A comprehensive web-based sentiment analysis tool for analyzing social media text from platforms like Twitter, Facebook, and Instagram. Built with Python, Streamlit, VADER, and spaCy.
- Real-time Sentiment Analysis: Analyze individual texts instantly
- Batch Processing: Analyze multiple texts at once
- Sample Data: Pre-loaded dataset for testing
- Interactive Visualizations:
- Sentiment distribution pie charts
- Score distribution histograms
- Sentiment score bar charts
- Word clouds for each sentiment category
- Confidence level analysis
- Social Media Text Handling:
- Emoji recognition
- Hashtag processing
- Slang normalization
- @mention handling
- URL removal
- Export Functionality: Download results as CSV
- Professional UI: Clean, modern interface with Streamlit
- Python 3.8+
- VADER Sentiment: Lexicon and rule-based sentiment analysis
- spaCy: Natural language processing
- Streamlit: Web application framework
- Plotly: Interactive visualizations
- WordCloud: Word cloud generation
- Pandas: Data manipulation
Sample dataset inspired by Sentiment140, containing 50 social media posts with:
- Various sentiment types (positive, negative, neutral)
- Emojis and special characters
- Hashtags and mentions
- Slang and informal language
Install Python dependencies:
pip install -r requirements.txtDownload spaCy language model (optional, for advanced preprocessing):
python -m spacy download en_core_web_smRun the application:
streamlit run app.pyOpen your browser to the URL shown (typically http://localhost:8501)
- Single Text: Analyze one text at a time
- Batch Analysis: Analyze multiple texts via manual input or file upload
- Sample Data: Use pre-loaded sample posts
- Sentiment classification (Positive/Negative/Neutral)
- Compound score (-1 to +1)
- Detailed sentiment scores
- Interactive visualizations
- Word clouds
- Export results as CSV
sentiment-analysis/
├── app.py # Main Streamlit application
├── sentiment_analyzer.py # VADER sentiment analysis engine
├── data_handler.py # Data loading and processing
├── visualizations.py # Chart and visualization functions
├── requirements.txt # Python dependencies
└── README.md # This file
Uses VADER (Valence Aware Dictionary and sEntiment Reasoner):
- Positive: Compound score ≥ 0.05 😊
- Neutral: -0.05 < Compound score < 0.05 😐
- Negative: Compound score ≤ -0.05 😞
- Slang normalization: Converts common slang (lol, omg, etc.) to full words
- Hashtag processing: Removes
#symbol but keeps the word - Mention removal: Removes
@mentions - URL removal: Strips out web links
- Emoji preservation: VADER handles emojis natively
- High: |compound score| ≥ 0.5
- Medium: 0.2 ≤ |compound score| < 0.5
- Low: |compound score| < 0.2
- Brand Monitoring
- Political Campaign Analysis
- Social Listening
- Customer Feedback Analysis
- Crisis Management
- Market Research
Sentiment: Positive 😊
Compound Score: 0.8516
Confidence: High
Detailed Scores:
- Positive: 0.4820
- Negative: 0.0000
- Neutral: 0.5180
- Input any social media text
- Get instant sentiment classification
- View detailed score breakdown
- See processed text comparison
- Manual input (multiple lines)
- File upload (CSV/TXT)
- Analyze up to hundreds of texts
- Comprehensive statistics
- Distribution Charts
- Score Histograms
- Bar Charts
- Word Clouds
- Confidence Analysis
This is an educational project demonstrating sentiment analysis concepts. Feel free to:
- Add more slang terms to the dictionary
- Improve preprocessing logic
- Add new visualization types
- Enhance the UI/UX
- VADER works best with social media text and informal language
- The model is lexicon-based, so it doesn’t require training
- Emojis significantly impact sentiment scores
- Context and sarcasm may not always be detected accurately
This project is for educational purposes. Feel free to use and modify as needed.
- VADER sentiment analysis tool by C.J. Hutto
- Sentiment140 dataset for inspiration
- Streamlit for the amazing web framework
- spaCy for NLP capabilities