An advanced sentiment analysis web application built with Streamlit that analyzes text sentiment using NLTK's VADER and transformer-based models.
- Real-time sentiment analysis of text input
- Detailed sentiment scoring on a scale from -1 (very negative) to 1 (very positive)
- Statistical metrics (average, median, standard deviation)
- Visual representation of sentiment distribution
- Sentiment gauge visualization
- Downloadable results in CSV format
- Python 3.8 or higher
- pip (Python package manager)
- Clone this repository
- Install the required packages:
pip install -r requirements.txt - Download required NLTK data:
import nltk nltk.download('vader_lexicon')
Run the Streamlit app:
streamlit run sentiment_analysis_app.py
The application will open in your default web browser.
-
Enter or paste text in the input area (left column)
- Each line will be analyzed separately
- For best results, enter complete sentences
-
View sentiment scores in the right column
- Scores range from -1 (very negative) to 1 (very positive)
- Color coding provides quick visual feedback
-
Below the main interface, you'll find:
- Statistical metrics (average score and standard deviation)
- A histogram showing the distribution of sentiment scores
- A table with detailed results that can be sorted and filtered
-
The application updates in real-time as you type or modify the input text
The application uses two sentiment analysis models:
- NLTK's VADER (Valence Aware Dictionary and sEntiment Reasoner) - Optimized for social media text
- DistilBERT transformer model - Used as a backup for more complex cases
For each input text, the app:
- Calculates sentiment scores
- Provides sentiment labels (Very Negative to Very Positive)
- Displays statistical metrics
- Creates visualizations of sentiment distribution
- Allows downloading results as CSV
The application uses a pre-trained DistilBERT model from Hugging Face that has been fine-tuned for sentiment analysis. The model outputs are converted to a continuous scale between -1 and 1 for intuitive interpretation.
This project is open source and available for educational and personal use.
April 13, 2025
[Add screenshots here]