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
  • 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
validate_project.pyintent_recognizer.py
validate_project.py
Raw Download
Find: Go to:
"""
Project Validation Script
Validates all project files and checks for errors.

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

import os
import sys
import importlib.util
from pathlib import Path


def check_file_exists(filepath):
    """Check if file exists."""
    if os.path.exists(filepath):
        print(f"[OK] {filepath}")
        return True
    else:
        print(f"[MISSING] {filepath}")
        return False


def check_import(module_name):
    """Check if module can be imported."""
    try:
        spec = importlib.util.find_spec(module_name)
        if spec is None:
            print(f"[FAIL] Cannot import {module_name}")
            return False
        print(f"[OK] {module_name} - Import successful")
        return True
    except Exception as e:
        print(f"[FAIL] {module_name} - Import failed: {e}")
        return False


def check_syntax(filepath):
    """Check Python file syntax."""
    try:
        with open(filepath, 'r', encoding='utf-8') as f:
            compile(f.read(), filepath, 'exec')
        print(f"[OK] {filepath} - Syntax OK")
        return True
    except SyntaxError as e:
        print(f"[ERROR] {filepath} - Syntax Error: {e}")
        return False
    except Exception as e:
        print(f"[ERROR] {filepath} - Error: {e}")
        return False


def main():
    """Main validation function."""
    print("=" * 60)
    print("Conversational AI Bot - Project Validation")
    print("Developer: RSK World (https://rskworld.in)")
    print("=" * 60)
    print()
    
    errors = []
    
    # Required Python files
    print("Checking Required Files:")
    print("-" * 60)
    required_files = [
        'chatbot.py',
        'main.py',
        'app.py',
        'config.py',
        'context_manager.py',
        'intent_recognizer.py',
        'entity_extractor.py',
        'conversation_history.py',
        'sentiment_analyzer.py',
        'language_support.py',
        'api_integrations.py',
        'conversation_analytics.py',
        'response_templates.py',
        'requirements.txt',
        'README.md',
        'setup.py',
        '__init__.py'
    ]
    
    for file in required_files:
        if not check_file_exists(file):
            errors.append(f"Missing file: {file}")
    
    print()
    
    # Check directories
    print("Checking Required Directories:")
    print("-" * 60)
    required_dirs = ['templates', 'static']
    for dir_name in required_dirs:
        if os.path.exists(dir_name) and os.path.isdir(dir_name):
            print(f"[OK] {dir_name}/")
        else:
            print(f"[MISSING] {dir_name}/")
            errors.append(f"Missing directory: {dir_name}")
    
    print()
    
    # Check Python syntax
    print("Checking Python Syntax:")
    print("-" * 60)
    python_files = [f for f in required_files if f.endswith('.py')]
    for file in python_files:
        if os.path.exists(file):
            if not check_syntax(file):
                errors.append(f"Syntax error in: {file}")
    
    print()
    
    # Check imports
    print("Checking Module Imports:")
    print("-" * 60)
    modules_to_check = [
        'chatbot',
        'context_manager',
        'intent_recognizer',
        'entity_extractor',
        'conversation_history',
        'sentiment_analyzer',
        'language_support',
        'api_integrations',
        'conversation_analytics',
        'response_templates',
        'config'
    ]
    
    for module in modules_to_check:
        if not check_import(module):
            errors.append(f"Import error: {module}")
    
    print()
    
    # Summary
    print("=" * 60)
    if errors:
        print(f"[FAILED] Validation FAILED - {len(errors)} error(s) found:")
        for error in errors:
            print(f"  - {error}")
        return False
    else:
        print("[PASSED] Validation PASSED - All checks successful!")
        return True
    print("=" * 60)


if __name__ == "__main__":
    success = main()
    sys.exit(0 if success else 1)

160 lines•4.1 KB
python
intent_recognizer.py
Raw Download
Find: Go to:
"""
Intent Recognition Module
Recognizes user intentions from natural language input.

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

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


