No project description provided
Project description
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 .
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file inheritedglyphs-2.0.post1.tar.gz.
File metadata
- Download URL: inheritedglyphs-2.0.post1.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
095da08dbc997dc28f635702f5a7bfad63be0770df3219398fe1a43cfa2df06c
|
|
| MD5 |
836888762df739cb96e065cd2e032692
|
|
| BLAKE2b-256 |
7c77536be3dcbc0dd9449bb47318ffa444030c5b9fb3964ac99665dcf17d3471
|
File details
Details for the file inheritedglyphs-2.0.post1-py3-none-any.whl.
File metadata
- Download URL: inheritedglyphs-2.0.post1-py3-none-any.whl
- Upload date:
- Size: 35.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c1d22f7d6707389705cff056ecdeb21f7fbc0597a0b5f765b4ffc1fdbbe8fe5
|
|
| MD5 |
979b80f9cec67f773df1303b309443eb
|
|
| BLAKE2b-256 |
337fa5b9efbd0fe030564e0bfbff950cf27eadb0d2b2718ab876681dbf94dd02
|