看过了许多分词包,IK无需使用Lucene可实现分词,较为简单实用。
-
public void setfre(String string){
-
-
StringReader reader = new StringReader(string);
-
IKSegmenter ik = new IKSegmenter(reader,true);//后一个变量决定是否消歧
-
-
Lexeme lexeme = null;
-
float count=0;
-
try {
-
while((lexeme = ik.next())!=null) {
-
String word=lexeme.getLexemeText();
-
count++;
-
if (!this.wordfre.containsKey(word)) {
-
this.wordfre.put(word, 1);
-
}else {
-
same++;
-
this.wordfre.put(word, this.wordfre.get(word)+1);
-
}
-
-
}
-
}
阅读(2937) | 评论(0) | 转发(0) |