lucene 3的中文分词mmseg4j

我的日啊,昨天刚完成了lucene 2.9到3.0的迁移,今天就有lucene 3.0.1了!!!

很久没写点有代码的东西了,实在是没时间。最近,很意外的,我竟然又写起了Java。

我的主要任务是把网站(不是我这个blog)的全文检索由lucene 2.9升级到3.x版本,同时更新下mmseg4j。

lucene 3.x版本采用了全新的API,作为过渡的2.9中那些deprecated方法在3.0中已经彻底废弃了。不过我也没有太多东西要改,主要是修正了TokenStreams的相关代码,似乎TokenStream也是3.0中最大的革新。

A new TokenStream API has been introduced with Lucene 2.9. This API has moved from being Token-based to Attribute-based. While Token still exists in 2.9 as a convenience class, the preferred way to store the information of a Token is to use AttributeImpls.

lucene的中文分词是使用的mmseg4j 1.8.2,这个版本也是针对lucene 2.x的,因此首先对mmseg4j下手。

与lucene相关的代码全部位于com.chenlb.mmseg4j.analysis;中,可以看到要做修正的地方并不多,主要还是把MMSegTokenizer中的next()换作boolean incrementToken()

READ MORE>>