orichain.lang_detect¶
- class orichain.lang_detect.LanguageDetection(languages: List[str] | None = None, min_words: int | None = None, low_accuracy: bool | None = False)[source]¶
Bases:
objectSynchronous interface for detecting the language of user messages using lingua-language-detector library.
- __init__(languages: List[str] | None = None, min_words: int | None = None, low_accuracy: bool | None = False) None[source]¶
Loading detector with requirements, by default loads all the languages with 0.0 min confidence
- Args:
languages (Optional[List], optional): List of languages to load. Defaults to None.
min_words (Optional[int], optional): Minimum words in the user message to detect language. Defaults to None.
low_accuracy (Optional[bool], optional): To enable low accuracy mode. Defaults to False.
- __call__(user_message: str, min_words: int | None = None, add_confidence: bool | None = False, iso_code_639_3: bool | None = False) Dict[source]¶
Runs language detection
- Args:
user_message (str): User message to detect language
min_words (Optional[int], optional): Minimum words in the user message to detect language. Defaults to None.
add_confidence (Optional[bool], optional): To add confidence in the result. Defaults to False.
iso_code_639_3 (Optional[bool], optional): To get iso code 639-3 instead of 639-1. Defaults to False.
- Returns:
Dict: Result of language detection
- class orichain.lang_detect.AsyncLanguageDetection(languages: List[str] | None = None, min_words: int | None = None, low_accuracy: bool | None = False)[source]¶
Bases:
objectAsynchronous interface for detecting the language of user messages using lingua-language-detector library.
- __init__(languages: List[str] | None = None, min_words: int | None = None, low_accuracy: bool | None = False) None[source]¶
Loading detector with requirements, by default loads all the languages with 0.0 min confidence
- Args:
languages (Optional[List], optional): List of languages to load. Defaults to None.
min_words (Optional[int], optional): Minimum words in the user message to detect language. Defaults to None.
low_accuracy (Optional[bool], optional): To enable low accuracy mode. Defaults to False.
- async __call__(user_message: str, min_words: int | None = None, add_confidence: bool | None = False, iso_code_639_3: bool | None = False) Dict[source]¶
Runs language detection
- Args:
user_message (str): User message to detect language
min_words (Optional[int], optional): Minimum words in the user message to detect language. Defaults to None.
add_confidence (Optional[bool], optional): To add confidence in the result. Defaults to False.
iso_code_639_3 (Optional[bool], optional): To get iso code 639-3 instead of 639-1. Defaults to False.
- Returns:
Dict: Result of language detection