SentenceDetectorEvaluationMonitor errorListener = null;
if (params.getMisclassified()) {
errorListener = new SentenceEvaluationErrorListener();
}
SentenceDetectorEvaluator evaluator = new SentenceDetectorEvaluator(
new SentenceDetectorME(model), errorListener);
System.out.print("Evaluating ... ");
ObjectStream<SentenceSample> sampleStream = SentenceDetectorTrainerTool.openSampleData("Test",
trainingDataInFile, encoding);
try {
evaluator.evaluate(sampleStream);
}
catch (IOException e) {
CmdLineUtil.printTrainingIoError(e);
throw new TerminateToolException(-1);
}
finally {
try {
sampleStream.close();
} catch (IOException e) {
// sorry that this can fail
}
}
System.err.println("done");
System.out.println();
System.out.println(evaluator.getFMeasure());
}