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.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb9e6d29f079f387d5f4ee7cfa848890a7039bc5d3fc7373f4bb35ac9956e85e |
|
MD5 | 76e7cd9e3e389f4e1d3441dae4b15a00 |
|
BLAKE2b-256 | 97dfdf582992571671938c98f515ffdebb254f0145874e359422b5776fed89df |
Hashes for cccconverter_ostrichb-0.90.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fbb95d228e22d47e4417811fa84762294ac9f2ff788f5cc447ec607cafc1bc1b |
|
MD5 | 14bbdacf402113c33ddbd5843e230f2e |
|
BLAKE2b-256 | 7fc1a2842c447c73d93b655acb754dae4c007c4d0a41c6dfd3f7ae070d17ff4d |