Spaces:
Sleeping
Sleeping
Download app/services/language.py from chotam/fraud-detector-api: direct link, hf CLI and curl.
- Browser
- Download file 424 Bytes
-
https://huggingface.co/spaces/chotam/fraud-detector-api/resolve/main/app/services/language.py
- Command line
-
hf download hf://spaces/chotam/fraud-detector-api/app/services/language.py
-
curl -L -o language.py https://huggingface.co/spaces/chotam/fraud-detector-api/resolve/main/app/services/language.py
424 Bytes
| from ..schemas import Lang | |
| _KZ_ONLY = set("әғқңөұүһі") | |
| _CYR_RANGE = (ord("а"), ord("я")) | |
| def detect_language(text: str, hint: Lang | None = None) -> Lang: | |
| if hint in ("ru", "kk"): | |
| return hint | |
| t = text.lower() | |
| if any(c in _KZ_ONLY for c in t): | |
| return "kk" | |
| for c in t: | |
| if _CYR_RANGE[0] <= ord(c) <= _CYR_RANGE[1] or c == "ё": | |
| return "ru" | |
| return "unknown" | |