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

新增一个函数用于实现对结果进行分组输出 #280

Open
mozillazg opened this issue Jun 5, 2022 · 0 comments
Open

新增一个函数用于实现对结果进行分组输出 #280

mozillazg opened this issue Jun 5, 2022 · 0 comments

Comments

@mozillazg
Copy link
Owner

mozillazg commented Jun 5, 2022

问题描述

新增一个函数用于实现对结果进行分组(按词语分组、儿化音分组、隔音符号连接的拼音分组)输出:

>>> xxx('你好吗?')
[
   {
      "hanzi": "你好",
      "pinyin": ["ní hǎo"],
   },
   {
      "hanzi": "吗",
      "pinyin": ["ma"],
   },
  {
      "hanzi": "?",
      "pinyin": [],
   },
]

>>> xxx('西安')
[
   {
      "hanzi": "西安",
      "pinyin": ["xi'an"],
   },
]

>>> xxx('花儿')
[
   {
      "hanzi": "花儿",
      "pinyin": ["huar"],
   },
]

case:

  • 配合 <ruby> 标签实现汉字标注拼音的显示效果:你好 (níhǎo)(ma) (当然,这个场景下获取拼音的需求更推荐使用 javascript 库在前端实现)

  • 解决儿化音以及类似 xi'an 这种连在一起的拼音的显示场景的需求

#245

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