Spaces:
Sleeping
Sleeping
Final Commit
Browse files
app.py
CHANGED
@@ -16,7 +16,7 @@ st.set_page_config(page_title="review Analysis", page_icon=":smiley:")
|
|
16 |
# Add image and heading
|
17 |
st.image("home.png", use_column_width=True)
|
18 |
|
19 |
-
file = st.file_uploader("
|
20 |
|
21 |
# Define the app's functionality
|
22 |
if file is not None:
|
@@ -40,7 +40,7 @@ if file is not None:
|
|
40 |
sentiment_counts = df["Sentiment"].value_counts()
|
41 |
fig = px.pie(sentiment_counts, values=sentiment_counts.values, names=sentiment_counts.index,
|
42 |
color_discrete_sequence=colors)
|
43 |
-
st.plotly_chart(fig)
|
44 |
|
45 |
# Create word clouds for positive and negative reviews
|
46 |
positive_reviews = " ".join(df[df["Sentiment"] == "POSITIVE"]["Review"].tolist())
|
@@ -51,23 +51,23 @@ if file is not None:
|
|
51 |
unsafe_allow_html=True
|
52 |
)
|
53 |
wc = WordCloud(width=800, height=400, background_color="white", colormap="Greens").generate(positive_reviews)
|
54 |
-
st.image(wc.to_array())
|
55 |
|
56 |
st.markdown(
|
57 |
f'<div style="background-color: #52565E; color: #ffffff; padding: 6px; font-size: 20px; font-family: Open-Sans; font-weight: bold; text-align: center; margin-bottom: 40px; margin-top: 60px;"> Causes behind Negative Reviews</div>',
|
58 |
unsafe_allow_html=True
|
59 |
)
|
60 |
wc = WordCloud(width=800, height=400, background_color="white", colormap="Greens").generate(negative_reviews)
|
61 |
-
st.image(wc.to_array())
|
62 |
|
63 |
# Display the sentiment of each review as cards
|
64 |
st.markdown(
|
65 |
-
f'<div style="background-color: #234A21; color: #ffffff; padding: 6px; font-size: 20px; font-family: Open-Sans; font-weight: bold; text-align: center; margin-
|
66 |
unsafe_allow_html=True
|
67 |
)
|
68 |
|
69 |
# Add the selectbox to filter sentiments
|
70 |
-
filter_sentiment = st.selectbox("
|
71 |
|
72 |
# Filter the dataframe based on the selected sentiment
|
73 |
if filter_sentiment != "All":
|
@@ -75,7 +75,7 @@ if file is not None:
|
|
75 |
|
76 |
# Create HTML table with no border and centered text
|
77 |
table_html = (df.style
|
78 |
-
.set_properties(**{'text-align': 'left','font-size': '
|
79 |
.set_table_styles([{'selector': 'th', 'props': [('border', '0px')]},
|
80 |
{'selector': 'td', 'props': [('border', '0px')]}])
|
81 |
.to_html(index=False, escape=False))
|
|
|
16 |
# Add image and heading
|
17 |
st.image("home.png", use_column_width=True)
|
18 |
|
19 |
+
file = st.file_uploader("", type=["csv"])
|
20 |
|
21 |
# Define the app's functionality
|
22 |
if file is not None:
|
|
|
40 |
sentiment_counts = df["Sentiment"].value_counts()
|
41 |
fig = px.pie(sentiment_counts, values=sentiment_counts.values, names=sentiment_counts.index,
|
42 |
color_discrete_sequence=colors)
|
43 |
+
st.plotly_chart(fig, use_container_width=True)
|
44 |
|
45 |
# Create word clouds for positive and negative reviews
|
46 |
positive_reviews = " ".join(df[df["Sentiment"] == "POSITIVE"]["Review"].tolist())
|
|
|
51 |
unsafe_allow_html=True
|
52 |
)
|
53 |
wc = WordCloud(width=800, height=400, background_color="white", colormap="Greens").generate(positive_reviews)
|
54 |
+
st.image(wc.to_array(),use_column_width=True)
|
55 |
|
56 |
st.markdown(
|
57 |
f'<div style="background-color: #52565E; color: #ffffff; padding: 6px; font-size: 20px; font-family: Open-Sans; font-weight: bold; text-align: center; margin-bottom: 40px; margin-top: 60px;"> Causes behind Negative Reviews</div>',
|
58 |
unsafe_allow_html=True
|
59 |
)
|
60 |
wc = WordCloud(width=800, height=400, background_color="white", colormap="Greens").generate(negative_reviews)
|
61 |
+
st.image(wc.to_array(),use_column_width=True)
|
62 |
|
63 |
# Display the sentiment of each review as cards
|
64 |
st.markdown(
|
65 |
+
f'<div style="background-color: #234A21; color: #ffffff; padding: 6px; font-size: 20px; font-family: Open-Sans; font-weight: bold; text-align: center; margin-top: 60px;"> What customers said about us</div>',
|
66 |
unsafe_allow_html=True
|
67 |
)
|
68 |
|
69 |
# Add the selectbox to filter sentiments
|
70 |
+
filter_sentiment = st.selectbox("", ["All", "POSITIVE", "NEGATIVE"])
|
71 |
|
72 |
# Filter the dataframe based on the selected sentiment
|
73 |
if filter_sentiment != "All":
|
|
|
75 |
|
76 |
# Create HTML table with no border and centered text
|
77 |
table_html = (df.style
|
78 |
+
.set_properties(**{'text-align': 'left','font-size': '15px','font-family': 'Open-Sans'})
|
79 |
.set_table_styles([{'selector': 'th', 'props': [('border', '0px')]},
|
80 |
{'selector': 'td', 'props': [('border', '0px')]}])
|
81 |
.to_html(index=False, escape=False))
|