说明同时请教 ,基于paoding 的lucene4.*的开发是不兼容
首先下载 \paoding-analysis-2.0.4-beta
将 paoding-dic-home.properties 粘贴到src目录下 并加入一行 "paoding.dic.home=E:/paoding2_0_4/dic"
将paoding-analysis-2.0.4-beta /dic 放到E:/
引入jar包 commons-logging.jar lucene-analyzers-2.2.jar lucene-core-2.3.jar paoding-analysis.jar
package testPoading;
import java.io.StringReader;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.Token;
import org.apache.lucene.analysis.TokenStream;
//import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
import net.paoding.analysis.analyzer.PaodingAnalyzer;
public class PoadAnalyzer {
public static void main(String[] args) throws Exception {
Analyzer analyzer = new PaodingAnalyzer();
String indexStr = "我的电话号码是010110011";
StringReader reader = new StringReader(indexStr);
TokenStream ts = analyzer.tokenStream(indexStr, reader);
// ts.reset();
Token t = ts.next();
// boolean boo=ts.incrementToken();
while (t != null) {
// CharTermAttribute termAtt = (CharTermAttribute)ts.addAttribute(CharTermAttribute.class);
System.out.print(t.termText()+" ");
t=ts.next();
}
}
}
如果无法使用 请配置环境变量: PAODING_DIC_HOME=E:/paoding2_0_4/dic