Hanzi Identifier is a simple Python module that identifies a string of text as having Simplified or Traditional characters.
Free software: MIT license
About
Easy-to-use helper functions for identifying strings:
>>> import hanzidentifier
>>> hanzidentifier.has_chinese('Hello my name is John.')
False
>>> hanzidentifier.is_simplified('John说:你好!')
True
>>> hanzidentifier.is_traditional('John說:你好!')
True
>>> hanzidentifier.has_chinese('Country in Simplified: 国家. Country in Traditional: 國家.')
True
Here it is without the helper functions:
>>> hanzidentifier.identify('Hello my name is Thomas.') is hanzidentifier.UNKNOWN
True
>>> hanzidentifier.identify('Thomas 说:你好!') is hanzidentifier.SIMPLIFIED
True
>>> hanzidentifier.identify('Thomas 說:你好!') is hanzidentifier.TRADITIONAL
True
>>> hanzidentifier.identify('你好!') is hanzidentifier.BOTH
True
>>> hanzidentifier.identify('Country in Simplified: 国家. Country in Traditional: 國家.' ) is hanzidentifier.MIXED
True
hanzidentifier.identify has five possible return values:
hanzidentifier.UNKNOWN: there are no recognized Chinese characters in the string.
hanzidentifier.BOTH: the string is compatible with both Simplified and Traditional character systems.
hanzidentifier.TRADITIONAL: the string consists of Traditional characters.
hanzidentifier.SIMPLIFIED: the string consists of Simplified characters.
hanzidentifier.MIXED: the string consists of characters recognized solely as Traditional characters and also consists of characters recognized solely as Simplified characters.
Characters that aren’t found in CC-CEDICT are ignored when determining a string’s identity. Hanzi Identifier uses the CC-CEDICT data provided by Zhon to identify Chinese characters.
Because the Traditional and Simplified Chinese character systems overlap, a string containing Simplified characters could identify as hanzidentifier.SIMPLIFIED or hanzidentifier.BOTH depending on if the characters are also Traditional characters.
Getting Started
Install Hanzi Identifier: $ pip install hanzidentifier
Report bugs and ask questions via GitHub Issues
Release files for hanzidentifier 1.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| hanzidentifier-1.3.0.tar.gz | 3.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| hanzidentifier-1.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.7 kB
Release files / hanzidentifier-1.3.0.tar.gz
| Download URL | hanzidentifier-1.3.0.tar.gz |
|---|---|
| Size | 3.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7acd99ef00c69ab57f3441e2b3568348b58ef115500e5a01f66cedea603b3101
|
|
BLAKE2b-256 checksum How to use checksums |
cb32c1f5f7cf4d4372c7778e34f116c52539db717b73e1ec0b149ce3717b1c9c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-httpx/0.27.2
|
Release files / hanzidentifier-1.3.0-py3-none-any.whl
| Download URL | hanzidentifier-1.3.0-py3-none-any.whl |
|---|---|
| Size | 4.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8e36204a96072c328c8bc6ae9342fc6f9faea10bc519ff51da3ef6e6e0cee5a6
|
|
BLAKE2b-256 checksum How to use checksums |
14f694c3975b5e06ea4084056413da975395924ff0ddd89e975427bd46684359
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-httpx/0.27.2
|