Spaces:
Sleeping
Sleeping
File size: 992 Bytes
e933299 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
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.") |