great-ai/great_ai/utilities/language/is_english.py
2022-07-04 19:31:15 +02:00

11 lines
295 B
Python

from typing import Optional
from langcodes import standardize_tag, tag_distance
def is_english(language_code: Optional[str]) -> bool:
if not language_code:
language_code = "und"
language_code = standardize_tag(language_code)
return tag_distance(language_code, "en") < 15