Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from mca_comment_analyzer import MCACommentAnalyzer
|
| 3 |
+
|
| 4 |
+
st.set_page_config(page_title="MCA Comment Analyzer", layout="wide")
|
| 5 |
+
|
| 6 |
+
st.title("📊 MCA eConsultation Comment Analyzer")
|
| 7 |
+
|
| 8 |
+
# Sidebar for batch input
|
| 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):")
|
| 12 |
+
|
| 13 |
+
comments = []
|
| 14 |
+
if upload_file:
|
| 15 |
+
comments = upload_file.read().decode("utf-8").splitlines()
|
| 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 |
+
plt = analyzer.generate_wordcloud(keyword_freq)
|
| 33 |
+
st.pyplot(plt)
|
| 34 |
+
else:
|
| 35 |
+
st.warning("⚠️ Please provide comments to analyze.")
|