文章主要是介绍,通过java方式分词,并且配置远程扩展词,实现程序热更新分词
1、下载com.github.magese:ik-analyzer 版本源代码
https://github.com/magese/ik-analyzer-solr.git
2、修改文件IKanalyzer.cfg.xml
新增远程词组属性
remote_ext_dict
remote_ext_stop_dict
对应地址填写自己远程地址
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
<comment>IK Analyzer 扩展配置</comment>
<!--用户可以在这里配置自己的扩展字典 -->
<entry key="ext_dict">local.dic;</entry>
<entry key="remote_ext_dict">http://ip:8080/ikanalyzer/ikanalyzer.txt</entry>
<entry key="remote_ext_stop_dict">http://ip:8080/ikanalyzer/ikanalyzer_stop.txt</entry>
<!--用户可以在这里配置自己的扩展停止词字典 -->
<entry key="ext_stopwords">stop.dic;</entry>
</properties>
注意:
IKanalyzer.cfg.xml 此配置文件,可以配置到引用分词jar包的项目里;放到resources下即可
3、修改源代码
1)Configuration.java 新增接口<