Skip to content

Commit

Permalink
增加SegmentWrapper遇到连续\n时的健壮性
Browse files Browse the repository at this point in the history
  • Loading branch information
hankcs committed Oct 17, 2015
1 parent f4feed3 commit 6fab603
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import com.hankcs.hanlp.seg.Segment;
import com.hankcs.hanlp.seg.common.Term;
import com.hankcs.hanlp.utility.TextUtility;

import java.io.BufferedReader;
import java.io.IOException;
Expand Down Expand Up @@ -58,7 +59,12 @@ public Term next() throws IOException
{
if (termArray != null && index < termArray.length) return termArray[index++];
String line = br.readLine();
if (line == null) return null;
while (TextUtility.isBlank(line))
{
if (line == null) return null;
line = br.readLine();
}

List<Term> termList = segment.seg(line);
if (termList.size() == 0) return null;
termArray = termList.toArray(new Term[0]);
Expand Down

0 comments on commit 6fab603

Please sign in to comment.