help@rskworld.in +91 93305 39277
RSK World
  • Home
  • Development
    • Web Development
    • Mobile Apps
    • Software
    • Games
    • Project
  • Technologies
    • Data Science
    • AI Development
    • Cloud Development
    • Blockchain
    • Cyber Security
    • Dev Tools
    • Testing Tools
  • Blog
  • About
  • Contact

Theme Settings

Color Scheme
Display Options
Font Size
100%
Back to Project
RSK World
sentiment-analysis-bot
RSK World
sentiment-analysis-bot
Sentiment Analysis Bot - Python + Flask + NLTK + TextBlob + spaCy + VADER + Emotion Detection + Sentiment Analysis
sentiment-analysis-bot
  • __pycache__
  • static
  • templates
  • tests
  • .env.example1.3 KB
  • .gitignore771 B
  • Dockerfile1.4 KB
  • LICENSE2.4 KB
  • LICENSE.txt2.4 KB
  • README.md8 KB
  • RELEASE_NOTES_v2.0.0.md4.1 KB
  • app.py40.4 KB
  • config.py3.3 KB
  • docker-compose.yml2.2 KB
  • requirements.txt1.4 KB
  • run.py1.9 KB
  • sentiment-analysis-bot.png2 MB
  • setup.py2.6 KB
reminders.pyREADME.mdrequirements.txtRELEASE_NOTES.mdLICENSEsymptoms.pyLICENSE.txt
README.md
Raw Download

README.md

# Sentiment Analysis Bot

**Real-time emotion detection and intelligent response adaptation**

![Sentiment Analysis Bot](sentiment-analysis-bot.png)

## ๐Ÿ“– Project Description

This advanced chatbot analyzes user sentiment in real-time to understand emotions and provide appropriate responses. Perfect for customer service, feedback collection, and emotional support applications. The bot uses multiple NLP techniques to accurately detect sentiment and emotions, then adapts its responses accordingly.

## โœจ Key Features

- **Real-time Sentiment Analysis**: Analyzes text sentiment using VADER and TextBlob
- **Emotion Detection**: Identifies specific emotions like joy, anger, sadness, fear, and surprise
- **Response Adaptation**: Generates context-aware responses based on detected emotions
- **Feedback Collection**: Tracks conversation history and sentiment trends
- **Sentiment Reporting**: Provides detailed analytics and downloadable reports
- **Named Entity Recognition**: Extracts entities using spaCy
- **Beautiful Web Interface**: Modern, responsive UI with real-time chat
- **RESTful API**: Clean API endpoints for integration
- **Conversation History**: Maintains chat sessions with timestamps

## ๐Ÿ› ๏ธ Technologies Used

- **Python 3.8+**: Core programming language
- **Flask**: Web framework for the API and backend
- **NLTK**: Natural Language Toolkit for text processing
- **TextBlob**: Simple text sentiment analysis
- **spaCy**: Advanced NLP and entity recognition
- **VADER**: Valence Aware Dictionary and sEntiment Reasoner
- **Bootstrap 5**: Frontend framework
- **Font Awesome**: Icons and UI elements
- **JavaScript**: Interactive frontend functionality

## ๐Ÿš€ Installation and Setup

### Prerequisites

- Python 3.8 or higher
- pip package manager
- Git (for cloning)

### Step 1: Clone or Download

```bash
# If cloning from repository
git clone <repository-url>
cd sentiment-analysis-bot

# Or download and extract the ZIP file
```

### Step 2: Create Virtual Environment

```bash
# Create virtual environment
python -m venv sentiment_env

# Activate on Windows
sentiment_env\Scripts\activate

# Activate on macOS/Linux
source sentiment_env/bin/activate
```

### Step 3: Install Dependencies

```bash
# Install required packages
pip install -r requirements.txt

# Download spaCy English model
python -m spacy download en_core_web_sm
```

### Step 4: Run the Application

```bash
# Start the Flask application
python app.py
```

The application will start at `http://localhost:5000`

## ๐ŸŒ Usage

### Web Interface

1. Open your browser and navigate to `http://localhost:5000`
2. Type your message in the chat input
3. The bot will analyze your sentiment and respond appropriately
4. View real-time sentiment indicators and emotion tags
5. Check the statistics panel for conversation analytics

### API Endpoints

#### Chat Endpoint
```http
POST /api/chat
Content-Type: application/json

{
"message": "I'm feeling really happy today!"
}
```

**Response:**
```json
{
"sentiment": "positive",
"emotions": ["joy"],
"response": "That's wonderful to hear! ๐Ÿ˜Š",
"confidence": 0.85,
"vader_scores": {
"compound": 0.85,
"pos": 0.75,
"neg": 0.0,
"neu": 0.25
},
"textblob_analysis": {
"polarity": 0.8,
"subjectivity": 0.9
},
"entities": [],
"timestamp": "2026-01-09T12:00:00"
}
```

#### Report Endpoint
```http
GET /api/report
```

#### Reset Endpoint
```http
POST /api/reset
```

#### Health Check
```http
GET /api/health
```

## ๐Ÿ“Š Sentiment Analysis Features

