Discover the language.

Lets try and unbox Python langdetect library, which will be very useful for text processing and linguistic tasks. This is a language detection library implemented in plain Java.

Language detection with Python.

As stated in langdetect supports 55 languages out of the box , now maybe even more. So let's try some practical examples !

Lets install langdetect.

pip install langdetect

from langdetect import detect

Lets detect english text.

try_text="My daughter just revealed to me she's transexual... I guess that makes me transparent."

OUT: en

Lets detect spanish text.

try_text2='Hoy pasaré por la biblioteca para devolver los libros.'

OUT: es

Lets detect russian text.

try_text3="Ночь темна и полна ужасов, а холодильник светел и полон обещаний."

OUT: ru

Lets detect french text.

try_text4="La pire position sexuelle c'est quand t'es allongé en dessous et qu'au dessus il n'y a personne..."

OUT: fr

Lets detect chinese text.



OUT: zh-cn

See also related topics: