- 5
- 0
- 约1.23万字
- 约 10页
- 2018-01-05 发布于河南
- 举报
Lucene一个简单Analyzer的代码分析
测试代码
public static void main(String[] args)
{???? String str = new String(我爱武大但我更爱中国);??????? Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_CURRENT);???? TokenStream ts = analyzer.tokenStream(null, new StringReader(str));?????? TermAttribute termAtt = (TermAttribute) ts.getAttribute(TermAttribute.class);?????? TypeAttribute typeAtt = (TypeAttribute) ts.getAttribute(TypeAttribute.class);
??????? int n = 0;????? try
????? {????????? while (ts.incrementToken())
?????????? {???????????????? System.out.println(termAtt.term());????????????????? System.out.println(typeAtt.type()
原创力文档

文档评论(0)