@Test public void testUnitCost() { System.out.println("unit cost"); String x = "Levenshtein"; String y = "Laeveshxtin"; String z = "Laeveshetin"; EditDistance edit = new EditDistance(20, false); assertEquals(0, edit.d(x, x), 1E-7); assertEquals(4, edit.d(x, y), 1E-7); assertEquals(4, edit.d(x, z), 1E-7); assertEquals(2, edit.d("act", "cat"), 1E-7); assertEquals(5, edit.d("adcroft", "addessi"), 1E-7); assertEquals(3, edit.d("baird", "baisden"), 1E-7); assertEquals(2, edit.d("boggan", "boggs"), 1E-7); assertEquals(5, edit.d("clayton", "cleary"), 1E-7); assertEquals(4, edit.d("dybas", "dyckman"), 1E-7); assertEquals(4, edit.d("emineth", "emmert"), 1E-7); assertEquals(4, edit.d("galante", "galicki"), 1E-7); assertEquals(1, edit.d("hardin", "harding"), 1E-7); assertEquals(2, edit.d("kehoe", "kehr"), 1E-7); assertEquals(5, edit.d("lowry", "lubarsky"), 1E-7); assertEquals(3, edit.d("magallan", "magana"), 1E-7); assertEquals(1, edit.d("mayo", "mays"), 1E-7); assertEquals(4, edit.d("moeny", "moffett"), 1E-7); assertEquals(2, edit.d("pare", "parent"), 1E-7); assertEquals(2, edit.d("ramey", "ramfrey"), 1E-7); edit = new EditDistance(20, true); assertEquals(0, edit.d(x, x), 1E-7); assertEquals(4, edit.d(x, y), 1E-7); assertEquals(3, edit.d(x, z), 1E-7); assertEquals(1, edit.d("act", "cat"), 1E-7); assertEquals(5, edit.d("adcroft", "addessi"), 1E-7); assertEquals(3, edit.d("baird", "baisden"), 1E-7); assertEquals(2, edit.d("boggan", "boggs"), 1E-7); assertEquals(6, edit.d("lcayton", "cleary"), 1E-7); assertEquals(5, edit.d("ydbas", "dyckman"), 1E-7); assertEquals(4, edit.d("emineth", "emmert"), 1E-7); assertEquals(4, edit.d("galante", "galicki"), 1E-7); assertEquals(1, edit.d("hardin", "harding"), 1E-7); assertEquals(2, edit.d("kehoe", "kehr"), 1E-7); assertEquals(5, edit.d("lowry", "lubarsky"), 1E-7); assertEquals(3, edit.d("magallan", "magana"), 1E-7); assertEquals(1, edit.d("mayo", "mays"), 1E-7); assertEquals(4, edit.d("moeny", "moffett"), 1E-7); assertEquals(2, edit.d("pare", "parent"), 1E-7); assertEquals(2, edit.d("ramey", "ramfrey"), 1E-7); }
@Override public double d(String x, String y) { if (weight != null) return weightedEdit(x, y); else if (FKP == null || x.length() == 1 || y.length() == 1) return damerau ? damerau(x, y) : levenshtein(x, y); else return br(x, y); }
EditDistance implements Metric<String> { @Override public double d(String x, String y) { if (weight != null) return weightedEdit(x, y); else if (FKP == null || x.length() == 1 || y.length() == 1) return damerau ? damerau(x, y) : levenshtein(x, y); else return br(x, y); } }
EditDistance implements Metric<String> { @Override public double d(String x, String y) { if (weight != null) return weightedEdit(x, y); else if (FKP == null || x.length() == 1 || y.length() == 1) return damerau ? damerau(x, y) : levenshtein(x, y); else return br(x, y); } EditDistance();  EditDistance(boolean damerau);  EditDistance(int maxStringLength);  EditDistance(int maxStringLength, boolean damerau);  EditDistance(int[][] weight);  EditDistance(int[][] weight, double radius); }
EditDistance implements Metric<String> { @Override public double d(String x, String y) { if (weight != null) return weightedEdit(x, y); else if (FKP == null || x.length() == 1 || y.length() == 1) return damerau ? damerau(x, y) : levenshtein(x, y); else return br(x, y); } EditDistance();  EditDistance(boolean damerau);  EditDistance(int maxStringLength);  EditDistance(int maxStringLength, boolean damerau);  EditDistance(int[][] weight);  EditDistance(int[][] weight, double radius); @Override String toString(); @Override double d(String x, String y); double d(char[] x, char[] y); static int levenshtein(String x, String y); static int levenshtein(char[] x, char[] y); static int damerau(String x, String y); static int damerau(char[] x, char[] y); }
EditDistance implements Metric<String> { @Override public double d(String x, String y) { if (weight != null) return weightedEdit(x, y); else if (FKP == null || x.length() == 1 || y.length() == 1) return damerau ? damerau(x, y) : levenshtein(x, y); else return br(x, y); } EditDistance();  EditDistance(boolean damerau);  EditDistance(int maxStringLength);  EditDistance(int maxStringLength, boolean damerau);  EditDistance(int[][] weight);  EditDistance(int[][] weight, double radius); @Override String toString(); @Override double d(String x, String y); double d(char[] x, char[] y); static int levenshtein(String x, String y); static int levenshtein(char[] x, char[] y); static int damerau(String x, String y); static int damerau(char[] x, char[] y);  }