package cn.reghao.tnb.sb.bayes.email;

import java.util.List;

/**
 * @author reghao
 * @date 2025-08-25 17:40:54
 */
public class SpamMain {
    static final int maxTrainNum = 50000;//训练邮件最大数
    static final int maxTestNum = 10000;//测试邮件最大数

    public static void main(String[] args) {
        String baseDir = "/home/reghao/Dropbox/dataset/trec06c";
        TextProcessor textProcessor = new TextProcessor(baseDir);

        String originalDataPath = String.format("%s/%s", baseDir, "full/index");
        List<String> list = textProcessor.getTextLines(originalDataPath);

        List<String> trainList = list.subList(0, maxTrainNum);
        String trainDataPath = String.format("%s/%s", baseDir, "full/index_train");
        textProcessor.write(trainDataPath, trainList);

        List<String> testList = list.subList(maxTrainNum, maxTrainNum + maxTestNum);
        String testDataPath = String.format("%s/%s", baseDir, "full/index_test");
        textProcessor.write(testDataPath, testList);

        SpamTrain spamTrain = new SpamTrain(textProcessor);
        spamTrain.train(trainDataPath);

        SpamTest spamTest = new SpamTest(spamTrain, maxTestNum);
        spamTest.test(testDataPath);

        /*SpamEvaluation spamEvaluation = new SpamEvaluation(spamTrain, spamTest);
        spamEvaluation.evaluation();*/
        System.out.println();
    }
}
