use of edu.cmu.lti.util.Pair in project lucida by claritylab.
the class HierarchicalClassifierTrainer method main.
public static void main(String[] args) throws Exception {
if (args.length > 3 || args.length < 2 || (args.length == 3 && !args[0].equals("--train"))) {
System.err.println("Usage:");
System.err.println("java HierarchicalClassifierTrainer [--train] <questionLang> <corpusLang>\n");
System.err.println(" - <questionLang> and <corpusLang> must be one of the following:");
System.err.println(" en_US, ja_JP, jp_JP, zh_TW, zh_CN");
System.err.println(" - Outputs a trained model in the current directory if --train is used.");
System.err.println(" - Otherwise, performs an evaluation using the configuration in the");
System.err.println(" properties file and outputs a report describing the results.");
System.exit(0);
}
boolean train = false;
int langPairInd = 0;
if (args[0].equals("--train")) {
train = true;
langPairInd++;
}
Pair<Language, Language> languagePair = new Pair<Language, Language>(Language.valueOf(args[langPairInd]), Language.valueOf(args[langPairInd + 1]));
HierarchicalClassifierTrainer qct = new HierarchicalClassifierTrainer(languagePair);
qct.initialize();
if (train) {
System.out.println("Training classifier...");
qct.trainClassifier();
qct.saveClassifier();
System.out.println("Classifier saved.");
} else {
System.out.println("Running experiment...");
Evaluation eval = qct.runExperiment();
FileUtil.writeFile(qct.createReport(), args[0] + ".report" + System.currentTimeMillis() + ".txt", "UTF-8");
ViewerFrame frame = new ViewerFrame(args[0], eval.toGUI());
frame.setVisible(true);
}
}
Aggregations