Solr搜索引擎 — 中文全拼简拼分词

搞定了中文分词下一个就是要来搞定拼音分词了,拼音分词有分为全拼和简拼

附上:

喵了个咪的博客:http://w-blog.cn

Solr官网:http://lucene.apache.org/solr/

PS:8.0.0版本已经发布,本文使用此时较为稳定的7.7.1版本

一,全拼分词

> wget http://files.cnblogs.com/files/wander1129/pinyin.zip
> unzip pinyin.zip
> mv pinyin4j-2.5.0.jar  server/solr-webapp/webapp/WEB-INF/lib
> mv pinyinAnalyzer4.3.1.jar  server/solr-webapp/webapp/WEB-INF/lib
> vim server/solr/new_core/conf/managed-schema

<fieldType name="text_pinyin" class="solr.TextField" positionIncrementGap="0">
    <analyzer type="index">
        <tokenizer class="org.wltea.analyzer.lucene.IKTokenizerFactory"/>
        <filter class="com.shentong.search.analyzers.PinyinTransformTokenFilterFactory" minTermLenght="2" />
        <filter class="com.shentong.search.analyzers.PinyinNGramTokenFilterFactory" minGram="1" maxGram="20" />
    </analyzer>
    <analyzer type="query">
        <tokenizer class="org.wltea.analyzer.lucene.IKTokenizerFactory"/>
        <filter class="com.shentong.search.analyzers.PinyinTransformTokenFilterFactory" minTermLenght="2" />
        <filter class="com.shentong.search.analyzers.PinyinNGramTokenFilterFactory" minGram="1" maxGram="20" />
    </analyzer>
</fieldType>

自制分词规则

> webapps/solr/WEB-INF/classes/
> cd /usr/local/solr-7.7.1/server/solr-webapp/webapp/WEB-INF
> mkdir classes
> wget http://pic.w-blog.cn/ikanalyzer-solr5.zip
> unzip ikanalyzer-solr5.zip 
> cd ikanalyzer-solr5/
> mv ext.dic ../server/solr-webapp/webapp/WEB-INF/classes/
> mv IKAnalyzer.cfg.xml ../server/solr-webapp/webapp/WEB-INF/classes/
> mv stopword.dic ../server/solr-webapp/webapp/WEB-INF/classes/
> vim ext.dic

美团

简拼分词

> wget http://pic.w-blog.cn/pinyinTokenFilter-1.1.0-RELEASE.jar
> mv pinyinTokenFilter-1.1.0-RELEASE.jar server/solr-webapp/webapp/WEB-INF/lib
> vim server/solr/new_core/conf/managed-schema

<fieldType name="text_jian_pinyin" class="solr.TextField">  
    <analyzer type="index">  
        <tokenizer class="org.wltea.analyzer.lucene.IKTokenizerFactory" isMaxWordLength="false" useSmart="false" />  
        <filter class="solr.LowerCaseFilterFactory" />  
        <filter class="top.pinyin.index.solr.PinyinTokenFilterFactory" pinyin="true" isFirstChar="true" minTermLenght="2" />  
        <filter class="com.shentong.search.analyzers.PinyinNGramTokenFilterFactory" minGram="2" maxGram="20" />  
    </analyzer>  
    <analyzer type="query">  
        <tokenizer class="org.wltea.analyzer.lucene.IKTokenizerFactory" isMaxWordLength="false" useSmart="false" />  
        <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true" />  
        <filter class="solr.LowerCaseFilterFactory" />  
    </analyzer>  
</fieldType>  

<field name="app_name" type="text_jian_pinyin" indexed="true" stored="true" />

展开阅读全文

Windows版YOLOv4目标检测实战:训练自己的数据集

04-26
©️2020 CSDN 皮肤主题: 技术黑板 设计师: CSDN官方博客 返回首页
实付0元
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值