gen_ai_hub.evaluations.utils.language_match_utils module¶
- class gen_ai_hub.evaluations.utils.language_match_utils.LanguageMapper¶
Bases:
objectUses the langcodes library to convert language strings to normalized ISO 639-1 strings, handling regional variants like zh-CN.
- EXCLUDED_CODES = {'bs', 'ms'}¶
- classmethod get_iso_code_639_1(code: str) str | None¶
Converts a language code string to its ISO 639-1 two-letter code.
- Parameters:
code (str) – Language code string (e.g., ‘zh-CN’, ‘en_US’, ‘en’)
- Returns:
Two-letter ISO 639-1 code (e.g., ‘zh’, ‘en’), or None if the code is invalid, excluded, or empty
- Return type:
Optional[str]