Skip to main content
https://badge.fury.io/py/hanzidentifier.png https://travis-ci.org/tsroten/hanzidentifier.png?branch=develop

Hanzi Identifier is a simple Python module that identifies a string of text as having Simplified or Traditional characters.

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 hanzidentifer.SIMPLIFIED or hanzidentifier.BOTH depending on if the characters are also Traditional characters.

Hanzi Identifier’s functions accept and return unicode.

Getting Started

Change Log

v1.0.2 (2015-08-06)

  • New README format

  • Adds Travis CI support

  • Uses io.open() in setup.py. Fixes #1.

v1.0.1 (2014-04-14)

  • Fixes URL typo.

v1.0 (2014-04-12)

Version 1.0 merges some changes from Dragon Mapper. It is not backwards compatible with the previous versions of Hanzi Identifier (e.g. some of the constants are named differently).

v0.1 (2013-04-24)

  • Initial release.

Release files for hanzidentifier-preview 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hanzidentifier-preview 1.1.0
File Size Uploaded
hanzidentifier_preview-1.1.0.tar.gz 4.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for hanzidentifier-preview 1.1.0
File Interpreter ABI Platform
hanzidentifier_preview-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 9.3 kB

Release files / hanzidentifier_preview-1.1.0.tar.gz

Download URL hanzidentifier_preview-1.1.0.tar.gz
Size 4.6 kB
Tags Source
SHA-256 checksum
How to use checksums
09bfbfee33db42b84c87ad4036d46fa80811db5b06be4c01284342d0d1e7fd89
BLAKE2b-256 checksum
How to use checksums
a111353cc891ed3c2b48dea504eefc5a4d723ea54cc4c704beada857fffd08c5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.10

Release files / hanzidentifier_preview-1.1.0-py3-none-any.whl

Download URL hanzidentifier_preview-1.1.0-py3-none-any.whl
Size 4.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e932410373feba4f38bce0dc740a24cbf5773179297d206e8eb4bfbd6df9b653
BLAKE2b-256 checksum
How to use checksums
056c4e6905f2aaa7a397b961bc51442f8ee2b2b0933e12c71a356dbfd60dd615
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.10

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

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