Skip to main content

Guess the natural language of a text

Project description

Attempts to determine the natural language of a selection of Unicode (utf-8) text.

Based on guesslanguage.cpp by Jacob R Rideout for KDE which itself is based on Language::Guess by Maciej Ceglowski.

Detects over 60 languages - all languages listed in the trigrams directory plus Japanese, Chinese, Korean and Greek.

guess_language uses heuristics based on the character set and trigrams in a sample text to detect the language. It works better with longer samples and will be confused if the sample text includes markup such as HTML tags.

Usage

The main entry points all take a single string as input and return a language identifier. The string must be Unicode or UTF-8 text. The language identifer can be the language name in English, the two- or three-letter IANA language code, a language ID or a tuple containing all three codes.

The primary entry points, and the return values, are as follows:

guessLanguage(txt) - IANA language code
guessLanguageTag(txt) - IANA language code (same as guessLanguage)
guessLanguageName(txt) - Language name in English
guessLanguageId(txt) - language ID
guessLanguageInfo(txt) - tuple of (IANA code, id, name)

Project details


Release history Release notifications | RSS feed

This version

0.2

Download files

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

Source Distribution

guess-language-0.2.tar.gz (98.9 kB view details)

Uploaded Source

File details

Details for the file guess-language-0.2.tar.gz.

File metadata

File hashes

Hashes for guess-language-0.2.tar.gz
Algorithm Hash digest
SHA256 b31ba2a279b8e6a19e9aa2f8e21c5fc4a56cd5557aea3f806cba73ecf38696e7
MD5 3a3574c2e8b44f84e656f90684f0c6aa
BLAKE2b-256 e4d0df50192865e44af5c934504d413514158c5e522b00d8ec631d818b6d8b6b

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 Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page