CarlosMalaga commited on
Commit
0ff3b5f
1 Parent(s): 1a9a3a5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -6
app.py CHANGED
@@ -242,6 +242,12 @@ def set_intro(css):
242
  # "[Stefano Faralli](https://corsidilaurea.uniroma1.it/it/users/stefanofaralliuniroma1it), and [Roberto Navigli](https://www.diag.uniroma1.it/navigli/)."
243
  # )
244
 
 
 
 
 
 
 
245
  def run_client():
246
  with open(Path(__file__).parent / "style.css") as f:
247
  css = f.read()
@@ -341,7 +347,7 @@ def run_client():
341
  st.markdown(text, unsafe_allow_html=True)
342
  else:
343
  if selection_list == "Top-k DB in Taxonomy Intervention" or selection_list == "Top-k DB in Taxonmy Outcome":
344
- response = relik_model.retrieve(text, k=100, batch_size=400, progress_bar=False)
345
 
346
  candidates_text = []
347
  for pred in response[0]:
@@ -361,13 +367,24 @@ def run_client():
361
 
362
  dict_of_ents_candidates, options_candidates = get_retriever_annotations_candidates(text, candidates_text)
363
 
364
-
365
- text = """
366
- <h2 style='color: black;'>Possible Candidates:</h2>
367
- <ul style='color: black;'>
368
- """ + "".join(f"<li style='color: black;'>{candidate}</li>" for candidate in dict_of_ents_candidates["ents"]) + "</ul>"
369
 
370
  st.markdown(text, unsafe_allow_html=True)
 
 
 
 
 
 
 
 
 
 
 
371
  else:
372
 
373
  text = "<h2 style='color: black;'>No Candidates Found</h2>"
 
242
  # "[Stefano Faralli](https://corsidilaurea.uniroma1.it/it/users/stefanofaralliuniroma1it), and [Roberto Navigli](https://www.diag.uniroma1.it/navigli/)."
243
  # )
244
 
245
+ def write_candidates_to_file(text, candidates, selected_candidates):
246
+ # Write the selected candidates to a file
247
+ with open("logs/selected_candidates.tsv", "a") as file:
248
+ file.write(text + "\t" + str(candidates) + str(selected_candidates) + "\n")
249
+
250
+
251
  def run_client():
252
  with open(Path(__file__).parent / "style.css") as f:
253
  css = f.read()
 
347
  st.markdown(text, unsafe_allow_html=True)
348
  else:
349
  if selection_list == "Top-k DB in Taxonomy Intervention" or selection_list == "Top-k DB in Taxonmy Outcome":
350
+ response = relik_model.retrieve(text, k=30, batch_size=400, progress_bar=False)
351
 
352
  candidates_text = []
353
  for pred in response[0]:
 
367
 
368
  dict_of_ents_candidates, options_candidates = get_retriever_annotations_candidates(text, candidates_text)
369
 
370
+
371
+ text = "<h2 style='color: black;'>Possible Candidates:</h2>"
372
+ #<h2 style='color: black;'>Possible Candidates:</h2>
373
+ # <ul style='color: black;'>
374
+ # """ + "".join(f"<li style='color: black;'>{candidate}</li>" for candidate in dict_of_ents_candidates["ents"]) + "</ul>"
375
 
376
  st.markdown(text, unsafe_allow_html=True)
377
+ # Multiselect widget for selecting candidates
378
+ selected_candidates = st.multiselect(
379
+ "Select Candidates:",
380
+ dict_of_ents_candidates["ents"], # Options for the multiselect
381
+ help="Select one or more candidates from the list."
382
+ )
383
+ # Button to save the selected candidates to a file
384
+ if st.button("Save Selected Candidates"):
385
+ write_candidates_to_file(text, dict_of_ents_candidates["ents"], selected_candidates)
386
+ st.success("Selected candidates have been saved to file.")
387
+
388
  else:
389
 
390
  text = "<h2 style='color: black;'>No Candidates Found</h2>"