Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| import matplotlib.pyplot as plt | |
| from mca_comment_analyzer import MCACommentAnalyzer | |
| # Streamlit Page Config | |
| st.set_page_config( | |
| page_title="MCA Comment Analyzer", | |
| page_icon="π", | |
| layout="wide" | |
| ) | |
| st.title("π MCA eConsultation Comment Analyzer") | |
| # Sidebar | |
| st.sidebar.header("Upload or Enter Comments") | |
| upload_file = st.sidebar.file_uploader("Upload a text file with comments", type=["txt"]) | |
| manual_input = st.sidebar.text_area("Or enter comments (one per line):") | |
| comments = [] | |
| if upload_file: | |
| comments = upload_file.read().decode("utf-8").splitlines() | |
| elif manual_input.strip(): | |
| comments = manual_input.strip().split("\n") | |
| if st.sidebar.button("π Analyze"): | |
| if comments: | |
| analyzer = MCACommentAnalyzer() | |
| df, keyword_freq = analyzer.process_comments(comments) | |
| # Show Analysis Results | |
| st.subheader("π Analysis Results") | |
| st.dataframe(df, use_container_width=True) | |
| # Sentiment Distribution Chart | |
| st.subheader("π Sentiment Distribution") | |
| sentiment_counts = df["Sentiment"].value_counts() | |
| st.bar_chart(sentiment_counts) | |
| # Word Cloud | |
| st.subheader("βοΈ Word Cloud") | |
| fig = analyzer.generate_wordcloud(keyword_freq) | |
| st.pyplot(fig) | |
| # Keyword Frequency Table | |
| st.subheader("π Keyword Frequency") | |
| st.dataframe(keyword_freq, use_container_width=True) | |
| else: | |
| st.warning("β οΈ Please provide comments to analyze.") | |