本帖最后由 czl756 于 2010-04-07 10:40:03 编辑

解决方案 »

  1.   

    只需要看这个部分的方法调用。
    注释行//加入新词项的下一句: TermInfo aTermInfo = new TermInfo();
    这句出问题了,TermInfo类的定义在一楼最下面贴了。eclipse该行的调试信息——“ClassNotFoundException”。 public TreeMap<String, TermInfo> setTermInfoSet() {
    long sTime = System.currentTimeMillis();
    TreeMap<String, TermInfo> terms = new TreeMap<String, TermInfo>();//新建TreeMap对象
    String currentArticleKey = articleSortedMap.firstKey();//取文档集最小的键值
    while(currentArticleKey != null) {
    String currentArticleContent = articleSortedMap.get(currentArticleKey);//文档正文内容
    String str = currentArticleContent.substring(2,3);//文档第一个非空词项
    String tempTerm = str;
    for(int i = 3; i != currentArticleContent.length() - 1;) {//遍历文档字符串
    str = currentArticleContent.substring(i, i+1);
    if(str.equals(" ")) i++;
    int j = i;
    while(!str.equals(" ")) {//取词项,词项间以" "隔开
    tempTerm += str;
    j++;
    str = currentArticleContent.substring(j, j+1);
    }
    i = j;
    if(stopwordSet.contains(tempTerm))
    continue;//遇到停用词,换下一个非空词项
    else {
    if(!terms.keySet().contains(tempTerm)) {//加入新词项
    TermInfo aTermInfo = new TermInfo();
    aTermInfo.totalCount = 1;
    aTermInfo.inDocInfo.put(currentArticleKey, 1);
    terms.put(tempTerm, aTermInfo);
    }
    else {//更新词项信息
    terms.get(tempTerm).totalCount++;
    Integer tempCount = terms.get(tempTerm).inDocInfo.get(currentArticleKey) + 1;
    terms.get(tempTerm).inDocInfo.put(currentArticleKey, tempCount);
    }
    }
    }
    currentArticleKey = articleSortedMap.higherKey(currentArticleKey);//取下一个严格高于当前键值的最小键值
    }
    long eTime = System.currentTimeMillis();
    System.out.println("stopword count is "+terms.size());
    System.out.println("Building the TermInfoSortedMap used "+(eTime - sTime)+"ms");
    return terms;
    }
      

  2.   

    TermInfo 类没找到,你查查是否编译了。
      

  3.   

    个人感觉,最容易出现的EXCEPTION就是ClassNotFoundException,最容易找的也是这个问题
      

  4.   

    只能是6楼说的:TermInfo类没编译吧?
    用的eclipse还是cmd运行的...?