JasonTPhillipsJr commited on
Commit
1f1627a
1 Parent(s): aafb64e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -258,11 +258,17 @@ selected_key = user_selection.split(" (")[0] # Remove the label part
258
  selected_review = example_reviews[selected_key]
259
  lower_case_review = selected_review.lower()
260
 
 
 
 
 
 
 
261
  # Process the text when the button is clicked
262
  if st.button("Process Review"):
263
  if lower_case_review.strip():
264
  bert_embedding = get_bert_embedding(lower_case_review)
265
- spaBert_embedding, current_pseudo_sentences = processSpatialEntities(selected_review,nlp)
266
  combined_embedding = torch.cat((bert_embedding,spaBert_embedding),dim=-1)
267
 
268
  if(dev_mode == True):
@@ -277,7 +283,7 @@ if st.button("Process Review"):
277
  doc = nlp(selected_review)
278
 
279
  # Highlight geo-entities with different colors
280
- highlighted_text = selected_review
281
  for ent in reversed(doc.ents):
282
  if ent.label_ in COLOR_MAP:
283
  color = COLOR_MAP[ent.label_][0]
 
258
  selected_review = example_reviews[selected_key]
259
  lower_case_review = selected_review.lower()
260
 
261
+ #Optional textbox for interactivity
262
+ user_input_review = st.text_area("Or type your own review here","")
263
+
264
+ review_to_process = user_input_review if user_input_review.strip() else selected_review
265
+ lower_case_review = review_to_process.lower()
266
+
267
  # Process the text when the button is clicked
268
  if st.button("Process Review"):
269
  if lower_case_review.strip():
270
  bert_embedding = get_bert_embedding(lower_case_review)
271
+ spaBert_embedding, current_pseudo_sentences = processSpatialEntities(review_to_process,nlp)
272
  combined_embedding = torch.cat((bert_embedding,spaBert_embedding),dim=-1)
273
 
274
  if(dev_mode == True):
 
283
  doc = nlp(selected_review)
284
 
285
  # Highlight geo-entities with different colors
286
+ highlighted_text = review_to_process
287
  for ent in reversed(doc.ents):
288
  if ent.label_ in COLOR_MAP:
289
  color = COLOR_MAP[ent.label_][0]