fasttext
This module offers tools for fastText.
Hint
Use pip to install the necessary dependencies for this module:
pip install mltb2[fasttext]
- class mltb2.fasttext.FastTextLanguageIdentification[source]
Bases:
object
Identify languages of a text.
- __call__(text: str, num_lang: int = 10, always_detect_lang: list[str] | None = None)[source]
Identify languages of a given text.
- Parameters:
text (str) – the text for which the language is to be recognized
num_lang (int) – number of returned language probabilities
always_detect_lang (list[str] | None) – A list of languages that should always be returned even if not detected. If the language is not detected, the probability is set to 0.0.
- Returns:
A dict from language to probability. This dict contains no more than
num_lang
elements. So it is not guaranteed that the language you want to recognize is included in the dict. This is the case when the probability is very low. Possible languages are:af als am an ar arz as ast av az azb ba bar bcl be bg bh bn bo bpy br bs bxr ca cbk ce ceb ckb co cs cv cy da de diq dsb dty dv el eml en eo es et eu fa fi fr frr fy ga gd gl gn gom gu gv he hi hif hr hsb ht hu hy ia id ie ilo io is it ja jbo jv ka kk km kn ko krc ku kv kw ky la lb lez li lmo lo lrc lt lv mai mg mhr min mk ml mn mr mrj ms mt mwl my myv mzn nah nap nds ne new nl nn no oc or os pa pam pfl pl pms pnb ps pt qu rm ro ru rue sa sah sc scn sco sd sh si sk sl so sq sr su sv sw ta te tg th tk tl tr tt tyv ug uk ur uz vec vep vi vls vo wa war wuu xal xmf yi yo yue zh