### Question:
MeasureUtil { static public Double evaluateSimilarity(ComparisonMeasure comparisonMeasure, List<? extends ComparisonField> comparisonFields, BitSet flags, BitSet referenceFlags){ Measure measure = comparisonMeasure.getMeasure(); double a11 = 0d; double a10 = 0d; double a01 = 0d; double a00 = 0d; for(int i = 0; i < comparisonFields.size(); i++){ if(flags.get(i)){ if(referenceFlags.get(i)){ a11 += 1d; } else { a10 += 1d; } } else { if(referenceFlags.get(i)){ a01 += 1d; } else { a00 += 1d; } } } double numerator; double denominator; if(measure instanceof SimpleMatching){ numerator = (a11 + a00); denominator = (a11 + a10 + a01 + a00); } else if(measure instanceof Jaccard){ numerator = (a11); denominator = (a11 + a10 + a01); } else if(measure instanceof Tanimoto){ numerator = (a11 + a00); denominator = (a11 + 2d * (a10 + a01) + a00); } else if(measure instanceof BinarySimilarity){ BinarySimilarity binarySimilarity = (BinarySimilarity)measure; numerator = (binarySimilarity.getC11Parameter() * a11 + binarySimilarity.getC10Parameter() * a10 + binarySimilarity.getC01Parameter() * a01 + binarySimilarity.getC00Parameter() * a00); denominator = (binarySimilarity.getD11Parameter() * a11 + binarySimilarity.getD10Parameter() * a10 + binarySimilarity.getD01Parameter() * a01 + binarySimilarity.getD00Parameter() * a00); } else { throw new UnsupportedFeatureException(measure); } try { return (numerator / denominator); } catch(ArithmeticException ae){ throw new InvalidResultException(null); } } private  MeasureUtil(); static boolean isSimilarity(Measure measure); static Double evaluateSimilarity(ComparisonMeasure comparisonMeasure, List<? extends ComparisonField> comparisonFields, BitSet flags, BitSet referenceFlags); static BitSet toBitSet(List<FieldValue> values); static boolean isDistance(Measure measure); static Double evaluateDistance(ComparisonMeasure comparisonMeasure, List<? extends ComparisonField> comparisonFields, List<FieldValue> values, List<FieldValue> referenceValues, Double adjustment); static Double calculateAdjustment(List<FieldValue> values, List<Double> adjustmentValues); static Double calculateAdjustment(List<FieldValue> values);  }### Answer:
@Test public void evaluateSimilarity(){ List<ClusteringField> clusteringFields = createClusteringFields("one", "two", "three", "four"); BitSet flags = createFlags(0, 0, 1, 1); BitSet referenceFlags = createFlags(0, 1, 0, 1); ComparisonMeasure comparisonMeasure = new ComparisonMeasure(ComparisonMeasure.Kind.SIMILARITY); comparisonMeasure = comparisonMeasure.withMeasure(new SimpleMatching()); assertEquals(Double.valueOf(2d / 4d), MeasureUtil.evaluateSimilarity(comparisonMeasure, clusteringFields, flags, referenceFlags)); comparisonMeasure = comparisonMeasure.withMeasure(new Jaccard()); assertEquals(Double.valueOf(1d / 3d), MeasureUtil.evaluateSimilarity(comparisonMeasure, clusteringFields, flags, referenceFlags)); comparisonMeasure = comparisonMeasure.withMeasure(new Tanimoto()); assertEquals(Double.valueOf(2d / (1d + 2 * 2d + 1d)), MeasureUtil.evaluateSimilarity(comparisonMeasure, clusteringFields, flags, referenceFlags)); comparisonMeasure = comparisonMeasure.withMeasure(new BinarySimilarity(0.5d, 0.5d, 0.5d, 0.5d, 1d, 1d, 1d, 1d)); assertEquals(Double.valueOf(2d / 4d), MeasureUtil.evaluateSimilarity(comparisonMeasure, clusteringFields, flags, referenceFlags)); }