Skip to main content

簡化字轉漢字

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

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。

Metadata

Release files for pyhan 0.0.22

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

Source distribution (sdist)

Source distribution for pyhan 0.0.22
File Size Uploaded
pyhan-0.0.22.tar.gz 21.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyhan 0.0.22
File Interpreter ABI Platform
pyhan-0.0.22-py3-none-any.whl Python 3 none any Details

Total release size: 43.0 kB

Release files / pyhan-0.0.22.tar.gz

Download URL pyhan-0.0.22.tar.gz
Size 21.8 kB
Tags Source
SHA-256 checksum
How to use checksums
bf9cb8c6a97b1b2bb9a6b0585c63304449afadc9f0a830498c015c355d373b72
BLAKE2b-256 checksum
How to use checksums
efc632c53dd57daa8bde7726602242c814dd108add938eb254e32d038017b880
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 13, 2025.

Transparency log

Release files / pyhan-0.0.22-py3-none-any.whl

Download URL pyhan-0.0.22-py3-none-any.whl
Size 21.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d85030578868b7d8af36f37711705003f36a705c223c7384691438cc4e7519c8
BLAKE2b-256 checksum
How to use checksums
b14c2b9c311ff0db72f0bef1308a9af3cbb0faeebdf21d191fa1ad704a2db6de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 13, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.0.22 This release

2 release files

0.0.21

2 release files

0.0.20

2 release files

0.0.19

2 release files

0.0.18

2 release files

0.0.16

2 release files

0.0.15

2 release files

0.0.14

2 release files

0.0.13

2 release files

0.0.11

2 release files

0.0.10

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.1

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