Skip to content

Commit e8a920c

Browse files
committed
改进原子切分 fix hankcs#1421
1 parent 65e0475 commit e8a920c

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/main/java/com/hankcs/hanlp/seg/Segment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ protected static List<AtomNode> quickAtomSegment(char[] charArray, int start, in
161161
int offsetAtom = start;
162162
int preType = CharType.get(charArray[offsetAtom]);
163163
int curType;
164-
while (++offsetAtom < end)
164+
while (++offsetAtom < end || (atomNodeList.isEmpty() && offsetAtom < charArray.length))
165165
{
166166
curType = CharType.get(charArray[offsetAtom]);
167167
if (curType != preType)

src/test/java/com/hankcs/hanlp/seg/SegmentTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,4 +536,11 @@ public void testIssue1172()
536536
CustomDictionary.insert("我的额度", "xyz");
537537
System.out.println(HanLP.segment("我的额度不够,需要提高额度"));
538538
}
539+
540+
public void testIssue1421()
541+
{
542+
System.out.println(HanLP.segment("十一中国放假吗"));
543+
System.out.println(HanLP.segment("十一发展计划"));
544+
System.out.println(HanLP.segment("十一通过山海关吗"));
545+
}
539546
}

0 commit comments

Comments
 (0)