mirror of
https://github.com/nexus-stc/hyperboria
synced 2024-12-23 18:17:45 +01:00
8472f27ec5
GitOrigin-RevId: ddf02e70d2827c048db49b687ebbcdcc67807ca6
10 lines
268 B
Python
10 lines
268 B
Python
import cld3
|
|
|
|
|
|
def detect_language(text: str) -> str:
|
|
prediction = cld3.get_language(text)
|
|
if prediction and prediction.is_reliable:
|
|
if prediction.language.endswith('-Latn'):
|
|
return prediction.language[:2]
|
|
return prediction.language
|