首页 > 编程语言 > 详细

自然语言交流系统 phxnet团队 创新实训 个人博客 (七)

时间:2017-05-22 13:00:17      阅读:311      评论:0      收藏:0      [点我收藏+]

 

 

使用Lucene 3.0.0的结构遍历TokenStream的内容.

 

以前版本的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(‘ ‘);
}

自然语言交流系统 phxnet团队 创新实训 个人博客 (七)

原文:http://www.cnblogs.com/qiaoyanlin/p/6888856.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!