How to use the pycantonese.util.startswithoneof function in pycantonese

To help you get started, we’ve selected a few pycantonese examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jacksonllee / pycantonese / pycantonese / jyutping.py View on Github external
for i in range(len(yale_list) - 1):
        yale1 = yale_list[i]
        yale2 = yale_list[i+1]

        ambiguous = False

        # test case 1:
        if endswithoneof(yale1, ambiguous_consonants) and \
                startswithoneof(yale2, vowel_letters):
            ambiguous = True

        # test case 2:
        if not ambiguous and \
                not endswithoneof(yale1, ambiguous_consonants) and \
                startswithoneof(yale2, ambiguous_consonants):
            ambiguous = True

        output_str += yale1

        if ambiguous:
            output_str += '\''

    output_str += yale_list[-1]

    return output_str
github jacksonllee / pycantonese / pycantonese / jyutping / yale.py View on Github external
yale1 = yale_list[i]
        yale2 = yale_list[i + 1]

        ambiguous = False

        # test case 1:
        if endswithoneof(yale1, ambiguous_consonants) and startswithoneof(
            yale2, vowel_letters
        ):
            ambiguous = True

        # test case 2:
        if (
            not ambiguous
            and not endswithoneof(yale1, ambiguous_consonants)
            and startswithoneof(yale2, ambiguous_consonants)
        ):
            ambiguous = True

        output_str += yale1

        if ambiguous:
            output_str += "'"

    output_str += yale_list[-1]

    return output_str
github jacksonllee / pycantonese / pycantonese / jyutping.py View on Github external
vowel_letters = {'a', 'e', 'i', 'o', 'u',
                     'á', 'é', 'í', 'ó', 'ú',
                     'à', 'è', 'ì', 'ò', 'ù',
                     'ā', 'ē', 'ī', 'ō', 'ū'}

    output_str = ''

    for i in range(len(yale_list) - 1):
        yale1 = yale_list[i]
        yale2 = yale_list[i+1]

        ambiguous = False

        # test case 1:
        if endswithoneof(yale1, ambiguous_consonants) and \
                startswithoneof(yale2, vowel_letters):
            ambiguous = True

        # test case 2:
        if not ambiguous and \
                not endswithoneof(yale1, ambiguous_consonants) and \
                startswithoneof(yale2, ambiguous_consonants):
            ambiguous = True

        output_str += yale1

        if ambiguous:
            output_str += '\''

    output_str += yale_list[-1]

    return output_str