Package: fasttext-langdetect
fasttext-langdetectThis library is a wrapper for the language detection model trained on fasttext by Facebook. For more information, please visit:https://fasttext.cc/docs/en/language-identification.htmlSupported languagesaf 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 cebckb 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 zhInstallpip install fasttext-langdetectUsagedetectmethod expects UTF-8 data.low_memoryoption enables getting predictions with the compressed version of the fasttext model by sacrificing the accuracy a bit.from ftlangdetect import detect

result = detect(text="Bugün hava çok güzel", low_memory=False)
print(result)
> {'lang': 'tr', 'score': 1.00}

result = detect(text="Bugün hava çok güzel", low_memory=True)
print(result)
> {'lang': 'tr', 'score': 0.9982126951217651}BenchmarkWe benchmarked the fasttext model againstcld2,langid, andlangdetecton Wili-2018 dataset.fasttextlangidlangdetectcld2Average time (ms)0,1582733811,72661870512,446043170,028776978139 langs - not weighted76,861,637,680,8139 langs - pop weighted95,593,186,692,744 langs - not weighted93,389,281,691,544 langs - pop weighted96,694,889,493,4pop weightedmeans recall for each language is multipled byits number of speakers.139 languages = all languages with ISO 639-1 2-letter code44 languages = top 44 languages spoken in the worldRecall per languagelangcld2fasttextlangdetectlangidAfrikaans0,940,9180,9920,966Albanian0,9580,9660,9640,954Amharic0,9760,98200,982Arabic0,9940,9980,9980,996Aragonese00,4300,788Armenian0,9660,97200,968Assamese0,9460,95600,14Avar00,62600Aymara0,596000Azerbaijani0,970,98800,984Bashkir0,970,9700Basque0,9780,9900,962Belarusian0,940,9700,964Bengali0,8980,9220,9040,942Bhojpuri0,7160,1500Bokmål0,8520,9660,9760,95Bosnian0,4220,10800,054Breton0,9460,97400,976Bulgarian0,8920,9640,9640,942Burmese0,9980,99800Catalan0,8820,950,930,928Central Khmer0,8760,87800,876Chechen00,9900Chuvash00,9600Cornish00,79200Corsican0,880,01600Croatian0,6880,8060,9820,932Czech0,9780,9860,9840,982Danish0,8860,9580,950,896Dhivehi0,9960,99800Dutch0,90,9780,9680,97English0,99210,9980,986Esperanto0,9360,97800,948Estonian0,9180,9520,9480,932Faroese0,912000,618Finnish0,9880,9980,9980,994French0,9460,9960,990,992Galician0,890,91200,93Georgian0,9740,97600,976German0,9580,9840,9780,978Guarani0,9680,72800Gujarati0,9320,9320,930,932Haitian Creole0,9880,53600,99Hausa0,976000Hebrew0,9940,9960,9980,998Hindi0,9820,9840,9820,972Hungarian0,960,9880,9680,986Icelandic0,9840,99600,996Ido00,7600Igbo0,798000Indonesian0,880,9460,9580,836Interlingua0,270,68800Interlingue0,1980,19200Irish0,9680,97800,984Italian0,8660,9480,9320,936Japanese0,970,9860,980,986Javanese00,86400,938Kannada0,9980,9980,9980,998Kazakh0,9780,99200,916Kinyarwanda0,86000,44Kirghiz0,9740,9900,408Komi00,54400Korean0,9860,990,9880,99Kurdish00,97200,976Lao0,840,84200,85Latin0,7780,86400,854Latvian0,980,9920,9920,99Limburgan00,32400Lingala0,85000Lithuanian0,960,9760,9740,97Luganda0,952000Luxembourgish0,8640,89400,93Macedonian0,880,9840,9820,974Malagasy0,990,9900,988Malay0,8960,58600,39Malayalam0,9880,9880,9880,988Maltese0,9620,96600,964Manx0,9720,29400Maori0,994000Marathi0,9580,9660,9640,942Modern Greek0,990,9920,990,992Mongolian0,9640,99400,996Navajo0000Nepali (macrolanguage)0,960,980,9780,922Northern Sami0000,866Norwegian Nynorsk0,940,7900,796Occitan0,660,4800,724Oriya0,960,95800,96Oromo0,956000Ossetian00,93800Panjabi0,9940,9940,9940,994Persian0,9920,9980,9960,998Polish0,9820,9980,9980,992Portuguese0,9080,9560,9460,952Pushto0,9380,92200,754Quechua0,9260,80800,852Romanian0,9320,9860,9840,984Romansh0,9340,32800Russian0,7280,9860,9840,988Sanskrit0,9640,97600Sardinian00,0100Scottish Gaelic0,9640,94200Serbian0,9420,94600,902Serbo-Croatian00,40200Shona0,844000Sindhi0,9780,98200Sinhala0,9620,96200,962Slovak0,9640,9740,9820,97Slovene0,8760,9660,9680,946Somali0,9240,6960,9560Spanish0,8940,9860,9760,98Standard Chinese0,9460,9840,7460,978Sundanese0,910,85400Swahili (macrolanguage)0,9240,920,9380,934Swedish0,8720,9940,9920,986Tagalog0,9280,9720,9740,964Tajik0,820,8500Tamil0,9920,9920,9920,994Tatar0,9780,98400Telugu0,9580,9580,9580,96Thai0,9880,9880,9880,988Tibetan0,9860,99200Tongan0,968000Tswana0,928000Turkish0,9680,9860,9820,976Turkmen0,940,93600Uighur0,9780,98600,964Ukrainian0,970,9880,9860,986Urdu0,860,9580,890,896Uzbek0,9840,9900Vietnamese0,9780,9860,9840,984Volapük0,9940,98200,986Walloon00,66400,98Welsh0,980,9920,9920,984Western Frisian0,8880,95600Wolof0,926000Xhosa0,928000,912Yiddish0,9560,95800Yoruba0,750,26200References[1] A. Joulin, E. Grave, P. Bojanowski, T. Mikolov,Bag of Tricks for Efficient Text Classification@article{joulin2016bag,
  title={Bag of Tricks for Efficient Text Classification},
  author={Joulin, Armand and Grave, Edouard and Bojanowski, Piotr and Mikolov, Tomas},
  journal={arXiv preprint arXiv:1607.01759},
  year={2016}
}[2] A. Joulin, E. Grave, P. Bojanowski, M. Douze, H. Jégou, T. Mikolov,FastText.zip: Compressing text classification models@article{joulin2016fasttext,
  title={FastText.zip: Compressing text classification models},
  author={Joulin, Armand and Grave, Edouard and Bojanowski, Piotr and Douze, Matthijs and J{\'e}gou, H{\'e}rve and Mikolov, Tomas},
  journal={arXiv preprint arXiv:1612.03651},
  year={2016}
}