Skip to main content

A Hong Kong Government Cantonese Romanisation converter

Project description

CCCConverter

基於 RIME-CantoneseCCC 粵拼轉換表的香港政府粵語拼音轉換器。

支援範圍

本程式的粵拼對照表來自 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


Download files

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

Source Distribution

cccconverter_ostrichb-0.90.3.tar.gz (118.2 kB view hashes)

Uploaded Source

Built Distribution

cccconverter_ostrichb-0.90.3-py3-none-any.whl (114.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page