language-detector
language-detector detects the language of text
Installation
pip install language-detector
Python Version
Works with both Python 2 and 3
Use
from language_detector import detect_language
text = "I arrived in that city on January 4, 1937"
language = detect_language(text)
# prints English
Features
| Languages Supported |
|---|
| Arabic |
| English |
| Farsi |
| French |
| German |
| Kurmanci (Kurdish) |
| Mandarin |
| Russian |
| Sorani (Kurdish) |
| Spanish |
| Turkish |
Testing
To test the package run
python -m unittest language_detector.tests.test
Comparison
Test is a comparison of how well language-detector and langid identify languages in the data sources.
| package | language-detector | langid |
|---|---|---|
| test-duration (in seconds) | 0.10 | 3.83 |
| accuracy | 96.77% | 67.74% |
Excluding Languages
If you don't want language-detector to look for certain languages, you can monkey-patch the code. For example, in order to exclude English:
import language_detector
language_detector.char_language = [cl for cl in char_language if cl[1] != "English"]
# proceed as normal
Datasets
The following is a list of datasets used for each language:
| Language | Datasets |
|---|---|
| Arabic | UN Corpora |
| English | UN Corpora |
| Farsi | BBC News Persian |
| French | UN Corpora |
| German | Deutsche Welle |
| Kurmanci (Kurdish) | Rudaw |
| Mandarin | UN Corpora |
| Russian | UN Corpora |
| Sorani (Kurdish) | Rudaw |
| Spanish | UN Corpora |
| Turkish | BBC News Türkçe |
Contributing
If you'd like to contribute a new language, please consult CONTRIBUTING.md
Support
Contact the package author, Daniel J. Dufour, at daniel.j.dufour@gmail.com
Metadata
Release files for language-detector 5.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| language-detector-5.0.2.tar.gz | 6.6 kB | Without provenance | Details for language-detector-5.0.2.tar.gz |
Release files / language-detector-5.0.2.tar.gz
| Download URL | language-detector-5.0.2.tar.gz |
|---|---|
| Size | 6.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7ab647575d0f662db1e998ca5a306486e04de2250ec8c942709acec520f7d8d3
|
|
BLAKE2b-256 checksum How to use checksums |
5c0afefb61145a386968d2070323b608be6a1eb7508e610c2319daad746c2c33
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.15.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/44.1.0 requests-toolbelt/0.9.1 tqdm/4.44.0 CPython/2.7.17
|
Security for language-detector 5.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.