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

有没有to_bopomofo ? #304

Open
SRbone opened this issue Aug 14, 2023 · 2 comments
Open

有没有to_bopomofo ? #304

SRbone opened this issue Aug 14, 2023 · 2 comments
Labels

Comments

@SRbone
Copy link

SRbone commented Aug 14, 2023

运行环境

  • 操作系统(Linux/macOS/Windows):win10
  • Python 版本:3.8.10
  • pypinyin 版本:0.49.0

问题描述

没啥bug, 请问从拼音风格怎么转到bopomofo啊?
比如:
pinyin = lazy_pinyin('衣裳', style=Style.TONE3, neutral_tone_with_five=True)
bopomofo = to_bopomofo(pinyin)
有没有to_bopomofo的风格转化啊?

问题复现步骤

@mozillazg
Copy link
Owner

@SRbone 目前没有单独的 to_bopomofo 函数,不过参考一下 https://github.com/mozillazg/python-pinyin/blob/master/pypinyin/style/bopomofo.py 这个文件里的相关内容。

@SRbone
Copy link
Author

SRbone commented Aug 15, 2023

多谢多谢,果然里面两句话就搞定了。

for find_re, replace in BOPOMOFO_REPLACE:
    pinyin = find_re.sub(replace, pinyin)
pinyin = ''.join(BOPOMOFO_TABLE.get(x, x) for x in pinyin)

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

No branches or pull requests

2 participants