@Override
    public double d(String a, String b) {
        if (weight != null)
            return weightedEdit(a, b);
        else if (FKP == null || a.length() == 1 || b.length() == 1)
            return damerau ? damerau(a, b) : levenshtein(a, b);
        else
            return br(a, b);
    }
@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);
    }