IKAnalyzer分词例子
package lucene;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
import org.wltea.analyzer.lucene.IKAnalyzer;
public class MyAnalyzer {
public static void main(String[] args) throws Exception {
String en="Java Hollo";
Analyzer analyzer=new IKAnalyzer();
TokenStream tokenStream= analyzer.tokenStream("word",en);
tokenStream.reset();
CharTermAttribute charTermAttribute=tokenStream.addAttribute(CharTermAttribute.class);
while(tokenStream.incrementToken()){
System.out.println(charTermAttribute.toString());
}
}
}