# services/language/language_factory.py
"""
Factory class for creating language detection services
"""
from typing import Optional, Set
from .base import LanguageDetectionService
from .langid_service import LangIdService


class LanguageFactory:
    """Factory class for creating language detection service instances"""

    @staticmethod
    def create_service(
        service_type: str, allowed_languages: Optional[Set[str]] = None, **kwargs
    ) -> Optional[LanguageDetectionService]:
        """
        Create an instance of the specified language detection service

        Args:
            service_type: Type of language detection service ("langid", etc.)
            allowed_languages: Set of allowed language codes
            **kwargs: Additional arguments for service initialization

        Returns:
            LanguageDetectionService instance or None if service_type is not recognized
        """
        services = {
            "langid": LangIdService,
            # Add other language detection services here
        }

        service_class = services.get(service_type.lower())
        if service_class:
            return service_class(allowed_languages=allowed_languages, **kwargs)
        else:
            raise ValueError(f"Unknown language detection service type: {service_type}")
