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
multi-language-chatbot
/
modules
RSK World
multi-language-chatbot
Multi-language Chatbot - Python + Flask + OpenAI API + NLP + Translation + Language Detection + Cultural Adaptation
modules
  • __pycache__
  • __init__.py194 B
  • analytics_engine.py28.6 KB
  • chatbot_core.py10.8 KB
  • collaboration_manager.py22.3 KB
  • conversation_memory.py25.2 KB
  • cultural_adapter.py12.3 KB
  • document_analyzer.py21.5 KB
  • language_detector.py5.8 KB
  • multimodal_processor.py32.7 KB
  • personality_engine.py33.6 KB
  • sentiment_analyzer.py16.9 KB
  • translator.py7.5 KB
  • voice_processor.py13.2 KB
conversation_analytics.cpython-313.pycweather_api.cpython-313.pycapp.cpython-313.pyc.pre-commit-config.yamlsentiment_analysis.pyRELEASE_NOTES.mdcultural_adapter.py
app.cpython-313.pyc

This file cannot be displayed in the browser.

Download File
RELEASE_NOTES.md
Raw Download

RELEASE_NOTES.md

# Release Notes - Multi-language Chatbot v1.0.0

**Release Date:** January 2026
**Author:** RSK World (https://rskworld.in)
**Founder:** Molla Samser
**Designer & Tester:** Rima Khatun
**Contact:** help@rskworld.in | +91 93305 39277

---

## 🎉 Initial Release

This is the first stable release of the Multi-language Chatbot - an advanced NLP chatbot with comprehensive multi-language support and cultural adaptation.

## ✨ Features

### Core Features
- **🌍 Multi-language Support**: Communicate in 12+ languages including English, Hindi, Bengali, Spanish, French, German, Chinese, Japanese, Arabic, Portuguese, Russian, and Italian
- **🔍 Automatic Language Detection**: Automatically detects user's language with confidence scoring
- **🔄 Real-time Translation**: Seamlessly translates messages between supported languages
- **🎭 Cultural Adaptation**: Adapts responses based on cultural context and regional preferences
- **💬 Intelligent Conversation**: Powered by OpenAI GPT with fallback to rule-based responses
- **🎨 Modern Web Interface**: Responsive, Bootstrap-based UI with real-time chat

### Advanced Features
- **🎤 Voice Input/Output**: Speech-to-text and text-to-speech capabilities with multiple language support
- **😊 Sentiment Analysis**: Advanced sentiment and emotion detection with multi-language support
- **🧠 Conversation Memory**: Persistent conversation context with learning capabilities
- **📄 Document Analysis**: Support for PDF, Word, Excel, images with OCR and content extraction
- **👥 Real-time Collaboration**: Multi-user chat rooms with WebSocket support
- **📈 Advanced Analytics**: Comprehensive analytics dashboard with visualizations and reports
- **🎭 Personality Customization**: Multiple personality profiles (Professional, Friendly, Casual, Academic, Creative)
- **🖼️ Multi-modal Input**: Support for text, voice, images, video, and mixed input processing
- **📊 Session Analytics**: Track conversation statistics and language usage
- **💾 Chat History**: Save and export conversation history
- **🔒 Security Features**: Rate limiting, input validation, CORS configuration

## 🐛 Bug Fixes

- Fixed undefined `response` variable when `user_language == 'en'` in app.py
- Fixed undefined `detected_lang` variable when `user_language` is provided
- Removed incorrect `logging` package from requirements.txt (built-in module)
- Removed incorrect `tesseract-ocr` package from requirements.txt (system dependency)
- Created missing required directories (logs, instance)
- Improved configuration management and app initialization

## 📦 Technical Details

### Requirements
- Python 3.8 or higher
- Flask 2.3.3
- OpenAI API key (optional, for AI responses)
- Google Translate API key (optional, for enhanced translations)

### Installation
```bash
# Clone the repository
git clone https://github.com/rskworld/multi-language-chatbot.git
cd multi-language-chatbot

# Create virtual environment
python -m venv venv
venv\Scripts\activate # Windows
# source venv/bin/activate # macOS/Linux

# Install dependencies
pip install -r requirements.txt

# Copy environment file
cp .env.example .env

# Edit .env file with your API keys
# OPENAI_API_KEY=your_openai_api_key_here
# GOOGLE_TRANSLATE_API_KEY=your_google_translate_api_key_here

# Run the application
python run.py
```

### Project Structure
```
multi-language-chatbot/
├── app.py # Main Flask application
├── run.py # Application runner
├── config.py # Configuration settings
├── requirements.txt # Python dependencies
├── .env.example # Environment variables template
├── README.md # Documentation
├── LICENSE # MIT License
├── modules/ # Core modules
│ ├── language_detector.py
│ ├── translator.py
│ ├── cultural_adapter.py
│ ├── chatbot_core.py
│ ├── voice_processor.py
│ ├── sentiment_analyzer.py
│ ├── conversation_memory.py
│ ├── document_analyzer.py
│ ├── collaboration_manager.py
│ ├── analytics_engine.py
│ ├── personality_engine.py
│ └── multimodal_processor.py
├── templates/ # HTML templates
│ └── index.html
├── static/ # Static assets
│ ├── css/
│ │ └── style.css
│ └── js/
│ └── chatbot.js
├── tests/ # Test suite
│ └── test_chatbot.py
├── logs/ # Log files
└── instance/ # Instance files
```

## 🔧 API Endpoints

- `GET /` - Main chat interface
- `POST /chat` - Send message and get response
- `POST /detect_language` - Detect language of text
- `POST /translate` - Translate text between languages
- `GET /languages` - Get supported languages
- `GET /health` - Health check
- `POST /voice/speech-to-text` - Convert speech to text
- `POST /voice/text-to-speech` - Convert text to speech
- `POST /sentiment/analyze` - Analyze sentiment
- `GET /memory/conversation` - Get conversation history
- `POST /document/analyze` - Analyze uploaded document
- `GET /collaboration/rooms` - Get collaboration rooms
- `POST /collaboration/room/create` - Create collaboration room
- `GET /analytics/dashboard` - Get analytics data
- `GET /personality/profiles` - Get personality profiles
- `POST /personality/set` - Set personality profile
- `POST /multimodal/process` - Process multi-modal input

## 📚 Documentation

For detailed documentation, please refer to:
- [README.md](README.md) - Complete project documentation
- [manifest.ini](manifest.ini) - Project manifest
- [LICENSE](LICENSE) - MIT License

## 🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

## 📞 Support

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

## 📄 License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

---

**© 2026 RSK World. All rights reserved.**
*Content used for educational purposes only.*
modules/cultural_adapter.py
Raw Download
Find: Go to:
"""
Cultural Adaptation Module
Author: RSK World (https://rskworld.in)
Founder: Molla Samser
Designer & Tester: Rima Khatun
Contact: help@rskworld.in, +91 93305 39277
Year: 2026
Description: Cultural context adaptation for different regions
"""

import logging
from datetime import datetime
import pytz
import re

logger = logging.getLogger(__name__)

class CulturalAdapter:
    def __init__(self):
        self.cultural_contexts = {
            'en': {
                'greeting_style': 'casual',
                'formality_level': 'medium',
                'date_format': '%Y-%m-%d',
                'time_format': '%I:%M %p',
                'timezone': 'UTC',
                'cultural_notes': []
            },
            'hi': {
                'greeting_style': 'respectful',
                'formality_level': 'high',
                'date_format': '%d-%m-%Y',
                'time_format': '%I:%M %p',
                'timezone': 'Asia/Kolkata',
                'cultural_notes': ['Use respectful terms like "ji"', 'Avoid direct refusal', 'Consider family context']
            },
            'bn': {
                'greeting_style': 'respectful',
                'formality_level': 'high',
                'date_format': '%d-%m-%Y',
                'time_format': '%I:%M %p',
                'timezone': 'Asia/Dhaka',
                'cultural_notes': ['Use formal address', 'Show respect for elders', 'Consider cultural festivals']
            },
            'es': {
                'greeting_style': 'warm',
                'formality_level': 'medium',
                'date_format': '%d/%m/%Y',
                'time_format': '%H:%M',
                'timezone': 'Europe/Madrid',
                'cultural_notes': ['Use warm greetings', 'Consider siesta time', 'Family-oriented responses']
            },
            'fr': {
                'greeting_style': 'formal',
                'formality_level': 'high',
                'date_format': '%d/%m/%Y',
                'time_format': '%H:%M',
                'timezone': 'Europe/Paris',
                'cultural_notes': ['Use formal language', 'Proper greetings important', 'Cultural sophistication']
            },
            'de': {
                'greeting_style': 'formal',
                'formality_level': 'high',
                'date_format': '%d.%m.%Y',
                'time_format': '%H:%M',
                'timezone': 'Europe/Berlin',
                'cultural_notes': ['Be direct and precise', 'Use formal titles', 'Punctuality important']
            },
            'zh': {
                'greeting_style': 'respectful',
                'formality_level': 'high',
                'date_format': '%Y年%m月%d日',
                'time_format': '%H:%M',
                'timezone': 'Asia/Shanghai',
                'cultural_notes': ['Show respect for hierarchy', 'Avoid direct confrontation', 'Consider face-saving']
            },
            'ja': {
                'greeting_style': 'very_formal',
                'formality_level': 'very_high',
                'date_format': '%Y年%m月%d日',
                'time_format': '%H:%M',
                'timezone': 'Asia/Tokyo',
                'cultural_notes': ['Use honorific language', 'Be polite and indirect', 'Consider seasonal context']
            },
            'ar': {
                'greeting_style': 'formal',
                'formality_level': 'high',
                'date_format': '%d/%m/%Y',
                'time_format': '%I:%M %p',
                'timezone': 'Asia/Riyadh',
                'cultural_notes': ['Use Islamic greetings', 'Consider prayer times', 'Family and tradition important']
            },
            'pt': {
                'greeting_style': 'warm',
                'formality_level': 'medium',
                'date_format': '%d/%m/%Y',
                'time_format': '%H:%M',
                'timezone': 'America/Sao_Paulo',
                'cultural_notes': ['Warm and friendly', 'Personal connections', 'Consider regional differences']
            },
            'ru': {
                'greeting_style': 'formal',
                'formality_level': 'high',
                'date_format': '%d.%m.%Y',
                'time_format': '%H:%M',
                'timezone': 'Europe/Moscow',
                'cultural_notes': ['Use formal address', 'Be direct but polite', 'Consider cultural heritage']
            },
            'it': {
                'greeting_style': 'warm',
                'formality_level': 'medium',
                'date_format': '%d/%m/%Y',
                'time_format': '%H:%M',
                'timezone': 'Europe/Rome',
                'cultural_notes': ['Expressive communication', 'Personal relationships', 'Cultural references']
            }
        }
        
        self.regional_greetings = {
            'en': {
                'morning': ['Good morning', 'Hello'],
                'afternoon': ['Good afternoon', 'Hello'],
                'evening': ['Good evening', 'Hello'],
                'general': ['Hello', 'Hi', 'Hey']
            },
            'hi': {
                'morning': ['सुप्रभात', 'नमस्ते'],
                'afternoon': ['नमस्ते'],
                'evening': ['शुभ संध्या', 'नमस्ते'],
                'general': ['नमस्ते', 'प्रणाम']
            },
            'bn': {
                'morning': ['সুপ্রভাত', 'আসসালামু আলাইকুম'],
                'afternoon': ['আসসালামু আলাইকুম'],
                'evening': ['সুভ সন্ধ্যা', 'আসসালামু আলাইকুম'],
                'general': ['আসসালামু আলাইকুম', 'অ্যাডাব']
            },
            'es': {
                'morning': ['Buenos días', 'Hola'],
                'afternoon': ['Buenas tardes', 'Hola'],
                'evening': ['Buenas noches', 'Hola'],
                'general': ['Hola', '¿Qué tal?']
            },
            'fr': {
                'morning': ['Bonjour', 'Salut'],
                'afternoon': ['Bonjour', 'Salut'],
                'evening': ['Bonsoir', 'Salut'],
                'general': ['Bonjour', 'Salut']
            }
        }
    
    def adapt(self, text: str, target_language: str) -> str:
        """
        Adapt text for cultural context
        """
        try:
            if target_language not in self.cultural_contexts:
                return text
            
            context = self.cultural_contexts[target_language]
            adapted_text = text
            
            # Adapt formality level
            adapted_text = self._adapt_formality(adapted_text, context['formality_level'])
            
            # Add cultural context if appropriate
            adapted_text = self._add_cultural_context(adapted_text, target_language)
            
            # Adapt time/date references
            adapted_text = self._adapt_datetime_references(adapted_text, context)
            
            # Adapt greetings
            adapted_text = self._adapt_greetings(adapted_text, target_language)
            
            return adapted_text
            
        except Exception as e:
            logger.error(f"Cultural adaptation error: {str(e)}")
            return text
    
    def _adapt_formality(self, text: str, formality_level: str) -> str:
        """Adapt text formality level"""
        if formality_level in ['high', 'very_high']:
            # Make text more formal
            text = re.sub(r'\b(hi|hey)\b', 'hello', text, flags=re.IGNORECASE)
            text = re.sub(r'\b(you\'re|you are)\b', 'you are', text, flags=re.IGNORECASE)
            text = re.sub(r'\b(can\'t|cannot)\b', 'cannot', text, flags=re.IGNORECASE)
        elif formality_level == 'casual':
            # Make text more casual
            text = re.sub(r'\byou are\b', "you're", text, flags=re.IGNORECASE)
            text = re.sub(r'\bcannot\b', "can't", text, flags=re.IGNORECASE)
        
        return text
    
    def _add_cultural_context(self, text: str, language: str) -> str:
        """Add cultural context to responses"""
        cultural_additions = {
            'hi': [' ji', ' सर', ' मैम'],
            'bn': [' স্যার', ' ম্যাম', ' ভাই'],
            'ja': [' さん', ' 様'],
            'ar': [' أخي', ' أختي', ' سيدي'],
            'es': [' señor', ' señora', ' amigo'],
            'fr': [' monsieur', ' madame', ' ami']
        }
        
        # This is a simplified implementation
        # In practice, you'd want more sophisticated context-aware additions
        return text
    
    def _adapt_datetime_references(self, text: str, context: dict) -> str:
        """Adapt date and time references"""
        try:
            # Get current time in target timezone
            timezone = pytz.timezone(context['timezone'])
            now = datetime.now(timezone)
            
            # Replace generic time references with specific ones
            current_hour = now.hour
            
            if 'morning' in text.lower() and current_hour >= 12:
                text = text.replace('morning', 'day')
            elif 'evening' in text.lower() and current_hour < 17:
                text = text.replace('evening', 'afternoon')
            
            return text
            
        except Exception as e:
            logger.error(f"Datetime adaptation error: {str(e)}")
            return text
    
    def _adapt_greetings(self, text: str, language: str) -> str:
        """Adapt greetings based on time of day and culture"""
        try:
            if language not in self.regional_greetings:
                return text
            
            greetings = self.regional_greetings[language]
            timezone = pytz.timezone(self.cultural_contexts[language]['timezone'])
            now = datetime.now(timezone)
            hour = now.hour
            
            # Determine time of day
            if 5 <= hour < 12:
                time_period = 'morning'
            elif 12 <= hour < 17:
                time_period = 'afternoon'
            else:
                time_period = 'evening'
            
            # Replace generic greetings with time-appropriate ones
            if 'hello' in text.lower() or 'hi' in text.lower():
                appropriate_greetings = greetings.get(time_period, greetings['general'])
                if appropriate_greetings:
                    text = re.sub(r'\b(hello|hi)\b', appropriate_greetings[0], text, flags=re.IGNORECASE)
            
            return text
            
        except Exception as e:
            logger.error(f"Greeting adaptation error: {str(e)}")
            return text
    
    def get_cultural_tips(self, language: str) -> list:
        """Get cultural tips for a language"""
        context = self.cultural_contexts.get(language, {})
        return context.get('cultural_notes', [])
    
    def get_local_time(self, language: str) -> str:
        """Get current local time for language region"""
        try:
            if language not in self.cultural_contexts:
                return datetime.now().strftime('%H:%M')
            
            context = self.cultural_contexts[language]
            timezone = pytz.timezone(context['timezone'])
            now = datetime.now(timezone)
            
            return now.strftime(context['time_format'])
            
        except Exception as e:
            logger.error(f"Local time error: {str(e)}")
            return datetime.now().strftime('%H:%M')
    
    def get_local_date(self, language: str) -> str:
        """Get current local date for language region"""
        try:
            if language not in self.cultural_contexts:
                return datetime.now().strftime('%Y-%m-%d')
            
            context = self.cultural_contexts[language]
            timezone = pytz.timezone(context['timezone'])
            now = datetime.now(timezone)
            
            return now.strftime(context['date_format'])
            
        except Exception as e:
            logger.error(f"Local date error: {str(e)}")
            return datetime.now().strftime('%Y-%m-%d')
298 lines•12.3 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