Dana Atzil commited on
Commit
c35872d
·
1 Parent(s): bfa1074

fix display

Browse files
Files changed (1) hide show
  1. streamlit_app_LDA.py +10 -5
streamlit_app_LDA.py CHANGED
@@ -21,8 +21,10 @@ num_topics = st.sidebar.slider("Number of Topics", min_value=2, max_value=20, va
21
  num_passes = st.sidebar.slider("Number of Passes", min_value=5, max_value=50, value=10)
22
  lda_document_is = st.radio("A 'Document' in the topic model will correspond to a:", ("self-state", "segment"))
23
  seed_value = st.sidebar.number_input("Random Seed", value=42)
24
- num_top_elements_to_show = st.sidebar.slider("# top element to show in a topic", min_value=2, max_value=15, value=5)
25
 
 
 
 
26
  # ---------------------------
27
  # Load Data
28
  # ---------------------------
@@ -138,8 +140,11 @@ st.text(output_str)
138
  # Prepare and Display pyLDAvis Visualization
139
  # ---------------------------
140
  st.header("Interactive Topic Visualization")
141
- # vis_dict = {i: element_short_desc_map[v] for i, v in dictionary.items()}
142
- # vis_dictionary = corpora.dictionary.Dictionary([[new_token] for new_token in vis_dict.values()])
143
- vis_data = gensimvis.prepare(lda_model, corpus, dictionary)
 
 
 
144
  html_string = pyLDAvis.prepared_data_to_html(vis_data)
145
- components.html(html_string, width=1300, height=800)
 
21
  num_passes = st.sidebar.slider("Number of Passes", min_value=5, max_value=50, value=10)
22
  lda_document_is = st.radio("A 'Document' in the topic model will correspond to a:", ("self-state", "segment"))
23
  seed_value = st.sidebar.number_input("Random Seed", value=42)
 
24
 
25
+ st.sidebar.header("Display")
26
+ num_top_elements_to_show = st.sidebar.slider("# top element to show in a topic", min_value=2, max_value=15, value=5)
27
+ show_long_elements = st.checkbox("Show full element name")
28
  # ---------------------------
29
  # Load Data
30
  # ---------------------------
 
140
  # Prepare and Display pyLDAvis Visualization
141
  # ---------------------------
142
  st.header("Interactive Topic Visualization")
143
+ if not show_long_elements:
144
+ vis_dict = {i: element_short_desc_map[v] for i, v in dictionary.items()}
145
+ vis_dictionary = corpora.dictionary.Dictionary([[new_token] for new_token in vis_dict.values()])
146
+ vis_data = gensimvis.prepare(lda_model, corpus, vis_dictionary)
147
+ else:
148
+ vis_data = gensimvis.prepare(lda_model, corpus, dictionary)
149
  html_string = pyLDAvis.prepared_data_to_html(vis_data)
150
+ components.html(html_string, width=2300, height=800, scrolling=True)