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

三声变调错误 #270

Open
YL-Huo opened this issue Feb 28, 2022 · 3 comments
Open

三声变调错误 #270

YL-Huo opened this issue Feb 28, 2022 · 3 comments

Comments

@YL-Huo
Copy link

YL-Huo commented Feb 28, 2022

运行环境

  • 操作系统(Linux/macOS/Windows):Windows
  • Python 版本:3.10
  • pypinyin 版本:0.46.0

问题描述

lazy_pinyin(word, style=style.TONE3, tone_sandhi=True)返回的一些词未经三声变调,例如:
lazy_pinyin(‘永远’, style=style.TONE3, tone_sandhi=True) 返回 ['yong3', 'yuan3'] (应当为yong2yuan3)
lazy_pinyin(‘两手’, style=style.TONE3, tone_sandhi=True) 返回 ['liang3', 'shou3'] (应当为liang2shou3)
lazy_pinyin(‘辗转反侧’, style=style.TONE3, tone_sandhi=True) 返回 ['zhan3', 'zhuan3', 'fan3', 'ce4'] (应当为zhan2zhuan2fan3ce4)

另一部分词例如‘你好’ni2hao3是正常的。

问题复现步骤

from pypinyin import pinyin, lazy_pinyin, Style
lazy_pinyin('辗转反侧', style=Style.TONE3, tone_sandhi=True)
['zhan3', 'zhuan3', 'fan3', 'ce4']

@mozillazg
Copy link
Owner

这个跟分词有关,目前的实现是只会对词语进行变调处理,你可以先分词然后再把分词后的结果传入:

# ['永远'] 表示是分词后的结果
lazy_pinyin(['永远'], style=style.TONE3, tone_sandhi=True)

辗转反侧 这个词语的结果(目前传 list 也会是这个结果)跟实现以及之前可能是对变调的理解不够全面有关,我再调研一下。

等我有空的时候我再调研一下更全面的变调规则以及完善一下变调的实现方式。

@YL-Huo
Copy link
Author

YL-Huo commented Mar 3, 2022

非常感谢!

三声连续变调(例如辗转反侧)的规律其实有点复杂,而且也有一些争议,这个知乎回答给了一些比较基础的解释。可能连续变调问题超过了pypinyin应当实现的功能范围,现有的功能已经非常好啦!

再次感谢。

@gzm55
Copy link

gzm55 commented Sep 1, 2022

@mozillazg '你追我赶' 这个结果也不正确吧

>>> lazy_pinyin('你追我赶', style=Style.TONE, tone_sandhi=True)
['ní', 'zhuī', 'wǒ', 'gǎn']

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

No branches or pull requests

3 participants