"""
Project Validation Script
Validates all modules and dependencies

Developer: RSK World
Website: https://rskworld.in
Email: help@rskworld.in
Phone: +91 93305 39277
Year: 2026
"""

import sys
import importlib

def check_imports():
    """
    Check if all required modules can be imported
    Developer: RSK World - https://rskworld.in
    """
    modules = [
        'flask',
        'nltk',
        'spacy',
        'transformers',
        'sklearn',
        'langdetect',
        'textstat',
        'numpy',
        'torch'
    ]
    
    print("Checking Python module imports...")
    print("=" * 50)
    
    missing_modules = []
    for module in modules:
        try:
            if module == 'sklearn':
                importlib.import_module('sklearn')
            else:
                importlib.import_module(module)
            print(f"✓ {module}")
        except ImportError:
            print(f"✗ {module} - MISSING")
            missing_modules.append(module)
    
    print("=" * 50)
    
    if missing_modules:
        print(f"\nMissing modules: {', '.join(missing_modules)}")
        print("Please install them using: pip install -r requirements.txt")
        return False
    else:
        print("\nAll required modules are installed!")
        return True

def check_project_modules():
    """
    Check if all project modules can be imported
    Developer: RSK World - https://rskworld.in
    """
    project_modules = [
        'text_preprocessing',
        'sentiment_analysis',
        'entity_recognition',
        'semantic_understanding',
        'text_summarization',
        'language_detection',
        'text_classification',
        'readability_analysis',
        'emotion_detection',
        'advanced_keywords',
        'pos_tagging',
        'text_similarity',
        'nlp_pipeline',
        'app'
    ]
    
    print("\nChecking project modules...")
    print("=" * 50)
    
    missing_modules = []
    for module in project_modules:
        try:
            importlib.import_module(module)
            print(f"✓ {module}.py")
        except ImportError as e:
            print(f"✗ {module}.py - ERROR: {e}")
            missing_modules.append(module)
    
    print("=" * 50)
    
    if missing_modules:
        print(f"\nMissing or broken modules: {', '.join(missing_modules)}")
        return False
    else:
        print("\nAll project modules are available!")
        return True

def check_spacy_model():
    """
    Check if spaCy model is installed
    Developer: RSK World - https://rskworld.in
    """
    print("\nChecking spaCy model...")
    print("=" * 50)
    
    try:
        import spacy
        nlp = spacy.load("en_core_web_sm")
        print("✓ spaCy English model (en_core_web_sm) is installed")
        return True
    except OSError:
        print("✗ spaCy English model (en_core_web_sm) is NOT installed")
        print("Please install it using: python -m spacy download en_core_web_sm")
        return False

def main():
    """
    Main validation function
    Developer: RSK World - https://rskworld.in
    """
    print("NLP Text Analysis Bot - Project Validation")
    print("Developer: RSK World - https://rskworld.in")
    print("=" * 50)
    
    results = []
    
    # Check imports
    results.append(("Python Dependencies", check_imports()))
    
    # Check project modules
    results.append(("Project Modules", check_project_modules()))
    
    # Check spaCy model
    results.append(("spaCy Model", check_spacy_model()))
    
    # Summary
    print("\n" + "=" * 50)
    print("VALIDATION SUMMARY")
    print("=" * 50)
    
    all_passed = True
    for name, passed in results:
        status = "PASS" if passed else "FAIL"
        print(f"{name}: {status}")
        if not passed:
            all_passed = False
    
    print("=" * 50)
    
    if all_passed:
        print("\n✓ All checks passed! Project is ready to use.")
        return 0
    else:
        print("\n✗ Some checks failed. Please fix the issues above.")
        return 1

if __name__ == '__main__':
    sys.exit(main())

