Detect an Unknown Language using Python
The idea behind language detection is based on the detection of the character among the expression and words in the text. The main principle is to detect commonly used words like to, of in English. Python provides various modules for language detection. In this article, the modules covered are:
Method 1: Using
This module is a port of Google’s language-detection library that supports 55 languages. This module don’t come with Python’s standard utility modules. So, it is needed to be installed externally. To install this type the below command in the terminal.
pip install langdetect
en ru es no hi ja
Method 2: Using
This module is used for natural language processing(NLP) tasks such as noun phrase extraction, sentiment analysis, classification, translation, and more. To install this module type the below command in the terminal.
pip install textblob
en ru es zh-CN hi ja
Method 3: Using
This module is a standalone Language Identification tool. It is pre-trained over a large number of languages (currently 97). It is a single.py file with minimal dependencies. To install this type the below command in the terminal.
pip install langrid
('en', -119.93012762069702) ('ru', -641.3409600257874) ('es', -191.01083326339722) ('zh', -199.18277835845947) ('hi', -286.99300467967987) ('ja', -875.6610476970673)
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course