Python, Language Detection, Fastlangid
Language Detection with Fastlangid
A quick tutorial for detecting the language of a text
Published in
2 min readOct 22, 2022
In this short post, I will show you an example of the module Spacy fastlangid. This module can detect the language of a text.
The module is based on the model lid.176.ftz based on fastText. The model can detect the following languages:
It is recommended that the text has at least more than five characters/words (not a big issue for most cases). More details for this model are available here.
Installation
The installation is fast. You simple type
pip install fastlangid
Today, the last version is 1.0.9.
Usage
To use it, import the library and use it. Now, let’s see an example:
from fastlangid.langid import LIDlangid = LID()
Now that we have the langid object, we can pass it to the predict function:
result = langid.predict(‘This…