Lucene StandardAnalyzer的代码分析2.docVIP

  • 16
  • 0
  • 约1.45万字
  • 约 13页
  • 2018-01-05 发布于河南
  • 举报
Lucene StandardAnalyzer的代码分析2

测试代码 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)

1亿VIP精品文档

相关文档