Jaro-Winkler Distance

 

 

发现commons-lang 中有实现:

StringUtils.class

public static double getJaroWinklerDistance(final CharSequence first, final CharSequence second) {
final double DEFAULT_SCALING_FACTOR = 0.1;

if (first == null || second == null) {
throw new IllegalArgumentException("Strings must not be null");
}

final double jaro = score(first,second);
final int cl = commonPrefixLength(first, second);
final double matchScore = Math.round((jaro + (DEFAULT_SCALING_FACTOR * cl * (1.0 - jaro))) *100.0)/100.0;

return matchScore;
}
posted @ 2016-11-02 17:02  风云力  阅读(725)  评论(0编辑  收藏  举报