This repo contains code for Detecting language from a given text in python using Facebook's library fasttext. A flask Restful API is also provided along.
$ pip3 install fasttext
$ pip3 install flask
To use as a Restfull api run the code app.py
. To simply use code without serving it as a API use language_identification.py
. Read more about this on my medium post.
curl -X POST \
http://127.0.0.1:5000/detect_language \
-H 'Content-Type: application/json' \
-d '{"text":"hello"}'
- As
K
value changes, number of languages returned by the model increases. Formating the return value in API needs to be done accordingly. Additionally the language iso code returned by the model could be converted to human understandable format by using additional python libraries likepycountry
language-identification
is a public domain work, dedicated using
CC0 1.0. Feel free to do
whatever you want with it.