CarlosMalaga commited on
Commit
6806e2f
1 Parent(s): 846aa97

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -28
app.py CHANGED
@@ -355,44 +355,46 @@ def run_client():
355
  st.markdown(text, unsafe_allow_html=True)
356
  else:
357
  if selection_list == "Top-k DB in Taxonomy Intervention" or selection_list == "Top-k DB in Taxonomy Outcome":
358
- response = relik_model.retrieve(text, k=30, batch_size=400, progress_bar=False)
359
  candidates_text = [pred.document.text for pred in response[0] if pred.document.text in db_set]
360
  else:
361
  response = relik_model.retrieve(text, k=10, batch_size=400, progress_bar=False)
362
  candidates_text = [pred.document.text for pred in response[0]]
363
 
364
  if candidates_text:
365
- st.session_state.candidates = candidates_text[:5]
366
-
367
- dict_of_ents_candidates, options_candidates = get_retriever_annotations_candidates(text, st.session_state.candidates)
368
-
369
- st.markdown("<h2 style='color: black;'>Possible Candidates:</h2>", unsafe_allow_html=True)
370
-
371
- # Display the candidates with checkboxes
372
- for candidate in dict_of_ents_candidates["ents"]:
373
- if candidate in st.session_state.selected_candidates:
374
- checked = True
375
- else:
376
- checked = False
377
- if st.checkbox(candidate, key=candidate, value=checked):
378
- if candidate not in st.session_state.selected_candidates:
379
- st.session_state.selected_candidates.append(candidate)
380
- else:
381
- if candidate in st.session_state.selected_candidates:
382
- st.session_state.selected_candidates.remove(candidate)
383
-
384
- # Button to save the selected candidates to a file
385
- if st.button("Save Selected Candidates"):
386
- write_candidates_to_file(text, dict_of_ents_candidates["ents"], st.session_state.selected_candidates)
387
- st.success("Selected candidates have been saved to file.")
388
- else:
389
- st.session_state.candidates = []
390
- st.session_state.selected_candidates = []
391
- st.markdown("<h2 style='color: black;'>No Candidates Found</h2>", unsafe_allow_html=True)
392
 
393
  else:
394
  st.error("Please enter some text.")
395
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
396
 
397
  if __name__ == "__main__":
398
  run_client()
 
355
  st.markdown(text, unsafe_allow_html=True)
356
  else:
357
  if selection_list == "Top-k DB in Taxonomy Intervention" or selection_list == "Top-k DB in Taxonomy Outcome":
358
+ response = relik_model.retrieve(text, k=50, batch_size=400, progress_bar=False)
359
  candidates_text = [pred.document.text for pred in response[0] if pred.document.text in db_set]
360
  else:
361
  response = relik_model.retrieve(text, k=10, batch_size=400, progress_bar=False)
362
  candidates_text = [pred.document.text for pred in response[0]]
363
 
364
  if candidates_text:
365
+ st.session_state.candidates = candidates_text[:10]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
366
 
367
  else:
368
  st.error("Please enter some text.")
369
 
370
+ if st.session_state.candidates:
371
+ dict_of_ents_candidates, options_candidates = get_retriever_annotations_candidates(text, st.session_state.candidates)
372
+
373
+ st.markdown("<h2 style='color: black;'>Possible Candidates:</h2>", unsafe_allow_html=True)
374
+
375
+ # Display the candidates with checkboxes
376
+ for candidate in dict_of_ents_candidates["ents"]:
377
+ if candidate in st.session_state.selected_candidates:
378
+ checked = True
379
+ else:
380
+ checked = False
381
+ if st.checkbox(candidate, key=candidate, value=checked):
382
+ if candidate not in st.session_state.selected_candidates:
383
+ st.session_state.selected_candidates.append(candidate)
384
+ else:
385
+ if candidate in st.session_state.selected_candidates:
386
+ st.session_state.selected_candidates.remove(candidate)
387
+
388
+ # Button to save the selected candidates to a file
389
+ if st.button("Save Selected Candidates"):
390
+ write_candidates_to_file(text, dict_of_ents_candidates["ents"], st.session_state.selected_candidates)
391
+ st.success("Selected candidates have been saved to file.")
392
+
393
+ else:
394
+ st.session_state.candidates = []
395
+ st.session_state.selected_candidates = []
396
+ st.markdown("<h2 style='color: black;'>No Candidates Found</h2>", unsafe_allow_html=True)
397
+
398
 
399
  if __name__ == "__main__":
400
  run_client()