Coder Social home page Coder Social logo

输出拼音缺少分隔符 about pinyin4j HOT 8 OPEN

wangdamu avatar wangdamu commented on August 12, 2024
输出拼音缺少分隔符

from pinyin4j.

Comments (8)

yupnano avatar yupnano commented on August 12, 2024

同样遇到该问题,有些词语出现分隔符失效的问题,拼音没有分隔开。

from pinyin4j.

jliuchen avatar jliuchen commented on August 12, 2024

同样遇到该问题,有些词语出现分隔符失效的问题,拼音没有分隔开

from pinyin4j.

fengzheng0571 avatar fengzheng0571 commented on August 12, 2024

同样遇到该问题,请问有解决办法吗?

from pinyin4j.

wnjustdoit avatar wnjustdoit commented on August 12, 2024

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

from pinyin4j.

looly avatar looly commented on August 12, 2024

我也被这个bug坑到了,原因是插入分隔符的时候逻辑判断有问题,多个汉字最后两个汉字的分隔符没有插入导致的。

hutool的解决办法是:

// 添加一个后缀是为了解决Pinyin4j的bug,在指定分隔符后,最后两个词的分隔符失效
str += " ";
String result;
try {
	result = PinyinHelper.toHanYuPinyinString(str, format, separator, true);
} catch (BadHanyuPinyinOutputFormatCombination e) {
	throw new PinyinException(e);
}

return result.substring(0, result.length()-1);

from pinyin4j.

wnjustdoit avatar wnjustdoit commented on August 12, 2024

我也被这个bug坑到了,原因是插入分隔符的时候逻辑判断有问题,多个汉字最后两个汉字的分隔符没有插入导致的。

hutool的解决办法是:

// 添加一个后缀是为了解决Pinyin4j的bug,在指定分隔符后,最后两个词的分隔符失效
str += " ";
String result;
try {
	result = PinyinHelper.toHanYuPinyinString(str, format, separator, true);
} catch (BadHanyuPinyinOutputFormatCombination e) {
	throw new PinyinException(e);
}

return result.substring(0, result.length()-1);

我已经修复了内部逻辑,https://github.com/wnjustdoit/pinyin4j/blob/master/src/test/java/net/sourceforge/pinyin4j/test/NewPinyinHelperTest.java

from pinyin4j.

looly avatar looly commented on August 12, 2024

我也被这个bug坑到了,原因是插入分隔符的时候逻辑判断有问题,多个汉字最后两个汉字的分隔符没有插入导致的。
hutool的解决办法是:

// 添加一个后缀是为了解决Pinyin4j的bug,在指定分隔符后,最后两个词的分隔符失效
str += " ";
String result;
try {
	result = PinyinHelper.toHanYuPinyinString(str, format, separator, true);
} catch (BadHanyuPinyinOutputFormatCombination e) {
	throw new PinyinException(e);
}

return result.substring(0, result.length()-1);

我已经修复了内部逻辑,https://github.com/wnjustdoit/pinyin4j/blob/master/src/test/java/net/sourceforge/pinyin4j/test/NewPinyinHelperTest.java

没有提交maven**库,用户没法用哎。

from pinyin4j.

wnjustdoit avatar wnjustdoit commented on August 12, 2024

我也被这个bug坑到了,原因是插入分隔符的时候逻辑判断有问题,多个汉字最后两个汉字的分隔符没有插入导致的。
hutool的解决办法是:

// 添加一个后缀是为了解决Pinyin4j的bug,在指定分隔符后,最后两个词的分隔符失效
str += " ";
String result;
try {
	result = PinyinHelper.toHanYuPinyinString(str, format, separator, true);
} catch (BadHanyuPinyinOutputFormatCombination e) {
	throw new PinyinException(e);
}

return result.substring(0, result.length()-1);

我已经修复了内部逻辑,https://github.com/wnjustdoit/pinyin4j/blob/master/src/test/java/net/sourceforge/pinyin4j/test/NewPinyinHelperTest.java

没有提交maven**库,用户没法用哎。

<dependency>
  <groupId>io.github.wnjustdoit</groupId>
  <artifactId>pinyin4j</artifactId>
  <version>2.6.0</version>
</dependency>

from pinyin4j.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.