Java Code Examples for org.apache.commons.lang3.StringUtils#getJaroWinklerDistance()

The following examples show how to use org.apache.commons.lang3.StringUtils#getJaroWinklerDistance() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: Mutters   File: FuzzySlot.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Optional<SlotMatch<String>> match(String token, Context context)
{
  String lowerToken = token.toLowerCase();
  double bestMatchScore = 0;
  String bestMatch = null;

  for (String option : options)
  {
    double score = StringUtils.getJaroWinklerDistance(lowerToken, option.toLowerCase());
    if (score > bestMatchScore)
    {
      bestMatchScore = score;
      bestMatch = option;
    }
  }

  if (bestMatchScore > tolerance && bestMatch != null)
  {
    return Optional.of(new SlotMatch<>(this, token, bestMatch));
  }
  else
  {
    return Optional.empty();
  }
}
 
Example 2
/**
     * Testing if the responses of two requests are similar. This is the not the same as the same, rather there is a
     * threshold set in the static parameters of the class.
     * @param firstString
     * @param secondString
     * @return Test if similar
     */
    private static boolean testSimilar(String firstString, String secondString) {
//        int fuzzyDist = StringUtils.getFuzzyDistance(firstString, secondString, Locale.getDefault());
        double jaroDist = StringUtils.getJaroWinklerDistance(firstString, secondString);
        int levenDist = StringUtils.getLevenshteinDistance(firstString, secondString);

//        BurpExtender.print("============================================");
//        BurpExtender.print("Fuzzy Distance:" + fuzzyDist);
//        BurpExtender.print("        Jaro Winkler Distance:" + jaroDist);
//        BurpExtender.print("        Levenshtein Distance:" + levenDist);
//        BurpExtender.print("============================================");

        return jaroDist >= JARO_THRESHOLD || levenDist <= LEVENSHTEIN_THRESHOLD;
    }
 
Example 3
Source Project: Stargraph   File: JarowinklerRanker.java    License: MIT License 4 votes vote down vote up
@Override
double computeStringDistance(CharSequence s1, CharSequence s2) {
    return StringUtils.getJaroWinklerDistance(s1, s2);
}