# LexiLang
Simple, fast dictionary-based language detector for short texts.
## Installation
```bash
pip install lexilang
```
## Usage
```python
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
Raw data
{
"_id": null,
"home_page": "https://github.com/LibreTranslate/LexiLang",
"name": "LexiLang",
"maintainer": "Piero Toffanin",
"docs_url": null,
"requires_python": null,
"maintainer_email": "pt@masseranolabs.com",
"keywords": null,
"author": "Piero Toffanin",
"author_email": "pt@masseranolabs.com",
"download_url": "https://files.pythonhosted.org/packages/3d/3e/bc4ec958f6b9f1903ad168d8bd759077df337eebb865afea7cb0c9fd8722/lexilang-1.0.4.tar.gz",
"platform": null,
"description": "# LexiLang\n\nSimple, fast dictionary-based language detector for short texts.\n\n## Installation\n\n```bash\npip install lexilang\n```\n\n## Usage\n\n```python\nfrom lexilang.detector import detect\n\nprint(detect(\"bonjour\")) # ('fr', 0.45)\nprint(detect(\"\u5b66\u4e2d\u6587\")) # ('zh', 0.45)\nprint(detect(\"ciao mondo\")) # ('it', 0.9)\nprint(detect(\"El gato dom\u00e9stico\")) # ('es', 0.45)\n\n# Optionally, specify a subset of languages to consider\nprint(detect(\"ciao\", languages=[\"de\", \"ro\"])) # ('de', 0.45)\n```\n\n`detect(text, languages=[])` -> tuple (`iso_639_1`, `confidence`)\n\n## Supported Languages\n\n * Afrikaans\n * Albanian\n * Arabic\n * Basque\n * Bengali\n * Bulgarian\n * Catalan\n * Chinese\n * Czech\n * Danish\n * Dutch\n * English\n * Esperanto\n * Estonian\n * Finnish\n * French\n * German\n * Greek\n * Hebrew\n * Hindi\n * Hungarian\n * Indonesian\n * Italian\n * Japanese\n * Kabyle\n * Kazakh\n * Korean\n * Latvian\n * Lithuanian\n * Macedonian\n * Norwegian\n * Occitan\n * Polish\n * Portuguese\n * Romanian\n * Russian\n * Serbian\n * Slovak\n * Slovenian\n * Spanish\n * Swedish\n * Thai\n * Turkish\n * Ukrainian\n * Vietnamese\n * Farsi\n\n## Limitations\n\nThis 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.\n\n## Contributing\n\nIf you want to add a new language, or improve an existing one, add more words to the respective dictionary in the `dictionaries` folder.\n\n## License\n\nAGPLv3\n",
"bugtrack_url": null,
"license": "AGPLv3",
"summary": "Simple, fast dictionary-based language detector",
"version": "1.0.4",
"project_urls": {
"Homepage": "https://github.com/LibreTranslate/LexiLang"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "96326ce9656a9a03986f1969fef5eddbfc310ab926fd6f8565224d071d77f41e",
"md5": "1fd43b545a77cd5a393903d1333f2ee8",
"sha256": "a751cd3ba5c578207c337586b41eb06f0d5df848b1045b1a9f9b911ba5c3ff48"
},
"downloads": -1,
"filename": "LexiLang-1.0.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "1fd43b545a77cd5a393903d1333f2ee8",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 1672758,
"upload_time": "2025-01-18T04:10:48",
"upload_time_iso_8601": "2025-01-18T04:10:48.694604Z",
"url": "https://files.pythonhosted.org/packages/96/32/6ce9656a9a03986f1969fef5eddbfc310ab926fd6f8565224d071d77f41e/LexiLang-1.0.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "3d3ebc4ec958f6b9f1903ad168d8bd759077df337eebb865afea7cb0c9fd8722",
"md5": "a7bb65042e4e81e9bf693e08c590dc4a",
"sha256": "8f0a262bf2ce1a76bf69285dbc4c85cdea87568ff560f6f432383e451ffe0acb"
},
"downloads": -1,
"filename": "lexilang-1.0.4.tar.gz",
"has_sig": false,
"md5_digest": "a7bb65042e4e81e9bf693e08c590dc4a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 1627385,
"upload_time": "2025-01-18T04:10:52",
"upload_time_iso_8601": "2025-01-18T04:10:52.019877Z",
"url": "https://files.pythonhosted.org/packages/3d/3e/bc4ec958f6b9f1903ad168d8bd759077df337eebb865afea7cb0c9fd8722/lexilang-1.0.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-18 04:10:52",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "LibreTranslate",
"github_project": "LexiLang",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "lexilang"
}