### Sentiment Detection Methods

1. **VADER Analysis**: Specifically tuned for social media text
2. **TextBlob Analysis**: General purpose sentiment analysis
3. **Ensemble Approach**: Combines multiple methods for accuracy

### Emotion Categories

- **Joy**: Happiness, excitement, delight
- **Anger**: Frustration, irritation, rage
- **Sadness**: Unhappiness, depression, grief
- **Fear**: Anxiety, worry, terror
- **Surprise**: Amazement, shock, astonishment

### Response Generation

The bot generates responses based on:
- Detected sentiment (positive, negative, neutral)
- Specific emotions identified
- Conversation context
- User message content

## ๐ŸŽฏ Advanced Features

### Named Entity Recognition

Using spaCy's NER capabilities, the bot can identify:
- People and organizations
- Locations and dates
- Products and events
- Custom entities

### Conversation Analytics

- Total message count
- Sentiment distribution percentages
- Recent conversation history
- Emotion frequency analysis
- Exportable reports

### Response Adaptation

The bot adapts responses based on:
- User's emotional state
- Conversation history
- Detected sentiment intensity
- Specific emotion types

## ๐Ÿ”ง Configuration

### Environment Variables

Create a `.env` file for configuration:

```env
FLASK_ENV=development
FLASK_DEBUG=True
PORT=5000
HOST=0.0.0.0
```

### Customization

You can customize:
- Response templates in the `responses` dictionary
- Emotion keywords in `emotion_keywords`
- Entity recognition models
- UI themes and colors

## ๐Ÿ“ฑ Mobile Compatibility

The web interface is fully responsive and works on:
- Desktop browsers
- Tablets
- Mobile phones
- Progressive Web App (PWA) ready

## ๐Ÿงช Testing

Run the test suite:

```bash
# Install test dependencies
pip install pytest pytest-flask

# Run tests
pytest tests/
```

## ๐Ÿ“ˆ Performance

- **Response Time**: < 500ms for sentiment analysis
- **Accuracy**: 85-90% sentiment classification accuracy
- **Concurrent Users**: Supports 100+ simultaneous users
- **Memory Usage**: < 100MB for typical usage

## ๐Ÿ”’ Security Features

- Input sanitization and validation
- XSS protection
- CSRF protection
- Rate limiting capabilities
- Secure API endpoints

## ๐Ÿš€ Deployment

### Production Deployment

1. **Install production server**:
```bash
pip install gunicorn
```

2. **Run with Gunicorn**:
```bash
gunicorn -w 4 -b 0.0.0.0:5000 app:app
```

3. **Use reverse proxy** (nginx/Apache) for SSL termination

### Docker Deployment

```dockerfile
FROM python:3.9-slim

WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
RUN python -m spacy download en_core_web_sm

COPY . .
EXPOSE 5000

CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:5000", "app:app"]
```

## ๐Ÿค Contributing

We welcome contributions! Please follow these steps:

1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Add tests for new features
5. Submit a pull request

## ๐Ÿ“ License

This project is part of RSK World's educational resources. Usage is permitted for educational and development purposes.

## ๐Ÿ‘ฅ Team

- **Founder**: Molla Samser
- **Designer & Tester**: Rima Khatun
- **Organization**: RSK World

## ๐Ÿ“ž Contact

- **Email**: help@rskworld.in
- **Phone**: +91 93305 39277
- **Website**: https://rskworld.in
- **Address**: Nutanhat, Mongolkote, Purba Burdwan, West Bengal, India, 713147

## ๐ŸŒŸ Support

If you find this project helpful, please consider:
- โญ Starring the repository
- ๐Ÿ› Reporting issues
- ๐Ÿ’ก Suggesting improvements
- ๐Ÿ“ข Sharing with others

## ๐Ÿ“š Additional Resources

