"IO error while creating POS Tagger fine-grained report file: "
+ e.getMessage());
}
}
POSEvaluator evaluator = new POSEvaluator(
new opennlp.tools.postag.POSTaggerME(model), missclassifiedListener,
reportListener);
System.out.print("Evaluating ... ");
try {
evaluator.evaluate(sampleStream);
}
catch (IOException e) {
System.err.println("failed");
throw new TerminateToolException(-1, "IO error while reading test 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: " + evaluator.getWordAccuracy());
}