Move packages
Signed-off-by: András Schmelczer <andras@schmelczer.dev>
This commit is contained in:
parent
cef2e51c67
commit
acbdd96883
1 changed files with 123 additions and 27 deletions
|
|
@ -1,16 +0,0 @@
|
|||
from typing import Optional
|
||||
|
||||
from langcodes import Language
|
||||
from langdetect import LangDetectException, detect
|
||||
|
||||
|
||||
def predict_language(text: Optional[str]) -> str:
|
||||
if not text:
|
||||
return Language.make().to_tag()
|
||||
|
||||
try:
|
||||
language_code = detect(text)
|
||||
except LangDetectException:
|
||||
return Language.make().to_tag()
|
||||
|
||||
return Language.get(language_code).to_tag()
|
||||
Loading…
Reference in a new issue