Spaces:
Sleeping
Sleeping
import streamlit as st | |
from textblob import TextBlob | |
st.title("π§ Mental Health Sentiment Analyzer") | |
st.markdown("Write your thoughts or journal entry below, and we'll analyze the emotional tone:") | |
user_input = st.text_area("Your entry", height=200) | |
if st.button("Analyze Sentiment"): | |
if user_input: | |
blob = TextBlob(user_input) | |
sentiment = blob.sentiment | |
st.subheader("Results:") | |
st.write(f"**Polarity**: {sentiment.polarity:.2f} (ranges from -1 [negative] to 1 [positive])") | |
st.write(f"**Subjectivity**: {sentiment.subjectivity:.2f} (ranges from 0 [objective] to 1 [subjective])") | |
if sentiment.polarity > 0.2: | |
st.success("Your entry reflects a positive mood. π") | |
elif sentiment.polarity < -0.2: | |
st.error("Your entry reflects a negative mood. π") | |
else: | |
st.warning("Your mood seems neutral or mixed. π") | |
else: | |
st.warning("Please enter some text first.") |