Analyze the sentiment (positive, negative, or neutral) of any text input using Python's TextBlob library.
This script classifies text based on polarity and displays the result in a clean, emoji-coded format.
- 🧩 Under 100 lines of code
- ⚙️ Uses the
TextBloblibrary for polarity-based sentiment analysis - 🧠 Detects Positive 😊, Negative 😞, or Neutral 😐 tone
- 🧵 Handles invalid or empty input safely
- 💬 Clean and beginner-friendly terminal interface
If you haven’t already, install textblob and its corpora:
pip install textblob
python -m textblob.download_corporaMake sure to run inside your conda environment (e.g. sentiment_env).
python mini_sentiment_analyzer.pyExample Output:
MINI SENTIMENT ANALYZER
Type a sentence or paragraph to analyze sentiment.
Enter your text: I love Hacktoberfest and open source!
📊 Sentiment Result: Positive 😊
(Uses TextBlob for polarity-based sentiment detection.)