nemoguardrails.library.utils.language_detection
nemoguardrails.library.utils.language_detection
Shared language-detection utilities for rails.
Detection is powered by fast-langdetect (the fastText lid.176 model),
which supports the 176 language codes listed in FASTTEXT_LANGUAGES:
https://fasttext.cc/docs/en/language-identification.html
Module Contents
Functions
Data
API
Detect the language of text using fast-langdetect.
Returns the ISO code of the most likely language (one of
FASTTEXT_LANGUAGES), or None when detection is unavailable
(fast-langdetect not installed) or fails.
Return the refusal message for lang.
Preference order: a custom message for the language, the built-in default for the language, a custom English message, then the built-in English one.