Skip to main content

簡化字轉漢字

Project description

簡化字轉漢字

  • 支持《通用規範漢字表》中的全部簡化字
  • 對於一對多的簡化字,人工標註規則
  • 支持運行時增加自定義規則
  • 簡單快速

pypi

pages

附:《通用規範漢字表》

安裝

pip install pyhan

示例

from pyhan import to_traditional,add_rule

if __name__ == '__main__':
    # 簡化字轉漢字
    res = to_traditional('萝卜去哪了,可以在茶几卜上几卦')
    # output: 蘿蔔去哪了,可以在茶几卜上幾卦
    print(res)
    
    # 運行時增加自定義規則
    add_rule('卜,蔔,-1|0|胡')
    res = to_traditional('胡卜')
    # output: 胡蔔
    print(res)

完善

如果你需要增加规则,可以编辑 st02.csv 文件, 例如:

卜,蔔,-1|0|萝
卜,卜

會匹配第三列及以後,這裡是-1|0|萝-1代表索引開始,0代表索引結束,代表匹配的目標詞,如果匹配成功,返回第二列

如果沒有第三列,返回第二列

測試

make test

貢獻

你可以按照以下步驟貢獻代碼:

  1. Fork 本倉庫。
  2. 提交 pull request。

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

pyhan-0.0.21.tar.gz (21.7 kB view details)

Uploaded Source

Built Distribution

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

pyhan-0.0.21-py3-none-any.whl (21.0 kB view details)

Uploaded Python 3

File details

Details for the file pyhan-0.0.21.tar.gz.

File metadata

  • Download URL: pyhan-0.0.21.tar.gz
  • Upload date:
  • Size: 21.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pyhan-0.0.21.tar.gz
Algorithm Hash digest
SHA256 545021c53ef986c94551c4adc44edd03184a074837e83568e9cc50ed0bbc8ae9
MD5 ebe3e1d0f3d452d641dffe2e5ab7e81a
BLAKE2b-256 6617f1584ca161971eb20d4f8ed3dccd4781e7aa8b43a828828f1ef1d33595ca

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyhan-0.0.21.tar.gz:

Publisher: release.yml on lizongying/pyhan

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyhan-0.0.21-py3-none-any.whl.

File metadata

  • Download URL: pyhan-0.0.21-py3-none-any.whl
  • Upload date:
  • Size: 21.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pyhan-0.0.21-py3-none-any.whl
Algorithm Hash digest
SHA256 56c7a2e7d3e70fdac22b3532d5b77b810f53acc591ce8eb71c15b6345bba5330
MD5 5bb2ccc87cc40c120c0577942053095f
BLAKE2b-256 50fa3a9e2db45f385fd9e71161c2149c9f6efc6a3ac0a2c00fc6c0c9400def9c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyhan-0.0.21-py3-none-any.whl:

Publisher: release.yml on lizongying/pyhan

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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