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