Paula Leonova commited on
Commit
69a7d3f
1 Parent(s): 39c7695

Fix keyword dictionary from overwriting previous results

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -168,9 +168,12 @@ if submit_button or example_button:
168
  with st.spinner("Generating keywords from text..."):
169
 
170
  kw_dict = dict()
 
171
  for key in text_chunks_lib:
 
172
  for text_chunk in text_chunks_lib[key]:
173
- keywords_list = md.keyword_gen(kw_model, text_chunk)
 
174
  kw_dict[key] = dict(keywords_list)
175
  # Display as a dataframe
176
  kw_df0 = pd.DataFrame.from_dict(kw_dict).reset_index()
@@ -192,10 +195,10 @@ if submit_button or example_button:
192
 
193
 
194
  st.markdown("### Summary")
195
- with st.spinner(f'Generating summaries for {len(text_chunks)} text chunks (this may take a minute)...'):
196
 
197
- my_expander = st.expander(label=f'Expand to see intermediate summary generation details for {len(text_chunks)} text chunks')
198
- with my_expander:
199
  summary = []
200
 
201
  st.markdown("_Once the original text is broken into smaller chunks (totaling no more than 1024 tokens, \
 
168
  with st.spinner("Generating keywords from text..."):
169
 
170
  kw_dict = dict()
171
+ text_chunk_counter = 0
172
  for key in text_chunks_lib:
173
+ keywords_list = []
174
  for text_chunk in text_chunks_lib[key]:
175
+ text_chunk_counter += 1
176
+ keywords_list += md.keyword_gen(kw_model, text_chunk)
177
  kw_dict[key] = dict(keywords_list)
178
  # Display as a dataframe
179
  kw_df0 = pd.DataFrame.from_dict(kw_dict).reset_index()
 
195
 
196
 
197
  st.markdown("### Summary")
198
+ with st.spinner(f'Generating summaries for {text_chunk_counter} text chunks (this may take a minute)...'):
199
 
200
+ my_summary_expander = st.expander(label=f'Expand to see intermediate summary generation details for {len(text_chunks)} text chunks')
201
+ with my_summary_expander:
202
  summary = []
203
 
204
  st.markdown("_Once the original text is broken into smaller chunks (totaling no more than 1024 tokens, \