hyperboria/nexus/nlptools/language_detect.py

8 lines
175 B
Python
Raw Normal View History

import cld3
def detect_language(text: str) -> str:
prediction = cld3.get_language(text)
if prediction and prediction.is_reliable:
return prediction.language