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
  • Basque
  • Bengali
  • Bulgarian
  • Catalan
  • Chinese
  • Czech
  • Danish
  • Dutch
  • English
  • Esperanto
  • Estonian
  • Finnish
  • French
  • German
  • Greek
  • Hebrew
  • Hindi
  • Hungarian
  • Indonesian
  • Italian
  • Japanese
  • Kabyle
  • Kazakh
  • Korean
  • Latvian
  • Lithuanian
  • Macedonian
  • Norwegian
  • Occitan
  • 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.7.tar.gz (1.6 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lexilang-1.0.7-py3-none-any.whl (1.6 MB view details)

Uploaded Python 3

File details

Details for the file lexilang-1.0.7.tar.gz.

File metadata

  • Download URL: lexilang-1.0.7.tar.gz
  • Upload date:
  • Size: 1.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for lexilang-1.0.7.tar.gz
Algorithm Hash digest
SHA256 195fcc02b28366e6e71484ffba77f7dc1dcc962ecf9633322f79305b9f6605f7
MD5 e8262f53cccc840af37ed92eba264470
BLAKE2b-256 8598695b7a5c3c7e77880d0dd7684920d1cf059874b2a3873a7eb7496ab9cb45

See more details on using hashes here.

Provenance

The following attestation bundles were made for lexilang-1.0.7.tar.gz:

Publisher: publish.yml on LibreTranslate/LexiLang

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lexilang-1.0.7-py3-none-any.whl.

File metadata

  • Download URL: lexilang-1.0.7-py3-none-any.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for lexilang-1.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 6d406accbebd12906d884c7dfa787765e1fb86acc2fa4dc6dc688081d21f8fdd
MD5 7819376982e0b1edb522a63ca3762d2a
BLAKE2b-256 2c4301adb7b19a99421f7404545ed0fdc96a9603cabded06a57f539b07127cd6

See more details on using hashes here.

Provenance

The following attestation bundles were made for lexilang-1.0.7-py3-none-any.whl:

Publisher: publish.yml on LibreTranslate/LexiLang

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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