Skip to main content

A simple implementation of Simplified-Traditional Chinese conversion.

Project description

zhconv 提供基于 MediaWiki 词汇表的最大正向匹配简繁转换。Python 2, 3 通用。支持以下地区词转换:

  • zh-cn 大陆简体

  • zh-tw 台灣正體

  • zh-hk 香港繁體

  • zh-sg 马新简体

  • zh-hans 简体

  • zh-hant 繁體

示例

>>> print(convert(u'我幹什麼不干你事。', 'zh-cn'))
我干什么不干你事。
>>> print(convert(u'人体内存在很多微生物', 'zh-tw'))
人體內存在很多微生物

完整支持 MediaWiki 人工转换语法:

>>> print(convert_for_mw(u'在现代,机械计算-{}-机的应用已经完全被电子计算-{}-机所取代', 'zh-hk'))
在現代,機械計算機的應用已經完全被電子計算機所取代
>>> print(convert_for_mw(u'-{zh-hant:資訊工程;zh-hans:计算机工程学;}-是电子工程的一个分支,主要研究计算机软硬件和二者间的彼此联系。', 'zh-tw'))
資訊工程是電子工程的一個分支,主要研究計算機軟硬體和二者間的彼此聯繫。
>>> print(convert_for_mw(u'張國榮曾在英國-{zh:利兹;zh-hans:利兹;zh-hk:列斯;zh-tw:里茲}-大学學習。', 'zh-sg'))
张国荣曾在英国利兹大学学习。
>>> print(convert_for_mw('毫米(毫公分),符號mm,是長度單位和降雨量單位,-{zh-hans:台湾作-{公釐}-或-{公厘}-;zh-hant:港澳和大陸稱為-{毫米}-(台灣亦有使用,但較常使用名稱為毫公分);zh-mo:台灣作-{公釐}-或-{公厘}-;zh-hk:台灣作-{公釐}-或-{公厘}-;}-。', 'zh-cn'))
毫米(毫公分),符号mm,是长度单位和降雨量单位,台湾作公釐或公厘。

和其他 高级字词转换语法

命令行工具

python -mzhconv [-w] {zh-cn|zh-tw|zh-hk|zh-sg|zh-hans|zh-hant|zh} < input > output

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

zhconv-1.3.2-py2.py3-none-any.whl (166.5 kB view details)

Uploaded Python 2Python 3

File details

Details for the file zhconv-1.3.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for zhconv-1.3.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 92566ad50975be13bab88dfb224e79dfea71d9e3ca39bf3a19a895725b77cbbe
MD5 320341716adf59ca084817e72957bfbd
BLAKE2b-256 21115a10a4f7c14bdc3f52f3919df4fb440f34c8ffabee92caf5f47897bf4f45

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