------------------ 原始邮件 ------------------
发送时间: 2010年1月21日(星期四) 中午11:02
主题: 庖丁 Lucene 3.0 升级
*庖丁 Lucene 3.0 升级说明*
(代码已提交svn,下载包稍后稍推迟下)
这次升级的主要目的是支持Lucene 3.0,具体改动如下:
(1)支持Lucene 3.0,对Lucene 3.0以下的版本,请使用
http://paoding.googlecode.com/svn/branches/paoding-for-lucene-2.4/中的代码编译。
(2)使用Java 5.0编译,不再支持Java 1.4,以后的新功能将会在Java 5上开发。
(3)PaodingAnalyzer的调用接口没有改动,但在使用上需要适应Lucene 3.0的API,分词示例如下:
//生成analyzer实例
Analyzer analyzer = new PaodingAnalyzer(properties);
//取得Token流
TokenStream stream = analyzer.tokenStream("", reader);
//重置到流的开始位置
stream.reset();
//添加工具类
TermAttribute termAtt = (TermAttribute) stream.addAttribute
(TermAttribute.class);
OffsetAttribute offAtt = (OffsetAttribute) stream.addAttribute
(OffsetAttribute.class);
//循环打印所有分词及其位置
while (stream.incrementToken()) {
System.out.println(termAtt.term() + " " +
offAtt.startOffset() + " " + offAtt.endOffset());
}
具体使用方法可以参见net.paoding.analysis.analyzer.estimate以及
net.paoding.analysis.examples包下面的示例代码。
by
reno...@gmail.com