green commited on
Commit
c73ef20
1 Parent(s): 038e757

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -16
app.py CHANGED
@@ -191,16 +191,17 @@ if not USE_CACHE:
191
  if LIMIT is not None:
192
  print(f"LIMIT: {LIMIT}")
193
 
194
- # digest store
195
  digests = dict() # key is cluster, value is digestor object
196
- out_dicts = []
197
  # list to accept user choices
198
  # retrieve cluster data and create dict to track each article (articleStubs)
199
  # and create topic clusters by performing ner.
200
  print("Initializing....")
201
  article_dict, clusters = initialize(LIMIT, USE_CACHE)
202
- # We now have clusters and cluster data. Redundancy.
203
- # We call a display function and get the user input.
 
204
  st.title("Welcome to TopicDig!")
205
  st.success(f"You select the topics, we summarize the relevant news and show you a digest, plus some info to help contextualize what the machine did.")
206
 
@@ -209,6 +210,7 @@ st.warning("Enjoy, and remember, these summaries contain a few kinds of issues,
209
  st.subheader(f"How it works:")
210
  st.write(f"""Select 1 to 3 topics from the drop down menus and click 'submit' to start generating your digest!""")
211
 
 
212
  with st.expander("See extra options"):
213
  st.subheader("Refresh topics: ")
214
  st.write("You may want to refresh the topic lists if the app loaded several hours ago or you get no summary.")
@@ -225,27 +227,19 @@ selections = []
225
  choices = list(clusters.keys())
226
  choices.insert(0,'None')
227
 
 
228
  # st.write(f"CNN articles: {st.session_state['cnn']}")
229
  # st.write(f"NPR articles: {st.session_state['npr']}")
230
  # st.write(f"Number of clusters {st.session_state['num_clusters']}")
231
 
232
-
233
  st.sidebar.subheader("Topics")
234
  show_clusters = {i:len(clusters[i]) for i in clusters.keys()}
235
  cdf = pd.DataFrame(data={"Articles":list(show_clusters.values()), "Cluster":list(show_clusters.keys())} )
236
  styler = cdf.style.hide_index()
237
- st.write(styler.to_html(), unsafe_allow_html=True)
238
-
239
- #st.write(df.to_html(index=False), unsafe_allow_html=True)
240
- st.sidebar.table(styler)
241
-
242
-
243
- """
244
- show_clusters.sort(key=lambda x: len(x[1]), reverse=True)
245
- for i in show_clusters:
246
- st.sidebar.write(f"{i[0]} : {len(i[1])}")
247
- """
248
 
 
249
  st.session_state['dt'] = dt.now()
250
  # Form used to take 3 menu inputs
251
  with st.form(key='columns_in_form'):
 
191
  if LIMIT is not None:
192
  print(f"LIMIT: {LIMIT}")
193
 
194
+ # digest store am I using this though? - april 15 2022
195
  digests = dict() # key is cluster, value is digestor object
196
+ out_dicts = [] # Am I using this? -dit
197
  # list to accept user choices
198
  # retrieve cluster data and create dict to track each article (articleStubs)
199
  # and create topic clusters by performing ner.
200
  print("Initializing....")
201
  article_dict, clusters = initialize(LIMIT, USE_CACHE)
202
+ # We now have clusters and cluster data. Redundancy?
203
+
204
+ # Welcome and explainer
205
  st.title("Welcome to TopicDig!")
206
  st.success(f"You select the topics, we summarize the relevant news and show you a digest, plus some info to help contextualize what the machine did.")
207
 
 
210
  st.subheader(f"How it works:")
211
  st.write(f"""Select 1 to 3 topics from the drop down menus and click 'submit' to start generating your digest!""")
212
 
213
+ # Provides expandable container for refresh and summarization parameters, currently only chunk size
214
  with st.expander("See extra options"):
215
  st.subheader("Refresh topics: ")
216
  st.write("You may want to refresh the topic lists if the app loaded several hours ago or you get no summary.")
 
227
  choices = list(clusters.keys())
228
  choices.insert(0,'None')
229
 
230
+ # May be desired in sidebar - april 15 2022
231
  # st.write(f"CNN articles: {st.session_state['cnn']}")
232
  # st.write(f"NPR articles: {st.session_state['npr']}")
233
  # st.write(f"Number of clusters {st.session_state['num_clusters']}")
234
 
235
+ # Display topics to user currently in sidebar - april 15 2022
236
  st.sidebar.subheader("Topics")
237
  show_clusters = {i:len(clusters[i]) for i in clusters.keys()}
238
  cdf = pd.DataFrame(data={"Articles":list(show_clusters.values()), "Cluster":list(show_clusters.keys())} )
239
  styler = cdf.style.hide_index()
240
+ st.sidebar.write(styler.to_html(), unsafe_allow_html=True)
 
 
 
 
 
 
 
 
 
 
241
 
242
+ # Get session time
243
  st.session_state['dt'] = dt.now()
244
  # Form used to take 3 menu inputs
245
  with st.form(key='columns_in_form'):