[接口需求] 能否增加获取全部合法拼音的接口?
针对每种风格的拼音,增加相关接口,获取全部合法拼音的列表。
感谢建议~
可以通过目前已有的功能实现这个需求:
- 获取所有有声调的拼音(通过 https://github.com/mozillazg/python-pinyin/blob/master/pypinyin/pinyin_dict.py 和 https://github.com/mozillazg/python-pinyin/blob/master/pypinyin/phrases_dict.py 获取拼音数据,或者解析 https://github.com/mozillazg/pinyin-data 和 https://github.com/mozillazg/phrase-pinyin-data 项目中包含的拼音数据)
- 使用 https://pypinyin.readthedocs.io/zh_CN/master/contrib.html#tone-convert 这里的转换函数得到想要的结果)
感谢建议~
可以通过目前已有的功能实现这个需求:
- 获取所有有声调的拼音(通过 https://github.com/mozillazg/python-pinyin/blob/master/pypinyin/pinyin_dict.py 和 https://github.com/mozillazg/python-pinyin/blob/master/pypinyin/phrases_dict.py 获取拼音数据,或者解析 https://github.com/mozillazg/pinyin-data 和 https://github.com/mozillazg/phrase-pinyin-data 项目中包含的拼音数据)
- 使用 https://pypinyin.readthedocs.io/zh_CN/master/contrib.html#tone-convert 这里的转换函数得到想要的结果)
但是没有转换成注音风格的方法
@wellhowtosay 感谢反馈。
你可以先通过下面的方法实现你的需求:
- 先按前面的第 1 步获取有声调拼音
- 然后使用 https://github.com/mozillazg/python-pinyin/blob/master/pypinyin/style/bopomofo.py 这里的
to_bopomofo或to_bopomofo_first方法转换为你需要的注音风格。
等后面有空的时候我再给 pypinyin.readthedocs.io/zh_CN/master/contrib.html#tone-convert 这里加一下单独的注音转换函数。
声母 (strict=True): b, c, ch, d, f, g, h, j, k, l, m, n, p, q, r, s, sh, t, x, z, zh
声母 (strict=False): 上述声母 + w, y
韵母 (strict=False): a, ai, an, ang, ao, e, ê, ei, en, eng, er, i, ia, ian, iang, iao, ie, in, ing, iong, iu, m, n, ng, o, ong, ou, u, ua, uai, uan, uang, ue, ui, un, uo, v, ve
韵母 (strict=True): a, ai, an, ang, ao, e, ê, ei, en, eng, er, i, ia, ian, iang, iao, ie, in, ing, io, iong, iou, m, n, ng, o, ong, ou, u, ua, uai, uan, uang, uei, uen, ueng, uo, v, van, ve, vn
韵母 m 和 n 参考:https://github.com/mozillazg/python-pinyin/blob/3f832563972a6e04c1a85292ac272b936b8233ba/pypinyin/phonetic_symbol.py#L40-L46
所有有声调的拼音:pinyin.txt
感谢建议~
可以通过目前已有的功能实现这个需求:
- 获取所有有声调的拼音(通过 https://github.com/mozillazg/python-pinyin/blob/master/pypinyin/pinyin_dict.py 和 https://github.com/mozillazg/python-pinyin/blob/master/pypinyin/phrases_dict.py 获取拼音数据,或者解析 mozillazg/pinyin-data 和 mozillazg/phrase-pinyin-data 项目中包含的拼音数据)
- 使用 pypinyin.readthedocs.io/zh_CN/master/contrib.html#tone-convert 这里的转换函数得到想要的结果)