From 8029385cbffbede6adc26aa7856337bc93df4656 Mon Sep 17 00:00:00 2001 From: ansj Date: Thu, 1 Sep 2016 13:59:16 +0800 Subject: [PATCH] add type method --- .../java/org/ansj/lucene5/AnsjAnalyzer.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/plugin/ansj_lucene5_plugin/src/main/java/org/ansj/lucene5/AnsjAnalyzer.java b/plugin/ansj_lucene5_plugin/src/main/java/org/ansj/lucene5/AnsjAnalyzer.java index 20701f2d..fc429a9e 100644 --- a/plugin/ansj_lucene5_plugin/src/main/java/org/ansj/lucene5/AnsjAnalyzer.java +++ b/plugin/ansj_lucene5_plugin/src/main/java/org/ansj/lucene5/AnsjAnalyzer.java @@ -9,6 +9,7 @@ import java.util.Set; import org.ansj.lucene.util.AnsjTokenizer; +import org.ansj.splitWord.analysis.BaseAnalysis; import org.ansj.splitWord.analysis.DicAnalysis; import org.ansj.splitWord.analysis.IndexAnalysis; import org.ansj.splitWord.analysis.ToAnalysis; @@ -29,7 +30,7 @@ public class AnsjAnalyzer extends Analyzer { * */ public static enum TYPE { - index, query, to, dic, user, search + base, index, query, to, dic, user, search } /** 自定义停用词 */ @@ -38,10 +39,7 @@ public static enum TYPE { private TYPE type; /** - * @param filter - * 停用词 - * @param pstemming - * 是否分析词干 + * @param filter 停用词 */ public AnsjAnalyzer(TYPE type, Set filter) { this.type = type; @@ -57,6 +55,10 @@ public AnsjAnalyzer(TYPE type) { this.type = type; } + public AnsjAnalyzer(String typeStr) { + this.type = TYPE.valueOf(typeStr); + } + private Set filter(String stopwordsDir) { if (StringUtil.isBlank(stopwordsDir)) { return null; @@ -93,6 +95,13 @@ public static Tokenizer getTokenizer(BufferedReader reader, TYPE type, Set