Skip to main content

注音和拼音的轉換工具

Project description

Python-Zhuyin (pyzhuyin) 注音和拼音轉換

Introduction 介紹

pyzhuyin is an open source Python library that provides a unified interface for converting between Chinese pinyin and Zhuyin (bopomofo).

pyzhuyin 是一個開放原始碼的 Python 套件,提供了將拼音轉換成注音的統一介面。

Installation 安裝

pip install pyzhuyin

Usage 使用

from pyzhuyin.convert import pinyin_to_zhuyin, zhuyin_to_pinyin


assert(pinyin_to_zhuyin("lu3 dan4") == ["ㄌㄨˇ", "ㄉㄢˋ"])
assert(zhuyin_to_pinyin("ㄌㄨˇ ㄉㄢˋ") == ["lu3", "dan4"])

assert(zhuyin_to_pinyin("ㄌㄩˊ ˙ㄗ") == ["lü2", "zi5"])
assert(zhuyin_to_pinyin("ㄌㄩˊ ˙ㄗ", u_to_v=True) == ["lv2", "zi5"])

Testing 測試

Run the following command at the root of the project to test the library:

在根目錄執行以下指令以測試套件:

python3 -m unittest

Notes 備註

  • Only support numeric tone for pinyin
    • e.g. "lu3" instead of "lǔ"
  • Neutral tone is represented as 5
    • e.g. "˙ㄗ" -> "zi5"
  • For pinyin_to_zhuyin:
    • if corresponding zhuyin not found, raise ValueError
    • internally convert all v to ü
  • For zhuyin_to_pinyin:
    • if corresponding pinyin not found, raise ValueError
  • 兒化音 is not supported because it is not representable in the zhuyin system as a "combo" word
    • e.g. "公園兒" -> "gong1 yuanr2" -> "ㄍㄨㄥ ㄩㄢㄦˊ" (not allowed)

Data Sources 資料來源

Author 作者

  • Raymond Ku

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

pyzhuyin-0.0.1.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

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

pyzhuyin-0.0.1-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file pyzhuyin-0.0.1.tar.gz.

File metadata

  • Download URL: pyzhuyin-0.0.1.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for pyzhuyin-0.0.1.tar.gz
Algorithm Hash digest
SHA256 3c69211acd4be67555e788592e686e57a967c2e3fcad3b79b30860e95522eb60
MD5 a1b91c58fca8a743db56d7fd241a521a
BLAKE2b-256 a9c0046c7d15287353ddda2e4b76570172d68d6ef2a7931e2a35352e03ffdaf2

See more details on using hashes here.

File details

Details for the file pyzhuyin-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: pyzhuyin-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for pyzhuyin-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c9b61af39a23c2b2965adddbb086abec76661800751aef43af35ac6065666212
MD5 d70a06d14d635051276603c51e91dc0a
BLAKE2b-256 a56c9d78d066f982cafa79f240d62b02f9ca01c9d4cc526853dfb030e1f21a53

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