网上已有不少教程了。
http://www.cnblogs.com/dennisit/archive/2013/04/07/3005847.html
http://blog.sina.com.cn/s/blog_4c9d7da201013wv2.html
这里只说两点:
- dic文件要用 “无dom的UTF-8”格式编码
- dic文件最好是放在项目的src文件夹下。
我的一个范例截图
对应的IKAnalyzer.cfg.xml文件设置如下:
<?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">./dic/scut.dic;</entry>
<!--用户可以在这里配置自己的扩展停止词字典-->
<entry key="ext_stopwords">./dic/stopword.dic;</entry>
</properties>