diff --git a/pypinyin/utils.py b/pypinyin/utils.py index e7e3612..a3e3f30 100644 --- a/pypinyin/utils.py +++ b/pypinyin/utils.py @@ -4,6 +4,12 @@ # 用于向后兼容,TODO: 废弃 from pypinyin.seg.simpleseg import simple_seg # noqa +from pypinyin.style._tone_convert import tone2_to_tone + + +# 用于向后兼容,TODO: 废弃 +def _replace_tone2_style_dict_to_default(string): + return tone2_to_tone(string) def _remove_dup_items(lst, remove_empty=False): diff --git a/pypinyin/utils.pyi b/pypinyin/utils.pyi index a7f8ddf..a6b2efc 100644 --- a/pypinyin/utils.pyi +++ b/pypinyin/utils.pyi @@ -1,5 +1,9 @@ from typing import List, Text + +def _replace_tone2_style_dict_to_default(string: Text) -> Text: ... + + def _remove_dup_items(lst: List[Text]) -> List[Text]: ... diff --git a/tests/contrib/test_tone_sandhi.py b/tests/contrib/test_tone_sandhi.py index 2aaa9b7..fe103f0 100644 --- a/tests/contrib/test_tone_sandhi.py +++ b/tests/contrib/test_tone_sandhi.py @@ -50,10 +50,16 @@ class MyConverter(ToneSandhiMixin, DefaultConverter): # 不满足变调条件 [['之一'], ['zhi1', 'yi1'], ['zhi1', 'yi1']], [['一'], ['yi1'], ['yi1']], + + # #270 + [['永远'], ['yo3ng', 'yua3n'], ['yo2ng', 'yua3n']], + [['两手'], ['lia3ng', 'sho3u'], ['lia2ng', 'sho3u']], + [['辗转反侧'], ['zha3n', 'zhua3n', 'fa3n', 'ce4'], + ['zha3n', 'zhua3n', 'fa3n', 'ce4']], ]) def test_tone_sandhi(han, normal_output, sandhi_output): assert lazy_pinyin(han, style=Style.TONE2) == normal_output or \ - lazy_pinyin(han, style=Style.TONE2) == sandhi_output + lazy_pinyin(han, style=Style.TONE2) == sandhi_output assert my_pinyin.lazy_pinyin(han, style=Style.TONE2) == sandhi_output # 测试关键字参数