itzbhav commited on
Commit
e933299
Β·
verified Β·
1 Parent(s): 0c6742e

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +25 -0
  2. requirements.txt +2 -0
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from textblob import TextBlob
3
+
4
+ st.title("🧠 Mental Health Sentiment Analyzer")
5
+
6
+ st.markdown("Write your thoughts or journal entry below, and we'll analyze the emotional tone:")
7
+
8
+ user_input = st.text_area("Your entry", height=200)
9
+
10
+ if st.button("Analyze Sentiment"):
11
+ if user_input:
12
+ blob = TextBlob(user_input)
13
+ sentiment = blob.sentiment
14
+ st.subheader("Results:")
15
+ st.write(f"**Polarity**: {sentiment.polarity:.2f} (ranges from -1 [negative] to 1 [positive])")
16
+ st.write(f"**Subjectivity**: {sentiment.subjectivity:.2f} (ranges from 0 [objective] to 1 [subjective])")
17
+
18
+ if sentiment.polarity > 0.2:
19
+ st.success("Your entry reflects a positive mood. 😊")
20
+ elif sentiment.polarity < -0.2:
21
+ st.error("Your entry reflects a negative mood. 😟")
22
+ else:
23
+ st.warning("Your mood seems neutral or mixed. 😐")
24
+ else:
25
+ st.warning("Please enter some text first.")
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ streamlit
2
+ textblob