Update app.py
Browse files
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 |
-
|
|
|
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 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
|
|
240 |
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
key="download_button",
|
246 |
css_styles="""button { background-color: yellow; border: 1px solid black; padding: 5px; color: black; }""",
|
247 |
):
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
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 |
|