Spaces:
Sleeping
Sleeping
| 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) | |