pycantonese.jyutping_to_ipa

pycantonese.jyutping_to_ipa(jp: str | list[str], *, onsets: dict[str, str] | None = None, nuclei: dict[str, str] | None = None, codas: dict[str, str] | None = None, tones: dict[str, str] | None = None) list[str][source]

Convert Jyutping romanization into IPA.

The Jyutping-to-IPA mapping is based on Matthews and Yip (2011: 461-463).

Parameters:
  • jp (str or list[str]) – A Jyutping romanization string for a single word (any number of syllables, optionally separated by spaces), or a list of such strings carrying explicit word segmentation (one word per element).

  • onsets (dict[str, str], optional) – If provided, it must be a dictionary that maps Jyutping onsets to the desired IPA symbols for customization. For example, Jyutping “z” maps to IPA /ts/ by default. Passing in {"z": "tʃ"} would map “z” to /tʃ/ instead.

  • nuclei (dict[str, str], optional) – If provided, it must be a dictionary that maps Jyutping nuclei to the desired IPA symbols for customization. For example, Jyutping “i” maps to IPA /i/ by default. Passing in {"i": "iː"} would map “i” to /iː/ instead.

  • codas (dict[str, str], optional) – If provided, it must be a dictionary that maps Jyutping codas to the desired IPA symbols for customization. For example, Jyutping “p” maps to IPA /p̚/ by default. Passing in {"p": "p"} would map “p” to /p/ instead.

  • tones (dict[str, str], optional) – If provided, it must be a dictionary that maps Jyutping tones to the desired IPA symbols for customization. For example, Jyutping “2” (high-rising tone) maps to IPA /25/ by default. Passing in {"2": "35"} would map Jyutping “2” to /35/ instead.

Returns:

A list with one element per input word. Each element is the IPA representation of that word, with syllables separated by a single space.

Return type:

list[str]

Examples

>>> jyutping_to_ipa('gwong2dung1waa2')  # 廣東話 Cantonese
['kʷɔŋ25 tʊŋ55 waː25']
>>> jyutping_to_ipa(['gwong2dung1', 'waa2'])
['kʷɔŋ25 tʊŋ55', 'waː25']
>>> jyutping_to_ipa('ci1', onsets={'c': "tʃ'"})
["tʃ'i55"]
>>> jyutping_to_ipa('ci1', tones={'1': "˥"})
['tsʰi˥']

See also

g2p(): One-shot grapheme-to-phoneme conversion that composes characters_to_jyutping() with this function.