Search in sources :

Example 1 with Pair

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);
    }
}
Also used : Evaluation(edu.cmu.minorthird.classify.experiments.Evaluation) Language(edu.cmu.lti.javelin.util.Language) ViewerFrame(edu.cmu.minorthird.util.gui.ViewerFrame) Pair(edu.cmu.lti.util.Pair)

Aggregations

Language (edu.cmu.lti.javelin.util.Language)1 Pair (edu.cmu.lti.util.Pair)1 Evaluation (edu.cmu.minorthird.classify.experiments.Evaluation)1 ViewerFrame (edu.cmu.minorthird.util.gui.ViewerFrame)1