Spaces:
Sleeping
Sleeping
Upload 2 files
Browse files- app.py +25 -0
- 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
|