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

返回值存在一点小问题 #31

Open
fushengruomengzhang opened this issue May 5, 2020 · 4 comments
Open

返回值存在一点小问题 #31

fushengruomengzhang opened this issue May 5, 2020 · 4 comments

Comments

@fushengruomengzhang
Copy link

代码:
private static final HanyuPinyinOutputFormat HANYU_PINYIN_OUTPUT_FORMAT = new HanyuPinyinOutputFormat();

static {
    HANYU_PINYIN_OUTPUT_FORMAT.setVCharType(HanyuPinyinVCharType.WITH_U_UNICODE);
    HANYU_PINYIN_OUTPUT_FORMAT.setCaseType(HanyuPinyinCaseType.LOWERCASE);
    HANYU_PINYIN_OUTPUT_FORMAT.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
}

public static String getPinYinChar(String str) {
try {
return PinyinHelper.toHanYuPinyinString(str, HANYU_PINYIN_OUTPUT_FORMAT, " ", false);
} catch (BadHanyuPinyinOutputFormatCombination badHanyuPinyinOutputFormatCombination) {
throw new GlobalSystemException(badHanyuPinyinOutputFormatCombination.getMessage(), badHanyuPinyinOutputFormatCombination);
}
}
测试:
@test
public void getPinYinChar(){
String s = PinYinUtil.getPinYinChar("大鱼吃小鱼,杨幂是个女的");
System.out.println(s);
}

输出结果:
da yu chi xiao yu yang mi shi ge nüde
bug描述:
separate我使用的是一个空格,返回值最后 [ 女的] 的拼音未使用separate 进行拼接
感谢开源

@wnjustdoit
Copy link

这个库很久没维护了,来这里一起助力吧:https://github.com/wnjustdoit/pinyin4j

@neo1949
Copy link

neo1949 commented Jul 1, 2020

参考 issues 28 提到的 汉语拼音正词法基本规则,实际上返回值是正确的,读一下这个基本规则应该就能理解了。

@wnjustdoit
Copy link

参考 issues 28 提到的 汉语拼音正词法基本规则,实际上返回值是正确的,读一下这个基本规则应该就能理解了。

那可不是这个问题,这个bug我已经修复了(你可以试试任意的句子,都可以正常分割的):https://github.com/wnjustdoit/pinyin4j/blob/master/src/test/java/net/sourceforge/pinyin4j/test/NewPinyinHelperTest.java

@neo1949
Copy link

neo1949 commented Jul 1, 2020

参考 issues 28 提到的 汉语拼音正词法基本规则,实际上返回值是正确的,读一下这个基本规则应该就能理解了。

那可不是这个问题,这个bug我已经修复了(你可以试试任意的句子,都可以正常分割的):https://github.com/wnjustdoit/pinyin4j/blob/master/src/test/java/net/sourceforge/pinyin4j/test/NewPinyinHelperTest.java

用的你库试了一下,确实没有出现最后两个中文字符中间未拼接分隔符的现象。

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

No branches or pull requests

3 participants