A Hong Kong Government Cantonese Romanisation converter
Project description
CCCConverter
基於 RIME-Cantonese 及 CCC 粵拼轉換表的香港政府粵語拼音轉換器。
支援範圍
本程式的粵拼對照表來自 RIME-Cantonese 中收錄的單字,包括正體中文及常用的粵字共計 27087 字。簡化字可能需要先轉換成正體中文方可正常轉換,為了確保用字的準確,本程式將不會支援簡化字的粵拼轉換。
使用
轉換單句:使用cccconverter.convert
中的convert_sentence
方法可以將一句話的中文字轉換為對應的港府粵語拼法,如下:
>>> convert_sentence("慈雲圩")
'tsz/tszi/tszu/tsi/tsee/chz/chzi/chzu/chi/chee wan/wun/wen hui||yu/yue||wai/wei'
因為 CCC 拼法中,同一個字,甚至是同一個音都有眾多的拼法,預設的情況下,轉換的結果會保留所有的拼法,其中,同一個音的不同的拼法會使用斜槓(/)相隔,不同音會用(||)相隔。
若僅需要寫出一個拼法,可以加上only_keep_first_spell=True
引數:
>>> convert_sentence("慈雲圩", only_keep_first_spell=True)
'tsz wan hui||yu||wai'
在上述基礎下,若僅需要一個讀音,可以再加上only_keep_first_pronunciation=True
引數:
>>> convert_sentence("慈雲圩", only_keep_first_spell=True, only_keep_first_pronunciation=True)
'tsz wan hui'
(兩個引數之間不衝突,可據實際情況組合使用)
若需要使生成結果作為列表顯示,可以使用convert_sentence_map
函數,引數同上:
>>> convert_sentence_map("慈雲圩")
[('慈', 'tsz/tszi/tszu/tsi/tsee/chz/chzi/chzu/chi/chee'), ('雲', 'wan/wun/wen'), ('圩', 'hui||yu/yue||wai/wei')]
If you have questions or better ideas about this package, please feel free to open an issue or request a PR!
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
Hashes for cccconverter_ostrichb-0.90.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | c0875db876c3a1fe79fd8c0b5bb8e679b7196f3ca9d4d895b3fffb527bd2dde7 |
|
MD5 | 400f952d6ea18185bdd3a0809a5da996 |
|
BLAKE2b-256 | 73cb675cfc55c701ae4391ce316739742b5085086c04dd090bb10aeb709605b4 |
Hashes for cccconverter_ostrichb-0.90.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 947f52393ca0586fd3e5f09c52373661f245da7d3b7a7fff01af543ecf3d8029 |
|
MD5 | 332726dcaac22f78fd9dca61907e1d93 |
|
BLAKE2b-256 | 0f82ede034c1bccbd137fb5572f3285434f377983840cd7a226987e6f73bdbe9 |