Skip to main content

Language detection library ported from Google's language-detection.

Project description

langdetect

Port of [language-detection](https://code.google.com/p/language-detection/) (version from 03/03/2014) library to Python.

Installation

$ pip install langdetect

Supported Python versions 2.6, 2.7, 3.x.

Basic usage

To detect the language of the text:

>>> from langdetect import detect
>>> detect("War doesn't show who's right, just who's left.")
'en'
>>> detect("Ein, zwei, drei, vier")
'de'

To find out the probabilities for the top languages:

>>> from langdetect import detect_langs
>>> detect_langs("Otec matka syn.")
[sk:0.572770823327, pl:0.292872522702, cs:0.134356653968]

IMPORTANT

Language detection algorithm is non-deterministic, which means that if you try to run it on a text which is either too short or too ambiguous, you might get different results everytime you run it.

To enforce consistent results, call following code before the first language detection:

from langdetect import DetectorFactory DetectorFactory.seed = 0

More information

This library is a direct port of [language-detection](https://code.google.com/p/language-detection/) from Java to Python. All the classes and methods (even unit tests) are unchanged, so for more information see the project’s website or wiki.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langdetect-1.0.6.zip (995.8 kB view details)

Uploaded Source

File details

Details for the file langdetect-1.0.6.zip.

File metadata

  • Download URL: langdetect-1.0.6.zip
  • Upload date:
  • Size: 995.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for langdetect-1.0.6.zip
Algorithm Hash digest
SHA256 0275dc679100641bc3328f5ff20d0dc6a4e1c0fac22eac36e45a27cf410a8114
MD5 4e31fbb1ba3530f2498ca81b2c1e57ab
BLAKE2b-256 4fade6789fd51ce941e2b9cfb77503e16b447c969c148b004c2645935f20ce58

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page