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 |
Do not 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 decorative 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 |
Supplementary planes characters usage 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 decorative tiāo nà stroke in the conversion. | |
punctation_align_center |
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=IVS_AD)) # Only uses Adobe-Japan1 IVS
寒󠄁來暑󠄁往󠄁,秋收冬󠄀藏。閏餘成󠄁歲,律呂調󠄁陽。雲騰󠄁致雨,露結爲霜。金生麗󠄁水,玉出崑崗。
Download & Installation
The module requires Python 3.7 or up.
The module is available on PyPI (https://pypi.org/project/inheritedglyphs). To install the latest release with pip, simply run
pip install inheritedglyphs
or from the source tree
pip install .
Metadata
Release files for inheritedglyphs 2.0.post1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| inheritedglyphs-2.0.post1.tar.gz | 38.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| inheritedglyphs-2.0.post1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 74.7 kB
Release files / inheritedglyphs-2.0.post1.tar.gz
| Download URL | inheritedglyphs-2.0.post1.tar.gz |
|---|---|
| Size | 38.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
095da08dbc997dc28f635702f5a7bfad63be0770df3219398fe1a43cfa2df06c
|
|
BLAKE2b-256 checksum How to use checksums |
7c77536be3dcbc0dd9449bb47318ffa444030c5b9fb3964ac99665dcf17d3471
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Release files / inheritedglyphs-2.0.post1-py3-none-any.whl
| Download URL | inheritedglyphs-2.0.post1-py3-none-any.whl |
|---|---|
| Size | 35.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5c1d22f7d6707389705cff056ecdeb21f7fbc0597a0b5f765b4ffc1fdbbe8fe5
|
|
BLAKE2b-256 checksum How to use checksums |
337fa5b9efbd0fe030564e0bfbff950cf27eadb0d2b2718ab876681dbf94dd02
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|