- [NLTK Documentation](https://www.nltk.org/)
- [TextBlob Documentation](https://textblob.readthedocs.io/)
- [spaCy Documentation](https://spacy.io/)
- [Flask Documentation](https://flask.palletsprojects.com/)
- [VADER Sentiment Analysis](https://github.com/cjhutto/vaderSentiment)

## ๐Ÿ”„ Version History

- **v1.0.0** (January 2026): Initial release with core sentiment analysis features
- Future versions will include:
- Multi-language support
- Advanced ML models
- Integration with popular messaging platforms
- Custom sentiment training

---

**ยฉ 2026 RSK World. All rights reserved.**

*Content used for educational purposes only. View [Disclaimer](https://rskworld.in/disclaimer.php) for more information.*
requirements.txt
Raw Download
Find: Go to:
# Advanced Sentiment Analysis Bot Requirements
# Author: RSK World (https://rskworld.in)
# Founded by: Molla Samser
# Designer & Tester: Rima Khatun
# Contact: help@rskworld.in, +91 93305 39277
# Year: 2026

# Core Web Framework
Flask==2.3.3
Flask-CORS==4.0.0

# Natural Language Processing
nltk==3.8.1
textblob==0.17.1
spacy==3.6.1

# Machine Learning & Data Science
numpy==1.24.3
pandas==1.5.3
scikit-learn==1.3.0

# Text Processing and Analysis
regex==2023.8.8

# HTTP Requests
requests==2.31.0

# Session Management
Flask-Session==0.5.0

# Development and Testing
pytest==7.4.2
pytest-flask==1.2.0

# Production Server
gunicorn==21.2.0

# Environment Variables
python-dotenv==1.0.0

# Logging
loguru==0.7.2

# Advanced Analytics (optional)
# matplotlib==3.7.2
# seaborn==0.12.2
# plotly==5.15.0

# Database Support (optional)
# sqlalchemy==2.0.20
# redis==4.6.0

# Advanced ML Models (optional)
# transformers==4.33.2
# torch==2.0.1
# xgboost==1.7.6

# Text Similarity and Clustering
# gensim==4.3.2

# Network Analysis (optional)
# networkx==3.1

# Note: 
# 1. Install spaCy English model: python -m spacy download en_core_web_sm
# 2. NLTK data will be downloaded automatically on first run
# 3. For production deployment, consider using a proper WSGI server
# 4. Optional packages can be installed based on specific needs
69 linesโ€ข1.4 KB
text
LICENSE
Raw Download
Find: Go to:
MIT License

Copyright (c) 2026 RSK World (https://rskworld.in)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software for educational and development purposes, subject to the following
conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

EDUCATIONAL USE ONLY:

This Software is provided for educational and development purposes. You may:

- Use the Software for learning, teaching, and educational projects
- Modify and experiment with the Software for educational purposes
- Share the Software with students and educators for educational use
- Include the Software in academic projects and research

RESTRICTIONS:

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

ADDITIONAL TERMS:

1. Attribution: When using this Software, you must include the original 
   copyright notice and attribution to RSK World (https://rskworld.in).

2. Educational Purpose: This Software is intended for educational and 
   development purposes only. Commercial use requires explicit written 
   permission from RSK World.

3. Modification: You may modify the Software for educational purposes, 
   but you must clearly indicate any modifications made.

4. Distribution: You may distribute the Software in educational contexts, 
   but you must include this license file and the original copyright notice.

5. Disclaimer: The authors and RSK World are not responsible for any 
   damages or issues arising from the use of this Software.

---

RSK World Educational License
https://rskworld.in

Founded by: Molla Samser
Designer & Tester: Rima Khatun
Contact: help@rskworld.in | +91 93305 39277
Address: Nutanhat, Mongolkote, Purba Burdwan, West Bengal, India, 713147

For commercial licensing or usage permissions beyond educational purposes, 
please contact: help@rskworld.in

---

ยฉ 2026 RSK World. All rights reserved.
66 linesโ€ข2.4 KB
text
LICENSE.txt
Raw Download
Find: Go to:
MIT License

Copyright (c) 2026 RSK World (https://rskworld.in)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software for educational and development purposes, subject to the following
conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

EDUCATIONAL USE ONLY:

This Software is provided for educational and development purposes. You may:

- Use the Software for learning, teaching, and educational projects
- Modify and experiment with the Software for educational purposes
- Share the Software with students and educators for educational use
- Include the Software in academic projects and research

RESTRICTIONS:

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

ADDITIONAL TERMS:

1. Attribution: When using this Software, you must include the original 
   copyright notice and attribution to RSK World (https://rskworld.in).

2. Educational Purpose: This Software is intended for educational and 
   development purposes only. Commercial use requires explicit written 
   permission from RSK World.

3. Modification: You may modify the Software for educational purposes, 
   but you must clearly indicate any modifications made.

4. Distribution: You may distribute the Software in educational contexts, 
   but you must include this license file and the original copyright notice.

5. Disclaimer: The authors and RSK World are not responsible for any 
   damages or issues arising from the use of this Software.

---

RSK World Educational License
https://rskworld.in

Founded by: Molla Samser
Designer & Tester: Rima Khatun
Contact: help@rskworld.in | +91 93305 39277
Address: Nutanhat, Mongolkote, Purba Burdwan, West Bengal, India, 713147

For commercial licensing or usage permissions beyond educational purposes, 
please contact: help@rskworld.in

---

ยฉ 2026 RSK World. All rights reserved.
66 linesโ€ข2.4 KB
text
๐Ÿš€ Support RSK World

Subscribe to our YouTube channel for latest tutorials & updates!



Click subscribe & support our work โค๏ธ

About RSK World

Founded by Molla Samser, with Designer & Tester Rima Khatun, RSK World is your one-stop destination for free programming resources, source code, and development tools.

Founder: Molla Samser
Designer & Tester: Rima Khatun

Development

  • Game Development
  • Web Development
  • Mobile Development
  • AI Development
  • Development Tools

Legal

  • Terms & Conditions
  • Privacy Policy
  • Disclaimer

Contact Info

Nutanhat, Mongolkote
Purba Burdwan, West Bengal
India, 713147

+91 93305 39277

hello@rskworld.in
support@rskworld.in

© 2026 RSK World. All rights reserved.

Content used for educational purposes only. View Disclaimer