當前位置: 首頁>>代碼示例>>Java>>正文


Java StringUtils.getLevenshteinDistance方法代碼示例

本文整理匯總了Java中org.apache.commons.lang3.StringUtils.getLevenshteinDistance方法的典型用法代碼示例。如果您正苦於以下問題:Java StringUtils.getLevenshteinDistance方法的具體用法?Java StringUtils.getLevenshteinDistance怎麽用?Java StringUtils.getLevenshteinDistance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.lang3.StringUtils的用法示例。


在下文中一共展示了StringUtils.getLevenshteinDistance方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: findCalendarName

import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
private String findCalendarName(final String calendarName) {
  final String nCalendarName = calendarName.toLowerCase();
  Map<String, Integer> distances = new HashMap<>();

  for(String curCalendarName : getCalendarNames()) {
    String nCurCalendarName = curCalendarName.toLowerCase();
    int distance = StringUtils.getLevenshteinDistance(nCalendarName, nCurCalendarName);

    if(distance <= 3 || nCurCalendarName.contains(nCalendarName)) {
      distances.put(curCalendarName, distance);
    }
  }

  if(distances.size() == 1) {
    return distances.keySet().stream().findFirst().get();
  }

  return null;
}
 
開發者ID:rainu,項目名稱:alexa-skill,代碼行數:20,代碼來源:NewEventSpeechlet.java

示例2: testSimilar

import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
/**
     * 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;
    }
 
開發者ID:SpiderLabs,項目名稱:Airachnid-Burp-Extension,代碼行數:21,代碼來源:RequestSender.java

示例3: evaluate

import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
@Override
public Object evaluate(DeferredObject[] arguments) throws HiveException {
  String str0 = getStringValue(arguments, 0, converters);
  String str1 = getStringValue(arguments, 1, converters);

  if (str0 == null || str1 == null) {
    return null;
  }

  int dist = StringUtils.getLevenshteinDistance(str0, str1);
  output.set(dist);
  return output;
}
 
開發者ID:myui,項目名稱:hive-udf-backports,代碼行數:14,代碼來源:GenericUDFLevenshtein.java

示例4: computeStringDistance

import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
@Override
double computeStringDistance(CharSequence s1, CharSequence s2) {
    return StringUtils.getLevenshteinDistance(s1, s2);
}
 
開發者ID:Lambda-3,項目名稱:Stargraph,代碼行數:5,代碼來源:LevenshteinRanker.java

示例5: levenshteinDistance

import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
private int levenshteinDistance(String s1, String s2) {
    return StringUtils.getLevenshteinDistance(s1, s2);
}
 
開發者ID:ETspielberg,項目名稱:bibliometrics,代碼行數:4,代碼來源:Article.java


注:本文中的org.apache.commons.lang3.StringUtils.getLevenshteinDistance方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。