use of zemberek.ner.PerceptronNerTrainer.TestResult in project zemberek-nlp by ahmetaa.
the class EvaluateNer method run.
@Override
public void run() throws Exception {
initializeOutputDir();
if (hypothesisPath == null) {
IOUtil.checkDirectoryArgument(modelRoot, "Model Root");
} else {
IOUtil.checkFileArgument(referencePath, "Hypothesis File");
}
IOUtil.checkFileArgument(referencePath, "Reference File");
NerDataSet hypothesis;
NerDataSet reference = NerDataSet.load(referencePath, annotationStyle);
Log.info("Reference :");
Log.info(reference.info());
if (hypothesisPath == null) {
TurkishMorphology morphology = TurkishMorphology.createWithDefaults();
PerceptronNer ner = PerceptronNer.loadModel(modelRoot, morphology);
Stopwatch sw = Stopwatch.createStarted();
hypothesis = ner.evaluate(reference);
double secs = sw.elapsed(TimeUnit.MILLISECONDS) / 1000d;
Log.info("NER is applied to reference data in %.4f seconds.", secs);
} else {
hypothesis = NerDataSet.load(hypothesisPath, annotationStyle);
}
Log.info("Hypothesis :");
Log.info(hypothesis.info());
Path reportPath = outDir.resolve("eval-report");
PerceptronNerTrainer.evaluationReport(reference, hypothesis, reportPath);
TestResult result = PerceptronNerTrainer.collectEvaluationData(reference, hypothesis);
Log.info("Evaluation Result:");
Log.info(result.dump());
Log.info("Detailed evaluation report is written in %s", reportPath);
}
Aggregations