File size: 1,915 Bytes
72f90b1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
"""
Base Language Model Abstract Class

This module defines the interface that all language detection models must implement.
"""

from abc import ABC, abstractmethod
from typing import Dict, List, Any


class BaseLanguageModel(ABC):
    """
    Abstract base class for language detection models.
    
    All language detection models must inherit from this class and implement
    the required methods.
    """
    
    @abstractmethod
    def predict(self, text: str) -> Dict[str, Any]:
        """
        Predict the language of the given text.
        
        Args:
            text (str): Input text to analyze
            
        Returns:
            Dict containing prediction results with structure:
            {
                'predictions': [
                    {
                        'language_code': str,
                        'confidence': float
                    },
                    ...
                ],
                'text_length': int,
                'model_version': str,
                'model_type': str
            }
        """
        pass
    
    @abstractmethod
    def get_supported_languages(self) -> List[str]:
        """
        Get list of supported language codes.
        
        Returns:
            List of ISO 639-1 language codes
        """
        pass
    
    @abstractmethod
    def get_model_info(self) -> Dict[str, Any]:
        """
        Get information about the model.
        
        Returns:
            Dict containing model metadata and description with structure:
            {
                'name': str,
                'description': str,
                'accuracy': str,
                'model_size': str,
                'languages_supported': str,
                'training_details': str,
                'use_cases': str,
                'strengths': str,
                'limitations': str
            }
        """
        pass