@Test public void blankMatchesBlank() throws MatchException { LevenshteinMatcher matcher = new LevenshteinMatcher(); assertTrue(matcher.matches("", "")); }
@Override public boolean matches(String s1, String s2) throws MatchException { boolean matches = false; numCalls++; if (StringUtils.isEmpty(s1) && StringUtils.isEmpty(s2)) return true; if (StringUtils.isNotEmpty(s1) && StringUtils.isNotEmpty(s2)) { matches = s1.equals(s2); if (!matches){ logger.trace("Testing ld({}, {})", s1, s2); int shorter = Math.min(s1.length(), s2.length()); int longer = Math.max(s1.length(), s2.length()); if ((longer - shorter) > maxDistance) matches = false; else { int distance = calculateLevenshtein(s1, s2).intValue(); matches = (distance <= maxDistance); } } } if (this.getDictionary() != null && matches) { matches = doFalsePositiveCheck(s1,s2); } return matches; }
LevenshteinMatcher implements Matcher { @Override public boolean matches(String s1, String s2) throws MatchException { boolean matches = false; numCalls++; if (StringUtils.isEmpty(s1) && StringUtils.isEmpty(s2)) return true; if (StringUtils.isNotEmpty(s1) && StringUtils.isNotEmpty(s2)) { matches = s1.equals(s2); if (!matches){ logger.trace("Testing ld({}, {})", s1, s2); int shorter = Math.min(s1.length(), s2.length()); int longer = Math.max(s1.length(), s2.length()); if ((longer - shorter) > maxDistance) matches = false; else { int distance = calculateLevenshtein(s1, s2).intValue(); matches = (distance <= maxDistance); } } } if (this.getDictionary() != null && matches) { matches = doFalsePositiveCheck(s1,s2); } return matches; } }
LevenshteinMatcher implements Matcher { @Override public boolean matches(String s1, String s2) throws MatchException { boolean matches = false; numCalls++; if (StringUtils.isEmpty(s1) && StringUtils.isEmpty(s2)) return true; if (StringUtils.isNotEmpty(s1) && StringUtils.isNotEmpty(s2)) { matches = s1.equals(s2); if (!matches){ logger.trace("Testing ld({}, {})", s1, s2); int shorter = Math.min(s1.length(), s2.length()); int longer = Math.max(s1.length(), s2.length()); if ((longer - shorter) > maxDistance) matches = false; else { int distance = calculateLevenshtein(s1, s2).intValue(); matches = (distance <= maxDistance); } } } if (this.getDictionary() != null && matches) { matches = doFalsePositiveCheck(s1,s2); } return matches; }  }
LevenshteinMatcher implements Matcher { @Override public boolean matches(String s1, String s2) throws MatchException { boolean matches = false; numCalls++; if (StringUtils.isEmpty(s1) && StringUtils.isEmpty(s2)) return true; if (StringUtils.isNotEmpty(s1) && StringUtils.isNotEmpty(s2)) { matches = s1.equals(s2); if (!matches){ logger.trace("Testing ld({}, {})", s1, s2); int shorter = Math.min(s1.length(), s2.length()); int longer = Math.max(s1.length(), s2.length()); if ((longer - shorter) > maxDistance) matches = false; else { int distance = calculateLevenshtein(s1, s2).intValue(); matches = (distance <= maxDistance); } } } if (this.getDictionary() != null && matches) { matches = doFalsePositiveCheck(s1,s2); } return matches; }  Dictionary getDictionary(); void setDictionary(Dictionary dictionary); @Override int getCost(); @Override boolean matches(String s1, String s2); Integer calculateLevenshtein(String s1, String s2); @Override boolean isExact(); int getMaxDistance(); void setMaxDistance(int maxDistance); @Override String getExecutionReport(); }
LevenshteinMatcher implements Matcher { @Override public boolean matches(String s1, String s2) throws MatchException { boolean matches = false; numCalls++; if (StringUtils.isEmpty(s1) && StringUtils.isEmpty(s2)) return true; if (StringUtils.isNotEmpty(s1) && StringUtils.isNotEmpty(s2)) { matches = s1.equals(s2); if (!matches){ logger.trace("Testing ld({}, {})", s1, s2); int shorter = Math.min(s1.length(), s2.length()); int longer = Math.max(s1.length(), s2.length()); if ((longer - shorter) > maxDistance) matches = false; else { int distance = calculateLevenshtein(s1, s2).intValue(); matches = (distance <= maxDistance); } } } if (this.getDictionary() != null && matches) { matches = doFalsePositiveCheck(s1,s2); } return matches; }  Dictionary getDictionary(); void setDictionary(Dictionary dictionary); @Override int getCost(); @Override boolean matches(String s1, String s2); Integer calculateLevenshtein(String s1, String s2); @Override boolean isExact(); int getMaxDistance(); void setMaxDistance(int maxDistance); @Override String getExecutionReport(); static int COST; }