Skip to content

Commit 111fa2b

Browse files
committed
提高动态插入用户词语时的健壮性
1 parent 7a0692b commit 111fa2b

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ protected static List<Vertex> combineByCustomDictionary(List<Vertex> vertexList)
245245
CoreDictionary.Attribute value = null;
246246
for (; to < wordNet.length; ++to)
247247
{
248+
if (wordNet[to] == null) continue;
248249
state = state.transition(wordNet[to].realWord.toCharArray(), 0);
249250
if (state == null) break;
250251
if (state.getValue() != null)
@@ -258,6 +259,7 @@ protected static List<Vertex> combineByCustomDictionary(List<Vertex> vertexList)
258259
StringBuilder sbTerm = new StringBuilder();
259260
for (int j = start; j < end; ++j)
260261
{
262+
if (wordNet[j] == null) continue;
261263
sbTerm.append(wordNet[j]);
262264
wordNet[j] = null;
263265
}

0 commit comments

Comments
 (0)