A small and fast language identification model powered by fastText
Project description
A simple answer to your language identification needs, powered by fastText. It wraps the language identification model in a small Python package for easier use.
Install
pip install ftlid
Example
from ftlid import identify_language, load_model
# prints 'en'
print(identify_language('Hello, how are you?'))
# prints (['en'], array([0.99987388]))
print(identify_language('Hello, how are you?', with_prob=True))
# prints ['en', 'de']
print(identify_language('And then he said "Ich liebe dich"!', k=2))
# prints (['en', 'de'], array([0.50208992, 0.30427793]))
print(identify_language('And then he said "Ich liebe dich"!', with_prob=True, k=2))
# if you want to use your custom model
print(identify_language('Hello, how are you?', model_path='model.ftz'))
# if you would like to pass the model yourself or prevent it from being loaded on every request
model = load_model('model.ftz')
print(identify_language('Hello, how are you?', model=model))
License
Licensed under the MIT license (see LICENSE file for more details).
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.
Source Distribution
ftlid-0.1.2.tar.gz
(782.3 kB
view details)
Built Distribution
ftlid-0.1.2-py3-none-any.whl
(780.1 kB
view details)
File details
Details for the file ftlid-0.1.2.tar.gz
.
File metadata
- Download URL: ftlid-0.1.2.tar.gz
- Upload date:
- Size: 782.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/0.12.17 CPython/3.7.4 Linux/5.4.12-200.fc31.x86_64
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 746c1cdbb3fc921b19ad355f41e63857793a66fa3a4d836216627eb2afeeca6a |
|
MD5 | 51e9caec94a955d9cf20ee8a03e554a1 |
|
BLAKE2b-256 | 8117e7373a81b508f8db6878dbf97b010f2c0ef336006a4e5115c667409c5f53 |
File details
Details for the file ftlid-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: ftlid-0.1.2-py3-none-any.whl
- Upload date:
- Size: 780.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/0.12.17 CPython/3.7.4 Linux/5.4.12-200.fc31.x86_64
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cad346581d795399dc2341f199d9ffc70c61182c8ce72da0c626a18e38353646 |
|
MD5 | bb15587cf68704b2adf85e8cec05e03a |
|
BLAKE2b-256 | 108ee52fd090d8f1801da24b85aeca3b4c40d3e6327b3ce08440515655ccd04b |