@Test public void testCountTruePositives() { Assert.assertEquals(0, FMeasure.countTruePositives(new Object[] {}, new Object[] {})); Assert.assertEquals(gold.length, FMeasure.countTruePositives(gold, gold)); Assert.assertEquals(0, FMeasure.countTruePositives(gold, predictedCompletelyDistinct)); Assert.assertEquals(2, FMeasure.countTruePositives(gold, predicted)); }
static int countTruePositives(final Object[] references, final Object[] predictions) { List<Object> predListSpans = new ArrayList<>(predictions.length); Collections.addAll(predListSpans, predictions); int truePositives = 0; Object matchedItem = null; for (Object referenceName : references) { for (Object predListSpan : predListSpans) { if (referenceName.equals(predListSpan)) { matchedItem = predListSpan; truePositives++; } } if (matchedItem != null) { predListSpans.remove(matchedItem); } } return truePositives; }
FMeasure { static int countTruePositives(final Object[] references, final Object[] predictions) { List<Object> predListSpans = new ArrayList<>(predictions.length); Collections.addAll(predListSpans, predictions); int truePositives = 0; Object matchedItem = null; for (Object referenceName : references) { for (Object predListSpan : predListSpans) { if (referenceName.equals(predListSpan)) { matchedItem = predListSpan; truePositives++; } } if (matchedItem != null) { predListSpans.remove(matchedItem); } } return truePositives; } }
FMeasure { static int countTruePositives(final Object[] references, final Object[] predictions) { List<Object> predListSpans = new ArrayList<>(predictions.length); Collections.addAll(predListSpans, predictions); int truePositives = 0; Object matchedItem = null; for (Object referenceName : references) { for (Object predListSpan : predListSpans) { if (referenceName.equals(predListSpan)) { matchedItem = predListSpan; truePositives++; } } if (matchedItem != null) { predListSpans.remove(matchedItem); } } return truePositives; }  }
FMeasure { static int countTruePositives(final Object[] references, final Object[] predictions) { List<Object> predListSpans = new ArrayList<>(predictions.length); Collections.addAll(predListSpans, predictions); int truePositives = 0; Object matchedItem = null; for (Object referenceName : references) { for (Object predListSpan : predListSpans) { if (referenceName.equals(predListSpan)) { matchedItem = predListSpan; truePositives++; } } if (matchedItem != null) { predListSpans.remove(matchedItem); } } return truePositives; }  double getPrecisionScore(); double getRecallScore(); double getFMeasure(); void updateScores(final Object[] references, final Object[] predictions); void mergeInto(final FMeasure measure); @Override String toString(); static double precision(final Object[] references, final Object[] predictions); static double recall(final Object[] references, final Object[] predictions); }
FMeasure { static int countTruePositives(final Object[] references, final Object[] predictions) { List<Object> predListSpans = new ArrayList<>(predictions.length); Collections.addAll(predListSpans, predictions); int truePositives = 0; Object matchedItem = null; for (Object referenceName : references) { for (Object predListSpan : predListSpans) { if (referenceName.equals(predListSpan)) { matchedItem = predListSpan; truePositives++; } } if (matchedItem != null) { predListSpans.remove(matchedItem); } } return truePositives; }  double getPrecisionScore(); double getRecallScore(); double getFMeasure(); void updateScores(final Object[] references, final Object[] predictions); void mergeInto(final FMeasure measure); @Override String toString(); static double precision(final Object[] references, final Object[] predictions); static double recall(final Object[] references, final Object[] predictions);  }