注音和拼音的轉換工具
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 import pinyin_to_zhuyin, zhuyin_to_pinyin
assert(pinyin_to_zhuyin("lu3") == "ㄌㄨˇ")
assert(pinyin_to_zhuyin("dan4") == "ㄉㄢˋ")
assert(map(pinyin_to_zhuyin, ["lu3", "dan4"]) == ["ㄌㄨˇ", "ㄉㄢˋ"])
assert(zhuyin_to_pinyin("ㄌㄩˊ") == "lü2")
assert(zhuyin_to_pinyin("˙ㄗ") == "zi5")
assert(map(lambda z: zhuyin_to_pinyin(z, 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 資料來源
-
中華民國教育部(Ministry of Education, R.O.C.)。《重編國語辭典修訂本》(版本編號:2015_20210928 )
Author 作者
- Raymond Ku
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 pyzhuyin-0.0.2.tar.gz.
File metadata
- Download URL: pyzhuyin-0.0.2.tar.gz
- Upload date:
- Size: 6.5 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3f53ae16e54f4543129dfb916a95d337708ff3061ed14a6606c7edfc14afa625
|
|
| MD5 |
5f25fbe911ebd72c9cbca82f679a234c
|
|
| BLAKE2b-256 |
af91c52eb914b78b2c7ebe321cfd9a3ff8c86f3910e81ddab2f3acb525dc830d
|
File details
Details for the file pyzhuyin-0.0.2-py3-none-any.whl.
File metadata
- Download URL: pyzhuyin-0.0.2-py3-none-any.whl
- Upload date:
- Size: 6.2 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2359933897da68a26be1b2e7d995eaf6a61c697813cb3a9aba420ac8e8b3e887
|
|
| MD5 |
149ba9add0df5fa0003ba4ada1f5ce3e
|
|
| BLAKE2b-256 |
a3fef485300106e7ec0aef8f3acd6bf2f83790fa905e5bb5b6405ec68b8d5eac
|