m. polinsky commited on
Commit
e517ab1
1 Parent(s): a8c2197

Update streamlit_app.py

Browse files
Files changed (1) hide show
  1. streamlit_app.py +17 -31
streamlit_app.py CHANGED
@@ -184,41 +184,27 @@ with st.form(key='columns_in_form'):
184
  if submitted:
185
  selections = [i for i in selections if i is not None]
186
  with st.spinner(text="Digesting...please wait, this will take a few moments...Maybe check some messages or start reading the latest papers on summarization with transformers...."):
187
- found = False
188
-
189
- # Check if we already have this digest.
190
- for i in digests:
191
- if set(selections) == set(list(i)):
192
- digestor = digests[i]
193
- found = True
194
- break
195
-
196
- # If we need a new digest
197
- if not found:
198
- chosen = []
199
- # Why not just use answers.values()?
200
- for i in selections: # i is supposed to be a list of stubs, mostly one
201
- if i != 'None':
202
- for j in clusters[i]:
203
- if j not in chosen:
204
- chosen.append(j) # j is supposed to be a stub.
205
-
206
- # Article dict contains stubs for unprocessed articles and lists of summarized chunks for processed ones.
207
- # Here we put together a list of article stubs and/or summary chunks and let the digestor sort out what it does with them,
208
- chosen = [i if isinstance(article_dict[i.hed], stub) else article_dict[i.hed] for i in chosen]
209
- # Digestor uses 'chosen', passed through 'stubs' to create digest.
210
- # 'user_choicese' is passed for reference.
211
- # Passing list(answers.values()) includes 'None' choices.
212
- digestor = Digestor(timer=Timer(), cache = USE_CACHE, stubs=chosen, user_choices=list(selections))
213
- # happens internally but may be used differently so it isn't automatic upon digestor creation.
214
- # Easily turn caching off for testing.
215
- digestor.digest() # creates summaries and stores them associated with the digest
216
 
217
 
218
 
219
  # Get displayable digest and digest data
220
- digestor.build_digest()# only returns for data collection
221
- digests[tuple(digestor.user_choices)] = digestor
222
 
223
  if len(digestor.text) == 0:
224
  st.write("You didn't select a topic!")
 
184
  if submitted:
185
  selections = [i for i in selections if i is not None]
186
  with st.spinner(text="Digesting...please wait, this will take a few moments...Maybe check some messages or start reading the latest papers on summarization with transformers...."):
187
+ chosen = []
188
+
189
+ for i in selections: # i is supposed to be a list of stubs, mostly one
190
+ if i != 'None':
191
+ for j in clusters[i]:
192
+ if j not in chosen:
193
+ chosen.append(j) # j is a stub.
194
+
195
+
196
+ # Digestor uses 'chosen' to create digest.
197
+ # 'user_choicese' is passed for reference.
198
+ digestor = Digestor(timer=Timer(), cache = USE_CACHE, stubs=chosen, user_choices=list(selections))
199
+ # happens internally but may be used differently so it isn't automatic upon digestor creation.
200
+ # Easily turn caching off for testing.
201
+ digestor.digest() # creates summaries and stores them associated with the digest
 
 
 
 
 
 
 
 
 
 
 
 
 
 
202
 
203
 
204
 
205
  # Get displayable digest and digest data
206
+ digestor.build_digest()
207
+
208
 
209
  if len(digestor.text) == 0:
210
  st.write("You didn't select a topic!")