经过几天的开发与调试,mmseg4j 1.6 版可以发布了。1.6 版主要实现与下功能:
MMSegAnalyzer 和 MMSegTokenizerFactory 默认的分词方式改为max-word。当然你可以单独地使用SimpleAnalyzer、ComplexAnalyzer、MaxWordAnalyzer。
多分词的效果:
public void testEffect() throws IOException { String words = segW.segWords("共和国", "|"); assertEquals("共和|国", words); } public void testEffect1() throws IOException { String words = segW.segWords("中国人民银行", "|"); assertEquals("中国|国人|人民|银行", words); } public void testEffect2() throws IOException { String words = segW.segWords("西伯利亚", "|"); assertEquals("西|伯利|利亚", words); } public void testEffect3() throws IOException { String words = segW.segWords("中华人民共和国", "|"); assertEquals("中华|华人|人民|共和|国", words); } public void testEffect4() throws IOException { String words = segW.segWords("羽毛球拍", "|"); assertEquals("羽毛|球拍", words); } public void testEffect6() throws IOException { String words = segW.segWords("为什么", "|"); assertEquals("为|什么", words); } public void testEffect7() throws IOException { String words = segW.segWords("很好听", "|"); assertEquals("很好|好听", words); } public void testEffect8() throws IOException { String words = segW.segWords("强冷空气", "|"); assertEquals("强|冷|空气", words); } public void testEffect10() throws IOException { String words = segW.segWords("清华大学", "|"); assertEquals("清华|大学", words); } public void testEffect11() throws IOException { String words = segW.segWords("华南理工大学", "|"); assertEquals("华南|理工|工大|大学", words); } public void testEffect12() throws IOException { String words = segW.segWords("广东工业大学", "|"); assertEquals("广东|工业|大学", words); }
solr 中使用
<fieldType name="textMaxWord" class="solr.TextField" > <analyzer> <tokenizer class="com.chenlb.mmseg4j.solr.MMSegTokenizerFactory" mode="max-word" dicPath="dic"/> </analyzer> </fieldType>
google code 已经提供下载。
版权所有: IT货架- 内容来自互联网,仅供用于技术学习,请遵循相关法律法规. 京ICP备11030978号-1