LeftNotEasy

    以前版本的Lucene是用TokenStream.next()来遍历TokenStream的内容, 目前的版本稍微修改了一下, 使用下面的的一段程序可以遍历TokenStream的内容

private static void displayTokenStream(TokenStream ts) throws IOException
{
  TermAttribute termAtt = (TermAttribute)ts.getAttribute(TermAttribute.class);
  TypeAttribute typeAtt = (TypeAttribute)ts.getAttribute(TypeAttribute.class);
  
  while (ts.incrementToken())
  {
      System.out.print(termAtt.term());
      System.out.print(\' \');
      System.out.println(typeAtt.type());
  }
  System.out.println(\' \');
}

分类:

技术点:

相关文章: