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.0.tar.gz (16.0 kB view details)

Uploaded Source

Built Distribution

LexiLang-1.0.0-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: LexiLang-1.0.0.tar.gz
  • Upload date:
  • Size: 16.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for LexiLang-1.0.0.tar.gz
Algorithm Hash digest
SHA256 58a6901f0cb2f08cb67a68bd3fb071d5ed0514ca3e8bcddd75c1fa3818b7deb4
MD5 08843f1fb8b28ec9d263501ab8ce8c14
BLAKE2b-256 8d9bfb2ed455eda9a30e3527a5c08f334ae2873c97bbfc74b05481c591d7fbd3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: LexiLang-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 16.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for LexiLang-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5bd697e7b739bf0cfdf64e8f88889353f7bcc1efcb0db89969de9d71082ba146
MD5 7201884ccab6ee2193a291e88b6fcd73
BLAKE2b-256 54640e3fdc708dbb5e36c03ca3938f6e6753f43c6b2d5f5fdef58190110edcb0

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