import streamlit as st from mca_comment_analyzer import MCACommentAnalyzer st.set_page_config(page_title="MCA Comment Analyzer", layout="wide") st.title("📊 MCA eConsultation Comment Analyzer") # Sidebar for batch input 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) st.subheader("📌 Analysis Results") st.dataframe(df, use_container_width=True) st.subheader("📊 Sentiment Distribution") sentiment_counts = df["Sentiment"].value_counts() st.bar_chart(sentiment_counts) st.subheader("☁️ Word Cloud") plt = analyzer.generate_wordcloud(keyword_freq) st.pyplot(plt) else: st.warning("⚠️ Please provide comments to analyze.")