ConstituentLabelingEvaluator extends Evaluator { public void evaluate(ClassificationTester tester, View gold, View prediction) { super.cleanAttributes(gold, prediction); Set<Constituent> goldCons = new HashSet<>(gold.getConstituents()); Set<Constituent> predictionCons = new HashSet<>(prediction.getConstituents()); Set<Constituent> predictionConsMinusGoldCons = new HashSet<>(predictionCons); predictionConsMinusGoldCons.removeAll(goldCons); for (Constituent c : goldCons) { boolean contains = false; for(Constituent cPred: predictionCons) if (cPred.equalsWithoutAttributeEqualityCheck(c)) contains = true; if (contains) tester.recordCount(c.getLabel(), 1, 1, 1); else tester.recordCount(c.getLabel(), 1, 1, 0); } for (Constituent c : predictionConsMinusGoldCons) { tester.recordCount(c.getLabel(), 0, 1, 0); } }  void evaluate(ClassificationTester tester, View gold, View prediction);  }
@Test public void testEvaluateIdenticalSpanLabels() throws Exception { ConstituentLabelingEvaluator evaluator = new ConstituentLabelingEvaluator(); evaluator.evaluate(splittingTester, gold, gold); assertEquals(1.0, splittingTester.getMicroF1(), 0); assertEquals(1.0, splittingTester.getMicroPrecision(), 0); }
@Test public void testEvaluateNoisySpanLabels() throws Exception { ConstituentLabelingEvaluator evaluator = new ConstituentLabelingEvaluator(); evaluator.evaluate(splittingTester, gold, predicted); assertEquals(0.636, splittingTester.getMicroF1(), 0.01); assertEquals(0.568, splittingTester.getMicroPrecision(), 0.01); }