From 8803d8f80754c9d28a00cf8ec0e24c46fa21444a Mon Sep 17 00:00:00 2001 From: hankcs Date: Fri, 8 May 2015 11:47:36 +0800 Subject: [PATCH] fixed issue https://github.com/hankcs/HanLP/issues/10 --- pom.xml | 2 +- src/main/java/com/hankcs/hanlp/seg/Segment.java | 1 + .../java/com/hankcs/test/seg/TestSegment.java | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 385bf524d..cc88d5f11 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.hankcs hanlp - 1.2.0 + 1.2.1 HanLP http://www.hankcs.com/ diff --git a/src/main/java/com/hankcs/hanlp/seg/Segment.java b/src/main/java/com/hankcs/hanlp/seg/Segment.java index 13470f69e..a6e93f715 100644 --- a/src/main/java/com/hankcs/hanlp/seg/Segment.java +++ b/src/main/java/com/hankcs/hanlp/seg/Segment.java @@ -275,6 +275,7 @@ protected void mergeNumberQuantifier(List termList, WordNet wordNetAll, sbQuantifier.setLength(0); } } + sbQuantifier.setLength(0); line += pre.realWord.length(); } // System.out.println(wordNetAll); diff --git a/src/test/java/com/hankcs/test/seg/TestSegment.java b/src/test/java/com/hankcs/test/seg/TestSegment.java index 2b501f228..22b6a5575 100644 --- a/src/test/java/com/hankcs/test/seg/TestSegment.java +++ b/src/test/java/com/hankcs/test/seg/TestSegment.java @@ -27,6 +27,7 @@ import java.io.BufferedReader; import java.io.StringReader; +import java.util.List; /** * @author hankcs @@ -182,4 +183,18 @@ public void testNumberAndQuantifier() throws Exception System.out.println(StandardTokenizer.segment(sentence)); } } + + public void testIssue10() throws Exception + { + StandardTokenizer.SEGMENT.enableNumberQuantifierRecognize(true); + IndexTokenizer.SEGMENT.enableNumberQuantifierRecognize(true); + List termList = StandardTokenizer.segment("此帐号有欠费业务是什么"); + System.out.println(termList); + termList = IndexTokenizer.segment("此帐号有欠费业务是什么"); + System.out.println(termList); + termList = StandardTokenizer.segment("15307971214话费还有多少"); + System.out.println(termList); + termList = IndexTokenizer.segment("15307971214话费还有多少"); + System.out.println(termList); + } }