本文整理汇总了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;
}
示例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;
}
示例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;
}
示例4: computeStringDistance
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@Override
double computeStringDistance(CharSequence s1, CharSequence s2) {
return StringUtils.getLevenshteinDistance(s1, s2);
}
示例5: levenshteinDistance
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private int levenshteinDistance(String s1, String s2) {
return StringUtils.getLevenshteinDistance(s1, s2);
}