Detect languages via a fasttext model
Project description
fastlid
Language identification based on fasttext (lid.176.ftz https://fasttext.cc/docs/en/language-identification.html).
The lid.176.ftz
file is licensed under Creative Commons Attribution-Share-Alike License 3.0 and is not part of this module. It is automatically downloaded from its external origin on the first run of this module.
This module attempts to immitate the follow two features of langid
- langid.classify: fastlid
- langid.set_languages(langs=[...]): fastlid.set_languages = [...]
- import fastlid
- fastlid.set_languages = ['nl','fr'])
- TODO: Commandline interface
Install it
pip install fastlid
or install from git
pip install git+https://github.com/ffreemt/fast-langid.git
# also works pip install git+https://github.com/ffreemt/fast-langid
or clone the git repo and install from source.
Use it
from fastlid import fastlid, supported_langs
# support 176 languages
print(supported_langs, len(supported_langs))
# ['af', 'als', 'am', 'an', 'ar', 'arz', 'as', 'ast', 'av', 'az'] 176
fastlid("test this")
# ('en', 0.765)
fastlid("test this 测试一下", k=2)
# (['zh', 'en'], [0.663, 0.124])
N.B. hanzidentifier
can be used to identify simplified Chinese or/and traditional Chinese should you need to do so.
For Developers
Install poetry
and yarn
the way you like it.
poetry install --dev
yarn install --dev
yarn test
yarn final
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.