java.lang.Object
com.graphhopper.debatty.java.stringsimilarity.JaroWinkler

public class JaroWinkler extends Object
This class is copied from: https://github.com/tdebatty/java-string-similarity/blob/master/src/main/java/info/debatty/java/stringsimilarity/JaroWinkler.java and slightly modified. * The Jaro–Winkler distance metric is designed and best suited for short strings such as person names, and to detect typos; it is (roughly) a variation of Damerau-Levenshtein, where the substitution of 2 close characters is considered less important then the substitution of 2 characters that a far from each other. Jaro-Winkler was developed in the area of record linkage (duplicate detection) (Winkler, 1990). It returns a value in the interval [0.0, 1.0]. The distance is computed as 1 - Jaro-Winkler similarity.
Author:
Thibault Debatty
  • Constructor Details

    • JaroWinkler

      public JaroWinkler()
      Instantiate with default threshold (0.7).
    • JaroWinkler

      public JaroWinkler(double threshold)
      Instantiate with given threshold to determine when Winkler bonus should be used. Set threshold to a negative value to get the Jaro distance.
  • Method Details

    • getThreshold

      public final double getThreshold()
      Returns the current value of the threshold used for adding the Winkler bonus. The default value is 0.7.
      Returns:
      the current value of the threshold
    • similarity

      public final double similarity(String s1, String s2)
      Compute JW similarity.
    • distance

      public final double distance(String s1, String s2)
      Return 1 - similarity.