FMeasure { static int countTruePositives(Object references[], Object predictions[]) { int truePositives = 0; for (int referenceIndex = 0; referenceIndex < references.length; referenceIndex++) { Object referenceName = references[referenceIndex]; for (int predictedIndex = 0; predictedIndex < predictions.length; predictedIndex++) { if (referenceName.equals(predictions[predictedIndex])) { truePositives++; } } } return truePositives; }  double getPrecisionScore(); double getRecallScore(); double getFMeasure(); void updateScores(Object references[], Object predictions[]); void mergeInto(FMeasure measure); @Override String toString(); static double precision(Object references[], Object predictions[]); static double recall(Object references[], Object predictions[]);  }
@Test public void testCountTruePositives() { assertEquals(0, FMeasure.countTruePositives(new Object[]{}, new Object[]{})); assertEquals(gold.length, FMeasure.countTruePositives(gold, gold)); assertEquals(0, FMeasure.countTruePositives(gold, predictedCompletelyDistinct)); assertEquals(2, FMeasure.countTruePositives(gold, predicted)); }