Skip to content

Commit

Permalink
修复 convertToPinyinList fix #1634
Browse files Browse the repository at this point in the history
  • Loading branch information
hankcs committed Mar 19, 2021
1 parent 88d3eb0 commit 18e5c7a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,10 @@ protected static List<Pinyin> segLongest(char[] charArray, AhoCorasickDoubleArra
public void hit(int begin, int end, Pinyin[] value)
{
int length = end - begin;
if (length == 1 && value.length > 1)
{
value = new Pinyin[]{value[0]};
}
if (length > lengths[begin])
{
wordNet[begin] = value;
Expand Down
5 changes: 5 additions & 0 deletions src/test/java/com/hankcs/hanlp/HanLPTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,9 @@ public void testDicUpdate()
{
System.out.println(HanLP.segment("大数据是一个新词汇!"));
}

public void testConvertToPinyinList()
{
System.out.println(HanLP.convertToPinyinString("你好", " ", false));
}
}

0 comments on commit 18e5c7a

Please # to comment.