jishnuprakash commited on
Commit
d334f3e
1 Parent(s): 11dfa1d
Files changed (1) hide show
  1. app.py +11 -9
app.py CHANGED
@@ -62,7 +62,7 @@ trained_model, tokenizer, test, NER = load_model()
62
 
63
  st.header("Try out a text!")
64
  with st.form('model_prediction'):
65
- text = st.text_area("Input Text", " ".join(test.iloc[0]['text'])[:1525])
66
  n1, n2, n3 = st.columns((0.2,0.4,0.4))
67
  ner_check = n1.checkbox("Extract Location and Date", value=True)
68
  predict = n2.form_submit_button("Predict")
@@ -89,18 +89,20 @@ with st.form('model_prediction'):
89
  if ner_check:
90
  #Perform NER on a single text
91
  n_text = NER(text)
92
- loc = ''
93
- date = ''
94
  for word in n_text.ents:
95
  print(word.text,word.label_)
96
  if word.label_ == 'DATE':
97
- date += word.text + ', '
98
  elif word.label_ == 'GPE':
99
- loc += word.text + ', '
100
- loc = "None found" if len(loc)<1 else loc
101
- date = "None found" if len(date)<1 else date
102
- st.write("Location entities: " + loc)
103
- st.write("Date entities: " + date)
 
 
104
 
105
  #Display entities
106
  st.write("All Entities-")
 
62
 
63
  st.header("Try out a text!")
64
  with st.form('model_prediction'):
65
+ text = st.text_area("Input Text", test.iloc[0]['text'][20])
66
  n1, n2, n3 = st.columns((0.2,0.4,0.4))
67
  ner_check = n1.checkbox("Extract Location and Date", value=True)
68
  predict = n2.form_submit_button("Predict")
 
89
  if ner_check:
90
  #Perform NER on a single text
91
  n_text = NER(text)
92
+ loc = []
93
+ date = []
94
  for word in n_text.ents:
95
  print(word.text,word.label_)
96
  if word.label_ == 'DATE':
97
+ date.append(word.text)
98
  elif word.label_ == 'GPE':
99
+ loc.append(word.text)
100
+ loc = list(set(loc))
101
+ date = list(set(date))
102
+ loc = "None found" if len(loc)==0 else loc
103
+ date = "None found" if len(date)==0 else date
104
+ st.write("Location entities: " + ",".join(loc))
105
+ st.write("Date entities: " + ",".join(date))
106
 
107
  #Display entities
108
  st.write("All Entities-")