From f33f05ef71c3e1c4d1227fa876168ebd7a0db049 Mon Sep 17 00:00:00 2001 From: "liangjie.lee" Date: Sun, 8 Nov 2009 14:18:18 +0000 Subject: [PATCH] --- .../analyzer/solr/IKTokenizerFactory14.java | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/org/wltea/analyzer/solr/IKTokenizerFactory14.java diff --git a/src/org/wltea/analyzer/solr/IKTokenizerFactory14.java b/src/org/wltea/analyzer/solr/IKTokenizerFactory14.java new file mode 100644 index 0000000..2c96752 --- /dev/null +++ b/src/org/wltea/analyzer/solr/IKTokenizerFactory14.java @@ -0,0 +1,56 @@ +/** + * + */ +package org.wltea.analyzer.solr; + +import java.io.Reader; +import java.util.Map; + +import org.apache.lucene.analysis.Tokenizer; +import org.apache.solr.analysis.BaseTokenizerFactory; +import org.wltea.analyzer.lucene.IKTokenizer; + +/** + * 实现Solr1.4分词器接口 + * 基于IKTokenizer的实现 + * + * @author 李良杰 + * + */ +public final class IKTokenizerFactory14 extends BaseTokenizerFactory{ + + private boolean isMaxWordLength = false; + + /** + * IK分词器Solr TokenizerFactory接口实现类 + * 默认最细粒度切分算法 + */ + public IKTokenizerFactory14(){ + } + + /* + * (non-Javadoc) + * @see org.apache.solr.analysis.BaseTokenizerFactory#init(java.util.Map) + */ + public void init(Map args){ + String _arg = args.get("isMaxWordLength"); + isMaxWordLength = Boolean.parseBoolean(_arg); + } + + /* + * (non-Javadoc) + * @see org.apache.solr.analysis.TokenizerFactory#create(java.io.Reader) + */ + public Tokenizer create(Reader reader) { + return new IKTokenizer(reader , isMaxWordLength()); + } + + public void setMaxWordLength(boolean isMaxWordLength) { + this.isMaxWordLength = isMaxWordLength; + } + + public boolean isMaxWordLength() { + return isMaxWordLength; + } + +}