traning.java~29~

来自「基于朴素贝叶斯算法实现的中文文本分类程序。可以对中文文本进行分类识别」· JAVA~29~ 代码 · 共 48 行

JAVA~29~
48
字号


/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2005</p>
 * <p>Company: </p>
 * @author not attributable
 * @version 1.0
 */
import java.util.*;

public class Traning {
  FMMSegment vocabulary;
  Sample []v=new Sample[3];
  Dictionary dict;

  public Traning(Dictionary newDict) {
    vocabulary=new FMMSegment(newDict);
    dict=newDict;
  }



  public void train(){
    for(int i=0;i<3;i++){
      v[i]=new Sample();
    }
    v[0].init(dict,vocabulary.vocabulary); //science类别
    //扫描science文本样例
    v[0].countFreq("sample/science.txt");

    System.out.println("v0's totle words:"+v[0].wordTable.get("电子"));

  }

  public void loadVocabulary(){
    vocabulary.fileSegment("Sample/sport.txt");
    vocabulary.fileSegment("Sample/science.txt");
    vocabulary.fileSegment("Sample/history.txt");
    System.out.println("totle number of vocabulary is:"+vocabulary.NumOfVoc());
    //System.out.println(vocabulary.vocabulary.containsKey("颗粒"));

    train();
  }


}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?