class IntentRecognizer:
    """
    Recognizes user intentions from natural language text.
    """
    
    def __init__(self):
        """Initialize the intent recognizer with predefined patterns."""
        # Intent patterns with keywords and confidence scores
        self.intent_patterns = {
            'greeting': {
                'keywords': ['hello', 'hi', 'hey', 'good morning', 'good afternoon', 
                           'good evening', 'greetings', 'howdy'],
                'patterns': [
                    r'\b(hello|hi|hey|greetings)\b',
                    r'good\s+(morning|afternoon|evening)',
                ],
                'confidence': 0.9
            },
            'goodbye': {
                'keywords': ['bye', 'goodbye', 'see you', 'farewell', 'later', 
                           'take care', 'adios'],
                'patterns': [
                    r'\b(bye|goodbye|see you|farewell)\b',
                    r'take\s+care',
                ],
                'confidence': 0.9
            },
            'question': {
                'keywords': ['what', 'when', 'where', 'who', 'why', 'how', 'which', 
                           'can you', 'could you', 'would you'],
                'patterns': [
                    r'^(what|when|where|who|why|how|which)',
                    r'\?',
                    r'can\s+you|could\s+you|would\s+you',
                ],
                'confidence': 0.8
            },
            'name_introduction': {
                'keywords': ['my name is', 'i am', 'i\'m', 'call me', 'name\'s'],
                'patterns': [
                    r'my\s+name\s+is',
                    r'i\s+am\s+[A-Z]',
                    r'i\'m\s+[A-Z]',
                    r'call\s+me',
                ],
                'confidence': 0.85
            },
            'name_query': {
                'keywords': ['what is my name', 'what\'s my name', 'do you know my name', 
                            'remember my name'],
                'patterns': [
                    r'what(\'s|\s+is)\s+my\s+name',
                    r'do\s+you\s+know\s+my\s+name',
                ],
                'confidence': 0.9
            },
            'help': {
                'keywords': ['help', 'assist', 'support', 'guide', 'how to', 'what can you'],
                'patterns': [
                    r'\bhelp\b',
                    r'what\s+can\s+you\s+do',
                    r'how\s+can\s+you\s+help',
                ],
                'confidence': 0.8
            },
            'weather': {
                'keywords': ['weather', 'temperature', 'rain', 'sunny', 'cloudy', 'forecast'],
                'patterns': [
                    r'weather',
                    r'temperature',
                    r'forecast',
                ],
                'confidence': 0.75
            },
            'time': {
                'keywords': ['time', 'what time', 'current time', 'clock'],
                'patterns': [
                    r'what\s+time',
                    r'current\s+time',
                    r'time\s+is',
                ],
                'confidence': 0.8
            },
            'date': {
                'keywords': ['date', 'what date', 'today\'s date', 'current date'],
                'patterns': [
                    r'what\s+date',
                    r'today\'s\s+date',
                    r'current\s+date',
                ],
                'confidence': 0.8
            },
            'compliment': {
                'keywords': ['thank', 'thanks', 'appreciate', 'great', 'awesome', 'good job'],
                'patterns': [
                    r'thank\s+you',
                    r'thanks',
                    r'great\s+job',
                ],
                'confidence': 0.7
            },
            'unknown': {
                'keywords': [],
                'patterns': [],
                'confidence': 0.0
            }
        }
    
    def recognize(self, text: str) -> Tuple[str, float]:
        """
        Recognize intent from text.
        
        Args:
            text: Input text to analyze
            
        Returns:
            Tuple of (intent_name, confidence_score)
        """
        if not text or not text.strip():
            return 'unknown', 0.0
        
        text_lower = text.lower().strip()
        intent_scores = {}
        
        # Calculate scores for each intent
        for intent_name, intent_data in self.intent_patterns.items():
            if intent_name == 'unknown':
                continue
            
            score = 0.0
            keywords = intent_data.get('keywords', [])
            patterns = intent_data.get('patterns', [])
            base_confidence = intent_data.get('confidence', 0.5)
            
            # Check keyword matches
            keyword_matches = sum(1 for keyword in keywords if keyword in text_lower)
            if keyword_matches > 0:
                score += (keyword_matches / len(keywords)) * base_confidence
            
            # Check pattern matches
            pattern_matches = sum(1 for pattern in patterns 
                                if re.search(pattern, text_lower, re.IGNORECASE))
            if pattern_matches > 0:
                score += (pattern_matches / len(patterns)) * base_confidence
            
            # Normalize score
            if keyword_matches > 0 or pattern_matches > 0:
                intent_scores[intent_name] = min(score, 1.0)
        
        # Return the intent with highest score
        if intent_scores:
            best_intent = max(intent_scores.items(), key=lambda x: x[1])
            return best_intent[0], best_intent[1]
        
        return 'unknown', 0.0
    
    def get_intent_confidence(self, intent: str) -> float:
        """
        Get base confidence score for an intent.
        
        Args:
            intent: Intent name
            
        Returns:
            Confidence score
        """
        return self.intent_patterns.get(intent, {}).get('confidence', 0.0)
    
    def get_all_intents(self) -> List[str]:
        """
        Get list of all supported intents.
        
        Returns:
            List of intent names
        """
        return [intent for intent in self.intent_patterns.keys() if intent != 'unknown']

194 lines•6.6 KB
python

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