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

配置多音字后发现有不属于该汉字的发音 #57

Open
chenqgp opened this issue May 11, 2022 · 3 comments
Open

配置多音字后发现有不属于该汉字的发音 #57

chenqgp opened this issue May 11, 2022 · 3 comments

Comments

@chenqgp
Copy link

chenqgp commented May 11, 2022

我的代码如下:

hans := "一余五哎欧额"              
hans2 := "刘茜"         
hans3 := "王"
py := pinyin.NewArgs()
py.Heteronym = true 
fmt.Println(pinyin.Pinyin(hans, py))
fmt.Println(pinyin.Pinyin(hans2, py))  
fmt.Println(pinyin.Pinyin(hans3, py))

输出如下:

[[yi yi yi] [yu tu xu yu] [wu] [ai] [ou] [e]] //  余的读音?
[[liu] [qian xi]]
[[wang wang yu]] // 王有yu的读音吗?

我简单查了下资料【余】【王】好像没有上述那么多的发音?
请大佬看看,是我代码有问题还是需要做什么?

@chenqgp
Copy link
Author

chenqgp commented May 12, 2022

@mozillazg 请看看

@chenqgp
Copy link
Author

chenqgp commented May 12, 2022

我翻看了一下python版本的是可以选择数据加载的,go的版本也可以选择加载数据吗?

@mozillazg
Copy link
Owner

@chenqgp 你可以参考下面这个命令生成想使用的拼音文件(将 pinyin.txt 替换为想使用的拼音文件)的 go 源码:

@go run _tools/gen_pinyin_dict.go _tools/pinyin-data/pinyin.txt pinyin_dict.go

然后在你的程序里用这个生成的 go 文件的拼音数据覆盖内置的拼音数据即可:

for k, v := range PinyinDict {
   pinyin.PinyinDict[k] = v
}

@mozillazg mozillazg pinned this issue May 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants