Spaces:
Running
Running
Implement st.toast to track the progress of BERTopic.
Browse files- pages/2 Topic Modeling.py +20 -1
pages/2 Topic Modeling.py
CHANGED
@@ -34,6 +34,7 @@ import pipeline
|
|
34 |
from html2image import Html2Image
|
35 |
from umap import UMAP
|
36 |
import os
|
|
|
37 |
|
38 |
|
39 |
#===config===
|
@@ -96,7 +97,7 @@ def clean_csv(extype):
|
|
96 |
paper = paper[~paper.Abstract.str.contains("STRAIT")]
|
97 |
|
98 |
#===mapping===
|
99 |
-
paper['Abstract_pre'] = paper['Abstract'].map(lambda x: re.sub('[,:;\.!-?β’=]', '', x))
|
100 |
paper['Abstract_pre'] = paper['Abstract_pre'].map(lambda x: x.lower())
|
101 |
paper['Abstract_pre'] = paper['Abstract_pre'].map(lambda x: re.sub('Β©.*', '', x))
|
102 |
paper['Abstract_pre'] = paper['Abstract_pre'].str.replace('\u201c|\u201d', '', regex=True)
|
@@ -384,12 +385,30 @@ if uploaded_file is not None:
|
|
384 |
with st.spinner('Performing computations. Please wait ...'):
|
385 |
|
386 |
topic_model, topic_time, topics, probs = bertopic_vis(extype)
|
|
|
|
|
387 |
fig1 = Vis_Topics(extype)
|
|
|
|
|
|
|
388 |
fig2 = Vis_Documents(extype)
|
|
|
|
|
|
|
389 |
fig3 = Vis_Hierarchy(extype)
|
|
|
|
|
|
|
390 |
fig4 = Vis_Heatmap(extype)
|
|
|
|
|
|
|
391 |
fig5 = Vis_Barchart(extype)
|
|
|
|
|
|
|
392 |
fig6 = Vis_ToT(extype)
|
|
|
393 |
with st.expander("Visualize Topics"):
|
394 |
st.write(fig1)
|
395 |
with st.expander("Visualize Terms"):
|
|
|
34 |
from html2image import Html2Image
|
35 |
from umap import UMAP
|
36 |
import os
|
37 |
+
import time
|
38 |
|
39 |
|
40 |
#===config===
|
|
|
97 |
paper = paper[~paper.Abstract.str.contains("STRAIT")]
|
98 |
|
99 |
#===mapping===
|
100 |
+
paper['Abstract_pre'] = paper['Abstract'].map(lambda x: re.sub('[,:;\.!-?β’=]', ' ', x))
|
101 |
paper['Abstract_pre'] = paper['Abstract_pre'].map(lambda x: x.lower())
|
102 |
paper['Abstract_pre'] = paper['Abstract_pre'].map(lambda x: re.sub('Β©.*', '', x))
|
103 |
paper['Abstract_pre'] = paper['Abstract_pre'].str.replace('\u201c|\u201d', '', regex=True)
|
|
|
385 |
with st.spinner('Performing computations. Please wait ...'):
|
386 |
|
387 |
topic_model, topic_time, topics, probs = bertopic_vis(extype)
|
388 |
+
time.sleep(.5)
|
389 |
+
st.toast('Visualize Topics', icon='π')
|
390 |
fig1 = Vis_Topics(extype)
|
391 |
+
|
392 |
+
time.sleep(.5)
|
393 |
+
st.toast('Visualize Document', icon='π')
|
394 |
fig2 = Vis_Documents(extype)
|
395 |
+
|
396 |
+
time.sleep(.5)
|
397 |
+
st.toast('Visualize Document Hierarchy', icon='π')
|
398 |
fig3 = Vis_Hierarchy(extype)
|
399 |
+
|
400 |
+
time.sleep(.5)
|
401 |
+
st.toast('Visualize Topic Similarity', icon='π')
|
402 |
fig4 = Vis_Heatmap(extype)
|
403 |
+
|
404 |
+
time.sleep(.5)
|
405 |
+
st.toast('Visualize Terms', icon='π')
|
406 |
fig5 = Vis_Barchart(extype)
|
407 |
+
|
408 |
+
time.sleep(.5)
|
409 |
+
st.toast('Visualize Topics over Time', icon='π')
|
410 |
fig6 = Vis_ToT(extype)
|
411 |
+
|
412 |
with st.expander("Visualize Topics"):
|
413 |
st.write(fig1)
|
414 |
with st.expander("Visualize Terms"):
|