Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for erhua #2

Open
lars76 opened this issue Jun 9, 2024 · 2 comments
Open

Add support for erhua #2

lars76 opened this issue Jun 9, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@lars76
Copy link

lars76 commented Jun 9, 2024

Hey, could you add support for erhua. Combinations such as 事儿 = shìr​ are not handled. Even in standard Chinese (news etc.), erhua is often heard.

@lars76
Copy link
Author

lars76 commented Jun 10, 2024

Here is quick workaround based on https://en.wikipedia.org/wiki/Erhua#Standard_rules

def pinyin_to_ipa_erhua(pinyin):
    ipas = list(pinyin_to_ipa(pinyin[:-1]))
    suffix_to_ipa = {
        "anr": "ɐʵ",
        "enr": "ɚ", "inr": "ɚ", "unr": "ɚ",
        "angr": "ɑ̃ʵ",
        "engr": "ɤ̃ʵ", "ingr": "ɤ̃ʵ",
        "iongr": "ʊ̃ʵ", "ongr": "ʊ̃ʵ",
        "our": "ou̯˞",
        "iur": "ou̯ʵ",
        "aor": "ou̯˞",
        "iaor": "ɑu̯ʵ",
        "eir": "ɚ", "uir": "ɚ",
        "air": "ɐʵ",
        "ier": "ɛʵ",
        "uer": "œʵ",
        "er": "ɤʵ",
        "or": "ɔʵ",
        "ar": "ɐʵ",
        "ir": "ɚ",
        "ur": "u˞",
        "vr": "ɚ"
    }
    strip_two = ["anr", "enr", "inr", "unr", "angr", "engr", "ingr", "iongr", "ongr"]
    
    new_ipas = []
    for ipa in ipas:
        ipa = list(ipa)
        for k, v in suffix_to_ipa.items():
            if pinyin.endswith(k):
                if k in strip_two:
                    ipa = ipa[:-2]
                else:
                    ipa = ipa[:-1]
                if pinyin == "jur" or pinyin == "yur":
                    ipa += ["ɥɚ"]
                else:
                    ipa += [v]
                break
        new_ipas.append(ipa)

    return new_ipas

@stefantaubert stefantaubert added the enhancement New feature or request label Jun 12, 2024
@stefantaubert
Copy link
Owner

Hello, thank you for the suggestion and the workaround. Unfortunately, I do not have the capacity to integrate this functionality at the moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants