sdhanabal1 commited on
Commit
133c41f
1 Parent(s): 6977cda

Add spinner during computation

Browse files
Files changed (1) hide show
  1. app.py +22 -22
app.py CHANGED
@@ -66,28 +66,28 @@ def main() -> None:
66
  st.write('<style>div.row-widget.stRadio > div{flex-direction:row;}</style>', unsafe_allow_html=True)
67
  st.header("Input")
68
 
69
- with st.form(key='terms-and-conditions'):
70
- sentences_length_input = st.number_input(
71
- label='Number of sentences to be extracted:',
72
- min_value=1,
73
- value=st.session_state.sentences_length
74
- )
75
- tc_text_input = st.text_area(
76
- value=st.session_state.tc_text,
77
- label='Terms & conditions content or specify an URL:',
78
- height=240
79
- )
80
-
81
- submit_button = st.form_submit_button(label='Summarize')
82
-
83
- if submit_button:
84
-
85
- if is_valid_url(tc_text_input):
86
- extract_summary_sentences = summarizer.extractive_summary_from_url(tc_text_input, sentences_length_input)
87
- else:
88
- extract_summary_sentences = summarizer.extractive_summary_from_text(tc_text_input, sentences_length_input)
89
-
90
- abstract_summary_list = summarizer.abstractive_summary(extract_summary_sentences)
91
 
92
  display_abstractive_summary(abstract_summary_list)
93
  display_extractive_summary(tc_text_input, extract_summary_sentences)
 
66
  st.write('<style>div.row-widget.stRadio > div{flex-direction:row;}</style>', unsafe_allow_html=True)
67
  st.header("Input")
68
 
69
+ sentences_length_input = st.number_input(
70
+ label='Number of sentences to be extracted:',
71
+ min_value=1,
72
+ value=st.session_state.sentences_length
73
+ )
74
+ tc_text_input = st.text_area(
75
+ value=st.session_state.tc_text,
76
+ label='Terms & conditions content or specify an URL:',
77
+ height=240
78
+ )
79
+
80
+ summarize_button = st.button(label='Summarize')
81
+
82
+ if summarize_button:
83
+
84
+ with st.spinner('Summarizing the text...'):
85
+ if is_valid_url(tc_text_input):
86
+ extract_summary_sentences = summarizer.extractive_summary_from_url(tc_text_input, sentences_length_input)
87
+ else:
88
+ extract_summary_sentences = summarizer.extractive_summary_from_text(tc_text_input, sentences_length_input)
89
+
90
+ abstract_summary_list = summarizer.abstractive_summary(extract_summary_sentences)
91
 
92
  display_abstractive_summary(abstract_summary_list)
93
  display_extractive_summary(tc_text_input, extract_summary_sentences)