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
conversational-ai-bot
RSK World
conversational-ai-bot
Conversational AI Bot - Python + NLP + Flask + Machine Learning + Chatbot + AI
conversational-ai-bot
  • __pycache__
  • static
  • templates
  • .gitignore577 B
  • ADVANCED_FEATURES.md5.7 KB
  • CHANGELOG.md2.2 KB
  • INSTALLATION.md1.8 KB
  • LICENSE1.2 KB
  • PROJECT_INFO.md2.8 KB
  • PROJECT_STATUS.md3.4 KB
  • QUICKSTART.md2.5 KB
  • README.md4.8 KB
  • __init__.py448 B
  • api_integrations.py6 KB
  • app.py4.2 KB
  • chatbot.py14.8 KB
  • config.py1.1 KB
  • context_manager.py5.8 KB
  • conversation_analytics.py5.9 KB
  • conversation_history.json413 B
  • conversation_history.py4.9 KB
  • entity_extractor.py6.6 KB
  • example_usage.py4.3 KB
  • intent_recognizer.py6.6 KB
  • language_support.py5 KB
  • main.py4.7 KB
  • requirements.txt311 B
  • response_templates.py7.2 KB
  • sentiment_analyzer.py5.6 KB
  • setup.py1.6 KB
  • test_chatbot.py5 KB
  • validate_project.py4.1 KB
pos_tagging.pyconfig.pyLICENSEsentiment_analyzer.py
config.py
Raw Download
Find: Go to:
"""
Configuration settings for Conversational AI Bot
Developer: RSK World
Website: https://rskworld.in
Email: help@rskworld.in
Phone: +91 93305 39277
Year: 2026
"""

# Bot Configuration
BOT_NAME = "Conversational AI Bot"
BOT_VERSION = "1.0.0"
DEFAULT_RESPONSE = "I'm sorry, I didn't understand that. Could you please rephrase?"

# Context Management
MAX_CONTEXT_HISTORY = 10  # Maximum number of previous messages to keep in context
CONTEXT_TIMEOUT = 3600  # Context timeout in seconds (1 hour)

# Intent Recognition
INTENT_CONFIDENCE_THRESHOLD = 0.6  # Minimum confidence score for intent recognition

# Entity Extraction
SUPPORTED_ENTITIES = ['PERSON', 'DATE', 'TIME', 'LOCATION', 'ORGANIZATION', 'MONEY', 'PERCENT']

# Conversation History
ENABLE_HISTORY = True
HISTORY_FILE = "conversation_history.json"
MAX_HISTORY_ENTRIES = 100

# NLP Settings
LANGUAGE = "en"
USE_LEMMATIZATION = True
REMOVE_STOPWORDS = True

# Developer Information
DEVELOPER_NAME = "RSK World"
DEVELOPER_WEBSITE = "https://rskworld.in"
DEVELOPER_EMAIL = "help@rskworld.in"
DEVELOPER_PHONE = "+91 93305 39277"
YEAR = 2026

42 lines•1.1 KB
python
LICENSE
Raw Download
Find: Go to:
MIT License

Copyright (c) 2026 RSK World

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 without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, 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.

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.

Developer: RSK World
Website: https://rskworld.in
Email: help@rskworld.in
Phone: +91 93305 39277
Year: 2026

29 lines•1.2 KB
text
sentiment_analyzer.py
Raw Download
Find: Go to:
"""
Sentiment Analysis Module
Analyzes sentiment of user messages to provide better responses.

Developer: RSK World
Website: https://rskworld.in
Email: help@rskworld.in
Phone: +91 93305 39277
Year: 2026
"""

from typing import Dict, Tuple
import re
from collections import Counter


