orionweller commited on
Commit
02405e8
1 Parent(s): 49bc621

add options to turn features off

Browse files
Files changed (1) hide show
  1. app.py +14 -3
app.py CHANGED
@@ -174,7 +174,13 @@ with st.sidebar:
174
  st.header("Upload qrels")
175
  qrels_file = st.file_uploader("Choose a file", key="qrels")
176
  qrels = load_local_qrels(qrels_file)
177
-
 
 
 
 
 
 
178
  ## make sure all qids in qrels are in queries and write out a warning if not
179
  if queries is not None and qrels is not None:
180
  missing_qids = set(qrels.keys()) - set(queries.keys()) | set(queries.keys()) - set(qrels.keys())
@@ -271,7 +277,12 @@ if corpus is not None and queries is not None and qrels is not None:
271
  # relevant
272
  relevant_docs = list(qrels[str(inst_num)].keys())[:n_relevant_docs]
273
  doc_texts = [(doc_id, corpus[doc_id]["title"] if "title" in corpus[doc_id] else "", corpus[doc_id]["text"]) for doc_id in relevant_docs]
274
- splitting_words = find_dividing_words([item[1] + " " + item[2] for item in doc_texts])
 
 
 
 
 
275
 
276
  # make a selectbox of these splitting words (allow multiple)
277
  container.subheader("Splitting Words")
@@ -284,7 +295,7 @@ if corpus is not None and queries is not None and qrels is not None:
284
  highlighted_texts = []
285
  highlighted_titles = []
286
  for (docid, title, text) in tqdm.tqdm(doc_texts):
287
- if not len(splitting_word_select):
288
  highlighted_texts.append(text)
289
  highlighted_titles.append(title)
290
  continue
 
174
  st.header("Upload qrels")
175
  qrels_file = st.file_uploader("Choose a file", key="qrels")
176
  qrels = load_local_qrels(qrels_file)
177
+ # add a checkbox to turn off highlighting
178
+ st.header("Highlighting Off")
179
+ highlighting_off = st.checkbox("Turn off highlighting", key="highlighting_off")
180
+ # add a checkbox to turn off word suggestions
181
+ st.header("Word Suggestions Off")
182
+ word_suggestions_off = st.checkbox("Turn off word suggestions", key="word_suggestions_off")
183
+
184
  ## make sure all qids in qrels are in queries and write out a warning if not
185
  if queries is not None and qrels is not None:
186
  missing_qids = set(qrels.keys()) - set(queries.keys()) | set(queries.keys()) - set(qrels.keys())
 
277
  # relevant
278
  relevant_docs = list(qrels[str(inst_num)].keys())[:n_relevant_docs]
279
  doc_texts = [(doc_id, corpus[doc_id]["title"] if "title" in corpus[doc_id] else "", corpus[doc_id]["text"]) for doc_id in relevant_docs]
280
+
281
+ if word_suggestions_off:
282
+ splitting_words = []
283
+ else:
284
+ splitting_words = find_dividing_words([item[1] + " " + item[2] for item in doc_texts])
285
+
286
 
287
  # make a selectbox of these splitting words (allow multiple)
288
  container.subheader("Splitting Words")
 
295
  highlighted_texts = []
296
  highlighted_titles = []
297
  for (docid, title, text) in tqdm.tqdm(doc_texts):
298
+ if not len(splitting_word_select) or highlighting_off:
299
  highlighted_texts.append(text)
300
  highlighted_titles.append(title)
301
  continue