Skip to main content

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)

Source distribution for langdetect-zh 1.0.4
File Size Uploaded
langdetect_zh-1.0.4.tar.gz 59.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for langdetect-zh 1.0.4
File Interpreter ABI Platform
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

Release history Release notifications | RSS feed

This release

1.0.4 This release

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page