Skip to main content

Simple, fast dictionary-based language detector

Project description

LexiLang

Simple, fast dictionary-based language detector for short texts.

Installation

pip install lexilang

Usage

from lexilang.detector import detect

print(detect("bonjour")) # ('fr', 0.45)
print(detect("学中文")) # ('zh', 0.45)
print(detect("ciao mondo")) # ('it', 0.9)
print(detect("El gato doméstico")) # ('es', 0.45)

# Optionally, specify a subset of languages to consider
print(detect("ciao", languages=["de", "ro"])) # ('de', 0.45)

detect(text, languages=[]) -> tuple (iso_639_1, confidence)

Supported Languages

  • Afrikaans
  • Albanian
  • Arabic
  • Bengali
  • Bulgarian
  • Catalan
  • Chinese
  • Czech
  • Danish
  • Dutch
  • English
  • Esperanto
  • Estonian
  • Finnish
  • French
  • German
  • Greek
  • Hebrew
  • Hindi
  • Hungarian
  • Indonesian
  • Italian
  • Japanese
  • Kazakh
  • Korean
  • Latvian
  • Lithuanian
  • Macedonian
  • Norwegian
  • Polish
  • Portuguese
  • Romanian
  • Russian
  • Serbian
  • Slovak
  • Slovenian
  • Spanish
  • Swedish
  • Thai
  • Turkish
  • Ukrainian
  • Vietnamese
  • Farsi

Limitations

This detector was designed for handling small texts (< 20 characters). It will probably not work reliably for longer text sequences. As it relies on dictionaries, if a word is missing or mispelled, the detection will fail.

Contributing

If you want to add a new language, or improve an existing one, add more words to the respective dictionary in the dictionaries folder.

License

AGPLv3

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

LexiLang-1.0.2.tar.gz (1.5 MB view details)

Uploaded Source

Built Distribution

LexiLang-1.0.2-py3-none-any.whl (1.6 MB view details)

Uploaded Python 3

File details

Details for the file LexiLang-1.0.2.tar.gz.

File metadata

  • Download URL: LexiLang-1.0.2.tar.gz
  • Upload date:
  • Size: 1.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.10.0 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/1.0.0 urllib3/1.26.18 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.15

File hashes

Hashes for LexiLang-1.0.2.tar.gz
Algorithm Hash digest
SHA256 d20ac902408242162c9bbde9d476a66b3bcc51afc83f5bf371bf829325fc87df
MD5 612dc02431212dadbb61d78a5a19f94c
BLAKE2b-256 4a1cadb51149c62916e28a9fe4e2f026c880f1e84870657bb064e7c1fcb10b3b

See more details on using hashes here.

File details

Details for the file LexiLang-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: LexiLang-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.10.0 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/1.0.0 urllib3/1.26.18 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.15

File hashes

Hashes for LexiLang-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0a36022eb4d5f853bdd0b60d07d3a5dceb55a7ae3a45f2adf7b036f2005889fc
MD5 331a3993cf97b8e378b9a52b29aa4e32
BLAKE2b-256 4562ccb9eda325a64847390ca95263df412dc8e0a9a26534f88f255b68285f9b

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