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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file LexiLang-1.0.1.tar.gz
.
File metadata
- Download URL: LexiLang-1.0.1.tar.gz
- Upload date:
- Size: 1.5 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 400289651736f46b2c88b5f6abda11af94987da4c30eb964ec410b88cc568925 |
|
MD5 | 64eec2c19cb1a0af2b87029ab3bd16f4 |
|
BLAKE2b-256 | c05243a9a70b4bafaa33cff9b17d7b6146f14ba8f87e3d304c50593de5c902c4 |
File details
Details for the file LexiLang-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: LexiLang-1.0.1-py3-none-any.whl
- Upload date:
- Size: 1.6 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 89e68ec6d392e299443f6ebe18928b1e0b5464ad491eb35227579f464cdf3fbb |
|
MD5 | f8fd197995c22910ffe0f776f289ae91 |
|
BLAKE2b-256 | 59f10d2096a3d76245345766d83a3d09a4f5c10f9f4917e1ad099fde6aeefd3b |