package cn.lucene.lesson2;
import java.io.StringReader;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
import org.apache.lucene.util.Version;
/**
* 分词测试
*/
public class AnalyzerDemo {
public static void main(String[] args) throws Exception{
Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_43);
TokenStream ts = analyzer.tokenStream("", new StringReader("this is analyzer test!"));
ts.reset();
boolean hasNext = ts.incrementToken();
while(hasNext){
CharTermAttribute cta = ts.getAttribute(CharTermAttribute.class);
System.out.println(cta.toString());
hasNext = ts.incrementToken();
}
ts.end();
}
}
最近下载更多
最近浏览更多
szf123 LV12
2023年12月10日
微信网友_6040315240812544 LV8
2022年10月20日
19895630790 LV1
2022年7月1日
chenhongjie LV5
2021年10月21日
Altria LV5
2021年8月13日
kilord LV1
2021年5月31日
ronnie0507 LV8
2021年5月17日
lodddy LV6
2021年5月4日
3270302262
2021年3月27日
暂无贡献等级
caozhaoqi83 LV5
2021年1月21日

