Harshb11 commited on
Commit
3d7895f
·
verified ·
1 Parent(s): 2e9406e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -25
app.py CHANGED
@@ -1,33 +1,36 @@
1
- import streamlit as st
2
- from mca_comment_analyzer 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:
14
- comments = upload_file.read().decode("utf-8").splitlines()
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.")
 
 
 
 
1
+ # app.py
 
2
 
3
+ # -----------------------------
4
+ # 1️⃣ Hugging Face cache fix
5
+ # -----------------------------
6
+ import os
7
+ os.environ["TRANSFORMERS_CACHE"] = "/tmp/cache"
8
 
9
+ # -----------------------------
10
+ # 2️⃣ Streamlit import
11
+ # -----------------------------
12
+ import streamlit as st
13
 
14
+ # -----------------------------
15
+ # 3️⃣ Local module import
16
+ # -----------------------------
17
+ from mca_comment_analyzer import MCACommentAnalyzerLight # check class name in your file
 
18
 
19
+ # -----------------------------
20
+ # 4️⃣ Streamlit App
21
+ # -----------------------------
22
+ st.title("MCA Comment Analyzer Light 📝")
23
 
24
+ # Example usage
25
+ st.write("Upload your comment file or input text below:")
26
 
27
+ user_input = st.text_area("Enter comment text:")
 
28
 
29
+ if st.button("Analyze"):
30
+ if user_input.strip() == "":
31
+ st.warning("Please enter some text!")
32
  else:
33
+ analyzer = MCACommentAnalyzerLight()
34
+ result = analyzer.analyze(user_input) # replace analyze() with your actual function
35
+ st.success("Analysis Result:")
36
+ st.write(result)