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.
Usage
To use it, import the library and use it. Now, let’s see an example:
from fastlangid.langid import LID
langid = LID()
Now, we have the langid object, and we can pass it to the predict:
result = langid.predict('This is a test')
print(f"The detected language is {result}")
The output is:
The detected language is en
For more details see this