DocumentCategorizerEvaluator evaluator = new DocumentCategorizerEvaluator(
new DocumentCategorizerME(model),
listeners.toArray(new DoccatEvaluationMonitor[listeners.size()]));
final PerformanceMonitor monitor = new PerformanceMonitor("doc");
ObjectStream<DocumentSample> measuredSampleStream = new ObjectStream<DocumentSample>() {
public DocumentSample read() throws IOException {
monitor.incrementCounter();
return sampleStream.read();
}
public void reset() throws IOException {
sampleStream.reset();
}
public void close() throws IOException {
sampleStream.close();
}
};
monitor.startAndPrintThroughput();
try {
evaluator.evaluate(measuredSampleStream);
} catch (IOException e) {
System.err.println("failed");
throw new TerminateToolException(-1, "IO error while reading test data: "
+ e.getMessage(), e);
} finally {
try {
measuredSampleStream.close();
} catch (IOException e) {
// sorry that this can fail
}
}
monitor.stopAndPrintFinalResult();
System.out.println();
System.out.println(evaluator);