/** * Edit distance between two strings. O(mn) time and O(n) space for weighted * edit distance. O(ne) time and O(mn) space for unit cost edit distance. * For weighted edit distance, this method is multi-thread safe. However, * it is NOT multi-thread safe for unit cost edit distance. */ @Override public double d(String x, String y) { if (weight != null) return weightedEdit(x, y); else if (x.length() == 1 || y.length() == 1) if (damerauDistance) return damerau(x, y); else return levenshtein(x, y); else return br(x, y); }
/** * Edit distance between two strings. O(mn) time and O(n) space for weighted * edit distance. O(ne) time and O(mn) space for unit cost edit distance. * For weighted edit distance, this method is multi-thread safe. However, * it is NOT multi-thread safe for unit cost edit distance. */ public double d(char[] x, char[] y) { if (weight != null) return weightedEdit(x, y); else if (x.length == 1 || y.length == 1) if (damerauDistance) return damerau(x, y); else return levenshtein(x, y); else return br(x, y); }