.getTokenizer());
DoccatEvaluationMonitor[] listenersArr = listeners
.toArray(new DoccatEvaluationMonitor[listeners.size()]);
DoccatCrossValidator validator;
try {
DoccatFactory factory = DoccatFactory.create(params.getFactory(),
tokenizer, featureGenerators);
validator = new DoccatCrossValidator(params.getLang(), mlParams,
factory, listenersArr);
validator.evaluate(sampleStream, params.getFolds());
} catch (IOException e) {
throw new TerminateToolException(-1,
"IO error while reading training data or indexing data: "
+ e.getMessage(), e);
} finally {
try {
sampleStream.close();
} catch (IOException e) {
// sorry that this can fail
}
}
System.out.println("done");
if (reportListener != null) {
System.out.println("Writing fine-grained report to "
+ params.getReportOutputFile().getAbsolutePath());
reportListener.writeReport();
try {
// TODO: is it a problem to close the stream now?
reportOutputStream.close();
} catch (IOException e) {
// nothing to do
}
}
System.out.println();
System.out.println("Accuracy: " + validator.getDocumentAccuracy() + "\n" +
"Number of documents: " + validator.getDocumentCount());
}