From 6fab6037fc182d186dbbe70f0269b88ca482473d Mon Sep 17 00:00:00 2001 From: hankcs Date: Sat, 17 Oct 2015 10:51:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0SegmentWrapper=E9=81=87?= =?UTF-8?q?=E5=88=B0=E8=BF=9E=E7=BB=AD\n=E6=97=B6=E7=9A=84=E5=81=A5?= =?UTF-8?q?=E5=A3=AE=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hankcs/hanlp/seg/common/wrapper/SegmentWrapper.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/hankcs/hanlp/seg/common/wrapper/SegmentWrapper.java b/src/main/java/com/hankcs/hanlp/seg/common/wrapper/SegmentWrapper.java index 75a3872dc..dfc82f76d 100644 --- a/src/main/java/com/hankcs/hanlp/seg/common/wrapper/SegmentWrapper.java +++ b/src/main/java/com/hankcs/hanlp/seg/common/wrapper/SegmentWrapper.java @@ -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; @@ -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 termList = segment.seg(line); if (termList.size() == 0) return null; termArray = termList.toArray(new Term[0]);