Chinaunix首页 | 论坛 | 博客
  • 博客访问: 79782
  • 博文数量: 31
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 839
  • 用 户 组: 普通用户
  • 注册时间: 2013-03-12 14:38
个人简介

我在收集一些石头,我期待它们有一天能够串联成一串项链。

文章分类

全部博文(31)

文章存档

2013年(31)

我的朋友

分类: Java

2013-03-12 16:39:03

看过了许多分词包,IK无需使用Lucene可实现分词,较为简单实用。

点击(此处)折叠或打开

  1. public void setfre(String string){

  2.      StringReader reader = new StringReader(string);
  3.      IKSegmenter ik = new IKSegmenter(reader,true);//后一个变量决定是否消歧

  4.                Lexeme lexeme = null;
  5.      float count=0;
  6.      try {
  7.             while((lexeme = ik.next())!=null) {
  8.                 String word=lexeme.getLexemeText();
  9.                 count++;
  10.                 if (!this.wordfre.containsKey(word)) {
  11.                     this.wordfre.put(word, 1);
  12.                 }else {
  13.                     same++;
  14.                     this.wordfre.put(word, this.wordfre.get(word)+1);
  15.                 }
  16.                 
  17.             }
  18. }

阅读(2906) | 评论(0) | 转发(0) |
0

上一篇:equal | == | equals | hashCode

下一篇:网页解析

给主人留下些什么吧!~~