CombinedRecordMatcher extends AbstractRecordMatcher { @Override public double getMatchingWeight(String[] record1, String[] record2) { double matchingWeight = 0; for (IRecordMatcher matcher : matchers) { double currentWeight = matcher.getMatchingWeight(record1, record2); if (currentWeight < matchingWeight) { continue; } lastPositiveMatcher = matcher; matchingWeight = currentWeight; if (matchingWeight >= matcher.getRecordMatchThreshold()) { return matchingWeight; } } return matchingWeight; }  @Override double getMatchingWeight(String[] record1, String[] record2); boolean add(IRecordMatcher matcher); @Override String getLabeledAttributeMatchWeights(); @Override boolean setAttributeMatchers(IAttributeMatcher[] attrMatchers); @Override boolean setAttributeWeights(double[] weights); @Override double getRecordMatchThreshold(); @Override String toString(); @Override MatchResult getMatchingWeight(Record record1, Record record2); IRecordMatcher getLastPositiveMatcher(); List<IRecordMatcher> getMatchers();  }
@Test public void testGetMatchingWeight() { final double MATCH_THRESHOLD = 0.9; IRecordMatcher recMatcher1 = RecordMatcherFactory.createMatcher(RecordMatcherType.simpleVSRMatcher, ATTRIBUTEMATCHERALGORITHMS, ATTRIBUTEWEIGHTS_1); recMatcher1.setRecordMatchThreshold(MATCH_THRESHOLD); List<List<Double>> matcherWeigths = computeWeights(recMatcher1); CombinedRecordMatcher combMatcher1 = RecordMatcherFactory.createCombinedRecordMatcher(); assertTrue(combMatcher1.add(recMatcher1)); List<List<Double>> combinedMatcherWeigths = computeWeights(combMatcher1); System.out.println(combMatcher1); compare(matcherWeigths, combinedMatcherWeigths); int nbMatch1 = countMatches(matcherWeigths); IRecordMatcher recMatcher2 = RecordMatcherFactory.createMatcher(RecordMatcherType.simpleVSRMatcher, ATTRIBUTEMATCHERALGORITHMS, ATTRIBUTEWEIGHTS_2); recMatcher2.setRecordMatchThreshold(MATCH_THRESHOLD); matcherWeigths = computeWeights(recMatcher2); CombinedRecordMatcher combMatcher2 = RecordMatcherFactory.createCombinedRecordMatcher(); assertTrue(combMatcher2.add(recMatcher2)); System.out.println(combMatcher2); compare(matcherWeigths, computeWeights(combMatcher2)); int nbMatch2 = countMatches(matcherWeigths); assertNotSame("The two matchers should not have the same match count", nbMatch1, nbMatch2); IRecordMatcher recMatcher3 = RecordMatcherFactory.createMatcher(RecordMatcherType.simpleVSRMatcher, new String[] { "DUMMY", "DUMMY", "DUMMY", "EXACT" }, new double[] { 0, 0, 0, 1 }); recMatcher3.setRecordMatchThreshold(MATCH_THRESHOLD); matcherWeigths = computeWeights(recMatcher3); CombinedRecordMatcher combMatcher3 = RecordMatcherFactory.createCombinedRecordMatcher(); assertTrue(combMatcher3.add(recMatcher3)); System.out.println(combMatcher3); compare(matcherWeigths, computeWeights(combMatcher3)); int nbMatch3 = countMatches(matcherWeigths); assertNotSame("The two matchers should not have the same match count. " + nbMatch1, nbMatch1, nbMatch3); assertNotSame("The two matchers should not have the same match count. " + nbMatch2, nbMatch2, nbMatch3); CombinedRecordMatcher combMatcher = RecordMatcherFactory.createCombinedRecordMatcher(); assertTrue(combMatcher.add(recMatcher1)); assertTrue(combMatcher.add(recMatcher2)); assertTrue(combMatcher.add(recMatcher3)); System.out.println(combMatcher); int nbMatch = countMatches(combMatcher); assertEquals(true, nbMatch >= nbMatch1); assertEquals(true, nbMatch >= nbMatch2); assertEquals(true, nbMatch >= nbMatch3); CombinedRecordMatcher reverseCombMatcher = RecordMatcherFactory.createCombinedRecordMatcher(); assertTrue(reverseCombMatcher.add(recMatcher3)); assertTrue(reverseCombMatcher.add(recMatcher2)); assertTrue(reverseCombMatcher.add(recMatcher1)); System.out.println(reverseCombMatcher); int nbMatchReverse = countMatches(combMatcher); assertEquals("The order of matcher should not change the number of matches", nbMatch, nbMatchReverse); }