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

增加按照拼音风格进行分割的接口 #247

Open
VisualJoyce opened this issue Jul 27, 2021 · 1 comment
Open

增加按照拼音风格进行分割的接口 #247

VisualJoyce opened this issue Jul 27, 2021 · 1 comment

Comments

@VisualJoyce
Copy link

VisualJoyce commented Jul 27, 2021

问题描述

  {'pos': 't', 'word': '一九五四年', 'pinyin': 'yi1jiu3wu3si4nian2'},

我们已知该格式的拼音,可以考虑增加接口返回一个分割好的列表。当前的模式下,可能使用正则表达式即可。扩展到各种已知风格,可能会更复杂些。但是包装好的接口可以节省很多重复工作。

本issue中的例子可以这样解决:

def parse_pinyin(text):
    g = re.findall(r'([a-z]+)', text)
    if g is not None:
        return g
    else:
        return [text]
@mozillazg
Copy link
Owner

感谢建议~

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

1 participant