Spaces:
Sleeping
Sleeping
Download app.py from saadtoorx/sentiment_analysis_app: direct link, hf CLI and curl.
- Browser
- Download file 857 Bytes
-
https://huggingface.co/spaces/saadtoorx/sentiment_analysis_app/resolve/main/app.py
- Command line
-
hf download hf://spaces/saadtoorx/sentiment_analysis_app/app.py
-
curl -L -o app.py https://huggingface.co/spaces/saadtoorx/sentiment_analysis_app/resolve/main/app.py
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.") | |