Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,11 +1,17 @@
|
|
| 1 |
import streamlit as st
|
|
|
|
| 2 |
from mca_comment_analyzer import MCACommentAnalyzer
|
| 3 |
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
st.title("π MCA eConsultation Comment Analyzer")
|
| 7 |
|
| 8 |
-
# Sidebar
|
| 9 |
st.sidebar.header("Upload or Enter Comments")
|
| 10 |
upload_file = st.sidebar.file_uploader("Upload a text file with comments", type=["txt"])
|
| 11 |
manual_input = st.sidebar.text_area("Or enter comments (one per line):")
|
|
@@ -16,20 +22,28 @@ if upload_file:
|
|
| 16 |
elif manual_input.strip():
|
| 17 |
comments = manual_input.strip().split("\n")
|
| 18 |
|
| 19 |
-
if st.sidebar.button("Analyze"):
|
| 20 |
if comments:
|
| 21 |
analyzer = MCACommentAnalyzer()
|
| 22 |
df, keyword_freq = analyzer.process_comments(comments)
|
| 23 |
|
|
|
|
| 24 |
st.subheader("π Analysis Results")
|
| 25 |
st.dataframe(df, use_container_width=True)
|
| 26 |
|
|
|
|
| 27 |
st.subheader("π Sentiment Distribution")
|
| 28 |
sentiment_counts = df["Sentiment"].value_counts()
|
| 29 |
st.bar_chart(sentiment_counts)
|
| 30 |
|
|
|
|
| 31 |
st.subheader("βοΈ Word Cloud")
|
| 32 |
-
|
| 33 |
-
st.pyplot(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
else:
|
| 35 |
st.warning("β οΈ Please provide comments to analyze.")
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
import matplotlib.pyplot as plt
|
| 3 |
from mca_comment_analyzer import MCACommentAnalyzer
|
| 4 |
|
| 5 |
+
# Streamlit Page Config
|
| 6 |
+
st.set_page_config(
|
| 7 |
+
page_title="MCA Comment Analyzer",
|
| 8 |
+
page_icon="π",
|
| 9 |
+
layout="wide"
|
| 10 |
+
)
|
| 11 |
|
| 12 |
st.title("π MCA eConsultation Comment Analyzer")
|
| 13 |
|
| 14 |
+
# Sidebar
|
| 15 |
st.sidebar.header("Upload or Enter Comments")
|
| 16 |
upload_file = st.sidebar.file_uploader("Upload a text file with comments", type=["txt"])
|
| 17 |
manual_input = st.sidebar.text_area("Or enter comments (one per line):")
|
|
|
|
| 22 |
elif manual_input.strip():
|
| 23 |
comments = manual_input.strip().split("\n")
|
| 24 |
|
| 25 |
+
if st.sidebar.button("π Analyze"):
|
| 26 |
if comments:
|
| 27 |
analyzer = MCACommentAnalyzer()
|
| 28 |
df, keyword_freq = analyzer.process_comments(comments)
|
| 29 |
|
| 30 |
+
# Show Analysis Results
|
| 31 |
st.subheader("π Analysis Results")
|
| 32 |
st.dataframe(df, use_container_width=True)
|
| 33 |
|
| 34 |
+
# Sentiment Distribution Chart
|
| 35 |
st.subheader("π Sentiment Distribution")
|
| 36 |
sentiment_counts = df["Sentiment"].value_counts()
|
| 37 |
st.bar_chart(sentiment_counts)
|
| 38 |
|
| 39 |
+
# Word Cloud
|
| 40 |
st.subheader("βοΈ Word Cloud")
|
| 41 |
+
fig = analyzer.generate_wordcloud(keyword_freq)
|
| 42 |
+
st.pyplot(fig)
|
| 43 |
+
|
| 44 |
+
# Keyword Frequency Table
|
| 45 |
+
st.subheader("π Keyword Frequency")
|
| 46 |
+
st.dataframe(keyword_freq, use_container_width=True)
|
| 47 |
+
|
| 48 |
else:
|
| 49 |
st.warning("β οΈ Please provide comments to analyze.")
|