Skip to content
/ ftlid Public

A small and fast language identification model powered by fastText

License

Notifications You must be signed in to change notification settings

mrshu/ftlid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ftlid

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).

About

A small and fast language identification model powered by fastText

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages