Skip to main content

No project description provided

Project description

繁體中文 简体中文󠄁 English

Inherited Glyphs Converter 傳承字形轉換器

Convert CJK ideographs to their inherited glyphs form (mostly follows List of Recommended Inherited Glyph Components), eliminating the xin zixing, Hong Kong and Taiwan region standard glyphs, and character variants that is unifiable but encoded seperately on Unicode.

The converter keeps shinjitai and simplified Chinese characters as much as possible.

Usage

Command line

python . <text file name>

Command line arguments:

Options Usage Default value
-o Specifies an output file. root_converted.ext
-c A string that contains j, k or t, or _.
j: Use Japanese compatibility ideographs.
k: Use Korean compatibility ideographs.
t: Use CNS 11643 compatibility ideographs.
_: Not to use compatibility ideographs.
jkt
-s Supplementary planes characters usage settings, parameter follows:
c: Only use characters that are in Adobe-Japan1, HKSCS or UnihanCore2020 characters on supplementary planes
*: Use all characters on supplementary planes.
_: Only use characters from the Basic Multilingual Plane.
c
-n Not to convert to inherited variants that are not unifiable on Unicode. (e.g. 秘 → 祕, 床 → 牀)
-v Use inherited variants that are commonly seen but not etymological. (e.g. 免 → 免)
-a Use inherited variants that are more etymological. (e.g. 皆 → 𣅜)
-i Uses IVSes in the conversion. Parameters:
ad: Use the Adobe-Japan1 IVS.
mo: Moji-Joho IVS.
ms: Macao Supplementary Character Set IVS.
-t Uses IVSes with tiāo nà stroke (乀).
-p Center align the punctation.
-u Specifies text encoding for decoding. UTF-8

Import module

The inheritedglyphs module provides a single function convert() which converts a string to their inherited glyphs form.

Function arguments:

Arguments Usage Default value
compatibility An iterable that contains 'j', 'k', and/or 't'.
'j': Use Japanese compatibility ideographs.
'k': Use Korean compatibility ideographs.
't': Use CNS 11643 compatibility ideographs.
'jkt'
supp_planes Use of supplementary planes characters settings, value follows:
'c': for supplementary planes, only use characters in Adobe-Japan1, HKSCS or UnihanCore2020.
'*': in supplementary planes, use all characters.
False: Only use characters from the Basic Multilingual Plane.
'c'
convert_not_unifiable Convert to inherited variants that are not unifiable on Unicode (e.g. 秘 → 祕, 床 → 牀) True
alternate Use inherited variants that are commonly seen but not etymological. (e.g. 免 → 免) False
etymological Use inherited variants that are more etymological. (e.g. 皆 → 𣅜) False
ivs Uses IVSes in the conversion. The argument value is an (ordered) iterable that contains one or more of the following, or False:
'ad': Adobe-Japan1 IVS.
'mo': Moji-Joho IVS.
'ms': Macao Supplementary Character Set IVS.
False
tiao_na Uses IVSes with tiāo (㇀) nà (㇏) stroke (乀) in the conversion.
-p Center align the punctation. False

Example

>>> from inheritedglyphs import *
>>> string = '寒來暑往,秋收冬藏。閏餘成歳,律吕調陽。雲騰致雨,露結為霜。金生麗水,玉出崑崗。'
>>> print(convert(string))
寒來暑往,秋收冬藏。閏餘成歲,律呂調陽。雲騰致雨,露結爲霜。金生麗水,玉出崑崗。
>>> print(convert(string, compatibility='j')) # # don't use Korean and CNS compatibility ideographs
寒來暑往,秋收冬藏。閏餘成歲,律呂調陽。雲騰致雨,露結爲霜。金生麗水,玉出崑崗。
>>> print(convert(string, compatibility=False, ivs=['ad'])) # Only uses Adobe-Japan1 IVS
寒󠄁來暑󠄁往󠄁,秋收冬󠄀藏。閏餘成󠄁歲,律呂調󠄁陽。雲騰󠄁致雨,露結爲霜。金生麗󠄁水,玉出崑崗。

Download & installation

The module requires Python 3.7 or up.

To install latest release with pip, simply run

pip install inheritedglyphs

or from the source tree

pip install .

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

inheritedglyphs-2.0.tar.gz (38.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

inheritedglyphs-2.0-py3-none-any.whl (35.6 kB view details)

Uploaded Python 3

File details

Details for the file inheritedglyphs-2.0.tar.gz.

File metadata

  • Download URL: inheritedglyphs-2.0.tar.gz
  • Upload date:
  • Size: 38.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for inheritedglyphs-2.0.tar.gz
Algorithm Hash digest
SHA256 c14c879fa914ec183bbe51ab54178032767d311cd6cbe6b3a88173c4df6b9b9c
MD5 bcb03e7a404a95a5f62344eb5142ca2f
BLAKE2b-256 635f9a3dac8127ea6acee53a4edd968e4b95a7fa75a34cd0b86afc5cdbd848d1

See more details on using hashes here.

File details

Details for the file inheritedglyphs-2.0-py3-none-any.whl.

File metadata

  • Download URL: inheritedglyphs-2.0-py3-none-any.whl
  • Upload date:
  • Size: 35.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for inheritedglyphs-2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8e10bac4d266b9af912776105f72c1f131ba7049f4e4e969a283f05daf4e93ad
MD5 7bcb50942b0b3a59beeed35aa7529fa4
BLAKE2b-256 025ceb6ed2490f0e9e48c420aedf50217ad0c09eb4dcbebaf889a11d90e5c35d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page