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

可能存在部分字的多音字拼音乱入问题 #271

Closed
yangpc170 opened this issue Mar 3, 2022 · 4 comments
Closed

可能存在部分字的多音字拼音乱入问题 #271

yangpc170 opened this issue Mar 3, 2022 · 4 comments
Labels

Comments

@yangpc170
Copy link

运行环境

  • 操作系统(macOS):
  • Python 版本:3.9.4
  • pypinyin 版本:0.44.0

问题描述

有些常见字,多音字好像多了。比如:
【王】,可以是wang,但好像多了一个“yu”的多音字
【覃】,可以是tan,可以是qin,但好像这边多了一个“yan”
等等...
总感觉我当前这个版本的包,出现了多音字拼音乱入的问题
注:可能是我查的资料不够多,如果你们找到,麻烦告诉我,谢谢!

问题复现步骤

print(pinyin('覃', heteronym=True)) --> [['tán', 'qín', 'yǎn']]
print(pinyin('王', heteronym=True)) --> [['wáng', 'wàng', 'yù']]
print(pinyin('朝', heteronym=True)) --> [['cháo', 'zhāo', 'zhū']]
print(pinyin('汪, heteronym=True)) --> [['wāng', 'wǎng', 'hóng']]

@mozillazg
Copy link
Owner

感谢反馈!

你可以先看一下这个,这里有说明对应的数据来源:https://github.com/mozillazg/python-pinyin#id9

@yangpc170
Copy link
Author

果然这边数据来源有问题,我在这边 pinyin-data,其中的pinyin.txt文件中,找到如上几个字【覃】、【王】、【朝】和【汪】等的多音字,确实出现了我说的那种情况。这边我反馈了,但没有直接修改文件,不知道他们会不会去排查全部的多音字,感觉还有不少字存在这些情况

@mozillazg
Copy link
Owner

mozillazg commented Mar 9, 2022

@yangpc170 你的需求是否跟 #198 这个是一样的?可以看一下这个 issue 里的方法

@yangpc170
Copy link
Author

非常感谢,使用上述的方法就可以实现不需要的拼音不显示了。确实有效,再次感谢

from pypinyin import pinyin
print(pinyin('朝', heteronym=True))
[['cháo', 'zhāo', 'zhū']]

如下可以去掉用不到的拼音

from pypinyin_dict.pinyin_data import kxhc1983
kxhc1983.load()
print(pinyin('朝', heteronym=True))
[['cháo', 'zhāo']]

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