class SentimentAnalyzer:
    """
    Analyzes sentiment of text using lexicon-based approach.
    Can be extended with ML models for better accuracy.
    """
    
    def __init__(self):
        """Initialize sentiment analyzer with sentiment lexicons."""
        # Positive words
        self.positive_words = {
            'good', 'great', 'excellent', 'awesome', 'fantastic', 'wonderful',
            'amazing', 'perfect', 'love', 'like', 'happy', 'glad', 'pleased',
            'delighted', 'satisfied', 'thankful', 'grateful', 'appreciate',
            'wonderful', 'brilliant', 'outstanding', 'superb', 'marvelous',
            'terrific', 'fabulous', 'splendid', 'nice', 'cool', 'fine',
            'okay', 'ok', 'yes', 'yeah', 'sure', 'definitely', 'absolutely'
        }
        
        # Negative words
        self.negative_words = {
            'bad', 'terrible', 'awful', 'horrible', 'worst', 'hate', 'dislike',
            'sad', 'angry', 'mad', 'frustrated', 'disappointed', 'upset',
            'annoyed', 'irritated', 'depressed', 'miserable', 'unhappy',
            'disgusting', 'pathetic', 'useless', 'stupid', 'dumb', 'idiot',
            'no', 'not', 'never', 'can\'t', 'won\'t', 'don\'t', 'doesn\'t',
            'shouldn\'t', 'wouldn\'t', 'couldn\'t', 'isn\'t', 'aren\'t'
        }
        
        # Intensifiers
        self.intensifiers = {
            'very', 'extremely', 'really', 'quite', 'rather', 'too', 'so',
            'incredibly', 'absolutely', 'completely', 'totally', 'utterly'
        }
        
        # Negation words
        self.negations = {
            'not', 'no', 'never', 'none', 'nobody', 'nothing', 'nowhere',
            'neither', 'nor', 'cannot', 'can\'t', 'won\'t', 'don\'t'
        }
    
    def analyze(self, text: str) -> Dict[str, any]:
        """
        Analyze sentiment of text.
        
        Args:
            text: Input text to analyze
            
        Returns:
            Dictionary with sentiment analysis results:
            {
                'sentiment': 'positive' | 'negative' | 'neutral',
                'score': float (-1.0 to 1.0),
                'confidence': float (0.0 to 1.0),
                'positive_words': list,
                'negative_words': list
            }
        """
        if not text or not text.strip():
            return {
                'sentiment': 'neutral',
                'score': 0.0,
                'confidence': 0.0,
                'positive_words': [],
                'negative_words': []
            }
        
        text_lower = text.lower()
        words = re.findall(r'\b\w+\b', text_lower)
        
        positive_count = 0
        negative_count = 0
        found_positive = []
        found_negative = []
        
        # Check for negations
        has_negation = any(neg in text_lower for neg in self.negations)
        
        # Analyze each word
        for i, word in enumerate(words):
            # Check for positive words
            if word in self.positive_words:
                # Check if negated
                if has_negation and i > 0 and words[i-1] in self.negations:
                    negative_count += 1
                    found_negative.append(word)
                else:
                    positive_count += 1
                    found_positive.append(word)
            
            # Check for negative words
            elif word in self.negative_words:
                # Check if negated
                if has_negation and i > 0 and words[i-1] in self.negations:
                    positive_count += 1
                    found_positive.append(word)
                else:
                    negative_count += 1
                    found_negative.append(word)
        
        # Calculate sentiment score
        total_sentiment_words = positive_count + negative_count
        if total_sentiment_words == 0:
            score = 0.0
            sentiment = 'neutral'
            confidence = 0.0
        else:
            score = (positive_count - negative_count) / max(total_sentiment_words, 1)
            
            if score > 0.1:
                sentiment = 'positive'
            elif score < -0.1:
                sentiment = 'negative'
            else:
                sentiment = 'neutral'
            
            confidence = min(abs(score) * 2, 1.0)
        
        return {
            'sentiment': sentiment,
            'score': round(score, 3),
            'confidence': round(confidence, 3),
            'positive_words': list(set(found_positive)),
            'negative_words': list(set(found_negative))
        }
    
    def get_sentiment_label(self, text: str) -> str:
        """
        Get simple sentiment label.
        
        Args:
            text: Input text
            
        Returns:
            'positive', 'negative', or 'neutral'
        """
        analysis = self.analyze(text)
        return analysis['sentiment']
    
    def is_positive(self, text: str) -> bool:
        """Check if text has positive sentiment."""
        return self.get_sentiment_label(text) == 'positive'
    
    def is_negative(self, text: str) -> bool:
        """Check if text has negative sentiment."""
        return self.get_sentiment_label(text) == 'negative'

163 lines•5.6 KB
python
🚀 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