JasonTPhillipsJr commited on
Commit
4aae01c
·
verified ·
1 Parent(s): dfc41ea

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -4
app.py CHANGED
@@ -12,7 +12,7 @@ from torch.utils.data import DataLoader
12
  from PIL import Image
13
 
14
  device = torch.device('cpu')
15
- dev_mode = True
16
 
17
 
18
  #Spacy Initialization Section
@@ -240,11 +240,21 @@ for label, (color, description) in COLOR_MAP.items():
240
  review_file_path = "models/spabert/datasets/SampleReviews.txt"
241
  example_reviews = load_reviews_from_file(review_file_path)
242
 
 
 
 
 
 
 
 
 
 
243
  # Dropdown for selecting an example review
244
- user_input = st.selectbox("Select an example review", options=list(example_reviews.keys()))
245
 
246
- # Get the selected review text
247
- selected_review = example_reviews[user_input]
 
248
 
249
  # Process the text when the button is clicked
250
  if st.button("Highlight Geo-Entities"):
 
12
  from PIL import Image
13
 
14
  device = torch.device('cpu')
15
+ dev_mode = False
16
 
17
 
18
  #Spacy Initialization Section
 
240
  review_file_path = "models/spabert/datasets/SampleReviews.txt"
241
  example_reviews = load_reviews_from_file(review_file_path)
242
 
243
+ # Define labels
244
+ review_labels = {
245
+ "Review 1": "Real",
246
+ "Review 2": "Spam",
247
+ }
248
+
249
+ # Create options with labels for the dropdown
250
+ dropdown_options = [f"{key} ({review_labels.get(key, 'Unknown')})" for key in example_reviews.keys()]
251
+
252
  # Dropdown for selecting an example review
253
+ user_selection = st.selectbox("Select an example review", options=dropdown_options)
254
 
255
+ # Extract the original review key from the selected option
256
+ selected_key = user_selection.split(" (")[0] # Remove the label part
257
+ selected_review = example_reviews[selected_key]
258
 
259
  # Process the text when the button is clicked
260
  if st.button("Highlight Geo-Entities"):