langdetect_zh
Installation
$ pip install langdetect_zh
Supported Python versions 2.7, 3.4+.
Languages
langdetect_zh supports 2 languages out of the box (ISO 639-1 codes):
zh-cn, zh-tw
Basic usage
Directly output the most similar language code:
>>> from langdetect_zh import detect
>>> detect("这是一段中文文本")
'zh-cn'
To find out the probabilities for the top languages:
>>> from langdetect_zh import detect_langs
>>> detect_langs("这是一段中文文本")
[zh-cn:0.999997316441747]
NOTE
Language detection algorithm is non-deterministic, which means that if you try to run it on a text which is either too short or too ambiguous, you might get different results everytime you run it.
To enforce consistent results, call following code before the first language detection:
from langdetect_zh import DetectorFactory
DetectorFactory.seed = 0
Original project
This package is an optimization of langdetect. The specific optimization measure is to subdivide simplified Chinese and traditional Chinese under the condition of pure Chinese.
Metadata
Release files for langdetect-zh 1.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| langdetect_zh-1.0.4.tar.gz | 59.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| langdetect_zh-1.0.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 121.9 kB
Release files / langdetect_zh-1.0.4.tar.gz
| Download URL | langdetect_zh-1.0.4.tar.gz |
|---|---|
| Size | 59.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
35e8a3e52ae40566b2999d1440a7f1730769b4bb6a1c61eb47f8a2344ff15e28
|
|
BLAKE2b-256 checksum How to use checksums |
d9dccf9c7298121a4ffa6b76cfe28081dff7de83f1e19075a99e8e5c63fef08a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.7
|
Release files / langdetect_zh-1.0.4-py3-none-any.whl
| Download URL | langdetect_zh-1.0.4-py3-none-any.whl |
|---|---|
| Size | 62.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
579a5020da6bb071dba117acedffee210841d9290d617f506396f59b48bf6509
|
|
BLAKE2b-256 checksum How to use checksums |
eec1a65aec56af3e148b4b9e2d46da3c258ebfe7c056e09a89895ebdb1c5ec0e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.7
|