You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I needed this feature as well. As a workaround, I segmented the text using the same command internally used by the pinyin library, and then combined the resulting arrays:
如下API,segmentation虽然对拼音做了分组,但是没有返回对应的汉字词语(或其索引)。
这样导致我无法根据返回值关联汉字与拼音,无法为字/词创建如下拼音注解。
要解决这个问题,需要修改API的返回值格式,否则就得先分词,再对与每个字/词调一遍pinyin()方法。
如果不想修改现有pinyin()方法的返回值格式(以免造成breaking change),那么我提议添加一个方法
pinyin.segment()
,用法如下:注:原拼音候选数组将移动一个对象作为属性
candidates
的值,另需在对象中返回属性segment
,index
二者至少其一。参考类似的API设计
The text was updated successfully, but these errors were encountered: