nlpblogs commited on
Commit
31e2b5d
·
verified ·
1 Parent(s): cd11bc4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -22
app.py CHANGED
@@ -214,42 +214,41 @@ st.button("Clear question", on_click=clear_question)
214
 
215
 
216
  if st.button("Sentiment Analysis"):
217
- placeholder = st.empty()
218
- progress_bar = st.progress(0)
219
-
220
  if st.session_state['url_count'] < max_attempts:
221
  if url:
222
- sentiment_df, df, fig1, fig2, fig3 = scrape_google_reviews(url)
 
223
  if sentiment_df is not None:
224
  st.success("Reviews scraped successfully!")
225
  df1 = df[['review_text', 'Sentiment', 'rating', 'review_date']]
226
  st.dataframe(df1)
227
-
228
  tab1, tab2, tab3 = st.tabs(["Pie Chart", "Bar Chart", "Scatter Plot"])
229
  if fig1 is not None:
230
  with tab1:
231
  st.plotly_chart(fig1)
232
- if fig2 is not None:
233
- with tab2:
234
- st.plotly_chart(fig2)
235
- if fig3 is not None:
236
- with tab3:
237
- st.plotly_chart(fig3)
238
- placeholder.text("Scrolling complete.")
239
- progress_bar.empty()
 
240
 
241
- buf = io.BytesIO()
242
- with zipfile.ZipFile(buf, "w") as myzip:
243
- myzip.writestr("Summary of the results.csv", df1.to_csv(index=False))
244
- with stylable_container(
245
  key="download_button",
246
  css_styles="""button { background-color: yellow; border: 1px solid black; padding: 5px; color: black; }""",
247
  ):
248
- st.download_button(
249
- label="Download zip file",
250
- data=buf.getvalue(),
251
- file_name="zip file.zip",
252
- mime="application/zip",
253
  )
254
 
255
 
 
214
 
215
 
216
  if st.button("Sentiment Analysis"):
 
 
 
217
  if st.session_state['url_count'] < max_attempts:
218
  if url:
219
+ with st.spinner("Wait for it...", show_time=True):
220
+ sentiment_df, df, fig1, fig2, fig3 = scrape_google_reviews(url)
221
  if sentiment_df is not None:
222
  st.success("Reviews scraped successfully!")
223
  df1 = df[['review_text', 'Sentiment', 'rating', 'review_date']]
224
  st.dataframe(df1)
225
+
226
  tab1, tab2, tab3 = st.tabs(["Pie Chart", "Bar Chart", "Scatter Plot"])
227
  if fig1 is not None:
228
  with tab1:
229
  st.plotly_chart(fig1)
230
+ if fig2 is not None:
231
+ with tab2:
232
+ st.plotly_chart(fig2)
233
+ if fig3 is not None:
234
+ with tab3:
235
+ st.plotly_chart(fig3)
236
+
237
+
238
+
239
 
240
+ buf = io.BytesIO()
241
+ with zipfile.ZipFile(buf, "w") as myzip:
242
+ myzip.writestr("Summary of the results.csv", df1.to_csv(index=False))
243
+ with stylable_container(
244
  key="download_button",
245
  css_styles="""button { background-color: yellow; border: 1px solid black; padding: 5px; color: black; }""",
246
  ):
247
+ st.download_button(
248
+ label="Download zip file",
249
+ data=buf.getvalue(),
250
+ file_name="zip file.zip",
251
+ mime="application/zip",
252
  )
253
 
254