solr学习(二)Solr4.7.2中整合中文分词mmseg4j-1.9.1

mseg4j支持最多分词,是一款很优秀的中文分词器,是用Chih-Hao Tsai 的 MMSeg 算法( http://technology.chtsai.org/mmseg/ )(本人也不懂这些,自行谷歌吧。)实现的中文分词器,并实现 lucene 的analyzer 和 solr 的TokenizerFactory 以方便在Lucene和Solr中使用。 

Solr中整合mmseg4j,需要如下几个步骤:

1、下载并解压mmseg4j-1.9.1.zip,把dist下面的所有jar文件拷贝到你应用服务器下的 solr /WEB-INF/lib中。有3个jar文件:mmseg4j-analysis-1.9.1.jar, mmseg4j-core-1.9.1.jar,mmseg4j-solr-1.9.1.jar。

2、如果是在mmseg4j-1.9.0前, 则需要copy data目录到solr_home/solr中(与core平级),并改名为dic。(本人用的是1.9.1,之前的没有 深究,就不瞎逼逼了);

3.在mmseg4j-1.9.0后,如本例的mmseg4j-1.9.1中 ,就 可以不用 dicPath 参数,可以使用 mmseg4j-core-1.9.0.jar 里的 words.dic ,在Schema.xml中加入如下配置

  <!-- mmseg4j-->
  <fieldType name="text_mmseg4j_complex" class="solr.TextField" positionIncrementGap="100" >  
    <analyzer>  
      <tokenizer class="com.chenlb.mmseg4j.solr.MMSegTokenizerFactory" mode="complex" dicPath="dic"/>  
    </analyzer>  
  </fieldType>  
  <fieldType name="text_mmseg4j_maxword" class="solr.TextField" positionIncrementGap="100" >  
    <analyzer>  
      <tokenizer class="com.chenlb.mmseg4j.solr.MMSegTokenizerFactory" mode="max-word" dicPath="dic"/>  
    </analyzer>  
  </fieldType>  
  <fieldType name="text_mmseg4j_simple" class="solr.TextField" positionIncrementGap="100" >  
    <analyzer>  
      <!--
      <tokenizer class="com.chenlb.mmseg4j.solr.MMSegTokenizerFactory" mode="simple" dicPath="n:/OpenSource/apache-solr-1.3.0/example/solr/my_dic"/> 
      -->
      <tokenizer class="com.chenlb.mmseg4j.solr.MMSegTokenizerFactory" mode="simple" dicPath="dic"/> 
    </analyzer>  
  </fieldType>
  <!-- mmseg4j-->

4、引用mmseg4j分词器

只需要在该schema.xml中加入如下配置便可引用对应的mmseg4j分词器

<field name="mmseg4j_complex_name" type="text_mmseg4j_complex" indexed="true" stored="true"/>
   <field name="mmseg4j_maxword_name" type="text_mmseg4j_maxword" indexed="true" stored="true"/>
   <field name="mmseg4j_simple_name" type="text_mmseg4j_simple" indexed="true" stored="true"/>
5、通过以上步骤就可以成功配置mmseg4j分词器到solr中了。



我是在这里找到的



如果没问题就应该没问题了、。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值