saadtoorx's picture
Create app.py
a3e1bff verified
Raw History Blame Contribute Delete
857 Bytes
import streamlit as st
from textblob import TextBlob
# Streamlit App UI
st.title("Simple Sentiment Analysis App (No ML Model)")
st.write("This app uses basic Python logic with TextBlob for sentiment analysis.")
# User input
text = st.text_area("Enter your text here:")
# Analyze button
if st.button("Analyze Sentiment"):
if text.strip():
blob = TextBlob(text)
polarity = blob.sentiment.polarity # Range: -1 to 1
# Determine sentiment category
if polarity > 0:
sentiment = "Positive ๐Ÿ˜Š"
elif polarity < 0:
sentiment = "Negative ๐Ÿ˜ž"
else:
sentiment = "Neutral ๐Ÿ˜"
# Show results
st.success(f"**Sentiment:** {sentiment}")
st.info(f"**Polarity Score:** {polarity:.3f}")
else:
st.warning("Please enter some text to analyze.")