1:项目地址:
https://github.com/chenlb/mmseg4j-solr
https://github.com/chenlb/mmseg4j-solr/wiki
2: solr的shcema.xml:
<fieldtype name="textComplex" class="solr.TextField" positionIncrementGap="100"> <analyzer> <tokenizer class="com.chenlb.mmseg4j.solr.MMSegTokenizerFactory" mode="complex" dicPath="dic"/> </analyzer> </fieldtype> <fieldtype name="textMaxWord" class="solr.TextField" positionIncrementGap="100"> <analyzer> <tokenizer class="com.chenlb.mmseg4j.solr.MMSegTokenizerFactory" mode="max-word" /> </analyzer> </fieldtype> <fieldtype name="textSimple" class="solr.TextField" positionIncrementGap="100"> <analyzer> <tokenizer class="com.chenlb.mmseg4j.solr.MMSegTokenizerFactory" mode="simple" dicPath="n:/custom/path/to/my_dic" /> </analyzer> </fieldtype>
tokenizer 的参数:
- dicPath 参数 - 设置自定义的扩展词库,支持相对路径(相对于 solr_home).
- mode 参数 - 分词模式。
如果没有自定义的词库, dicPath 参数可以省略
3:
简单分词使用textSimple(分词粒度不过精确但耗时少), 复杂分词使用 textComplex(分词粒度精确但耗时多)
4:
下载地址: http://yun.baidu.com/s/1dD7qMFf#dir/path=%2Fmmseg4j-solr
下载后解压 mmseg4j-solr-2.2.0-with-mmseg4j-core.zip
将 mmseg4j-core-1.10.0.jar 和 mmseg4j-solr-2.2.0.jar放到 solr.war/WEB-INF/lib 目录中
solr会自动使用 mmseg4j-core-1.10.0.jar中的data目录下的分词文件
mmseg4j中的词库:(强制使用 UTF-8):
- data/chars.dic 是单字与语料中的频率,一般不用改动,1.5版本中已经加到mmseg4j的jar里了,我们不需要关心它,当然你在词库目录放这个文件可以覆盖它。
- data/units.dic 是单字的单位,默认读jar包里的,你也可以自定义覆盖它,这个功能是试行,如果不喜欢它,可以用空的units.dic文件(放到你的词库目录下)覆盖它。
- data/words.dic 是词库文件,一行一词,当然你也可以使用自己的,1.5版本使用 sogou 词库,1.0的版本是用 rmmseg 自带的词库。
- data/wordsxxx.dic 1.6版支持多个词库文件,data 目录(或你定义的目录)下读到"words"前缀且".dic"为后缀的文件。如:data/words-my.dic。
- 由于 utf-8 文件有带与不带 BOM 之分,建议词库第一行为空行或为无 BOM 格式的 utf-8 文件。
5:
solr支持在索引了一部分数据后 IK Analisis 分词转换为 mmseg4j