Spaces:
Sleeping
Sleeping
File size: 876 Bytes
65d390d |
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 26 27 28 29 30 31 32 33 |
import streamlit as st
from textblob import TextBlob
# Streamlit page settings
st.set_page_config(page_title="Sentimental App", layout="centered")
# Title
st.title("π Sentimental App")
st.write("Analyze the sentiment of your text β positive, negative or neutral.")
# Input from user
user_input = st.text_area("Enter your text here:", height=150)
# Sentiment analysis function
def analyze_sentiment(text):
blob = TextBlob(text)
sentiment = blob.sentiment.polarity
if sentiment > 0:
return "Positive π"
elif sentiment < 0:
return "Negative π "
else:
return "Neutral π"
# Analyze button
if st.button("Analyze"):
if user_input.strip() == "":
st.warning("Please enter some text.")
else:
result = analyze_sentiment(user_input)
st.subheader("Sentiment Result:")
st.success(result)
|