A beautiful, modern web application for sentiment analysis with improved UI/UX design, built with Flask and featuring a robust fallback sentiment analysis system.
- 🎨 Modern UI/UX Design: Clean, responsive interface with smooth animations
- 🧠 Dual Analysis System: Primary Skills Network Watson service with intelligent fallback
- 📱 Responsive Design: Works perfectly on desktop, tablet, and mobile devices
- ⚡ Real-time Feedback: Instant character counting and input validation
- 🎯 Visual Results: Confidence scores with animated progress bars for positive, negative, and neutral sentiment
- 🔄 Loading States: Smooth loading animations and user feedback
- 📝 Sample Texts: Pre-made examples to test the application quickly
- 🛡️ Robust Error Handling: Automatic fallback to local sentiment analysis when external service is unavailable
- 🎭 Three Sentiment Types: Positive, Negative, and Neutral with color-coded results
The app features:
- Gradient background with a modern card-based layout
- Animated buttons and interactive elements
- Color-coded sentiment results (positive/negative)
- Animated confidence score bars
- Character counting with color indicators
- Sample text buttons for quick testing
- Clone the repository:
git clone <your-repo-url>
cd sentiment-analysis- Create a virtual environment (recommended):
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- No additional setup required!
- The application uses a fallback sentiment analysis system that works without external API keys
- Primary service: Skills Network Watson (automatic fallback if unavailable)
- Secondary service: Local rule-based sentiment analysis (always available)
- Run the application:
python app.py- Open your browser and navigate to:
http://localhost:5000
- Use the application:
- Enter text in the textarea
- Click "Analyze Sentiment" button
- View the results with confidence scores
- Try sample texts for quick testing
- Flask: Lightweight web framework for Python
- Skills Network Watson: Primary sentiment analysis service
- Local Fallback: Rule-based sentiment analysis for reliability
- JSON Processing: Efficient data handling and parsing
- Error Handling: Robust exception management with automatic fallback
- HTML5: Modern semantic markup
- CSS3: Advanced styling with gradients, animations, and flexbox
- JavaScript: Modern ES6+ features with async/await
- Font Awesome: Icons for better visual appeal
- Google Fonts: Inter font family for modern typography
- Character counting with color coding
- Auto-resizing textarea
- Loading states and animations
- Error handling with user-friendly messages
- Responsive design for all screen sizes
- Sample text functionality
- Keyboard shortcuts (Ctrl+Enter to analyze)
- Celebration animations for high confidence results
- Three-tier sentiment classification (Positive, Negative, Neutral)
- Automatic service fallback for maximum reliability
GET /: Main application pagePOST /analyze: Sentiment analysis endpoint- Input:
textToAnalyze(form data) - Output: JSON with
labelandscore
- Input:
Modify static/style.css to change:
- Color schemes
- Typography
- Layout and spacing
- Animations and transitions
Modify static/script.js to add:
- New sample texts
- Additional validation
- Enhanced animations
- New features
Modify app.py to:
- Use different models
- Add new endpoints
- Implement additional features
- Service: Skills Network Watson Sentiment Analysis
- Type: BERT-based sentiment analysis model
- Labels: positive, negative, neutral
- Confidence: Score between 0 and 1 (confidence level)
- Type: Dictionary-based sentiment analysis
- Method: Positive/negative word counting with weighted scoring
- Labels: POSITIVE, NEGATIVE, NEUTRAL
- Confidence: Calculated based on word frequency and sentiment strength
- Reliability: Always available, no network dependency
- Chrome (recommended)
- Firefox
- Safari
- Edge
- Mobile browsers
- Primary Service: Fast API responses from Skills Network Watson service
- Fallback Service: Instant local analysis with no network dependency
- Reliability: 100% uptime with automatic fallback system
- Accuracy: High accuracy from BERT-based primary model, reasonable accuracy from rule-based fallback
- No API Limits: Free to use with no usage restrictions
sentiment-analysis/
├── app.py # Main Flask application
├── sentiment_analysis.py # Sentiment analysis logic with fallback
├── test_sentiment.py # Test script for validation
├── requirements.txt # Python dependencies
├── README.md # This file
├── DEPLOYMENT.md # Deployment guide
├── QUICK_START.md # Quick start guide
├── Procfile # Deployment configuration
├── runtime.txt # Python version specification
├── .env.example # Environment variables template
├── .gitignore # Git ignore file
├── templates/
│ └── index.html # Main HTML template
└── static/
├── style.css # CSS styling
└── script.js # JavaScript functionality
Run the included test script to verify functionality:
python test_sentiment.pyThis will test various text inputs and show the sentiment analysis results.
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is open source and available under the MIT License.
See the DEPLOYMENT.md file for detailed instructions on hosting this application for free on various platforms.
- Skills Network for the Watson sentiment analysis service
- Flask community for the excellent web framework
- Font Awesome for beautiful icons
- Google Fonts for modern typography
- Python community for the amazing ecosystem