public double similarity(CharSequence source, CharSequence pattern) {
        int m;
        int n;
        char s, p, s1, p1;
        
        m = pattern.length() + 1;
        n = source.length() + 1;
        for (int x = 0; x < n; x++) {
            e[0][x] = x; 
        } // for
        
        p = 0;
        
        for (int y = 1; y < m; y++) {
            e[y][0] = y;
            
            p1 = p;
            p = Character.toUpperCase(pattern.charAt(y - 1));
            s = 0;

            for (int x = 1; x < n; x++) {
                int val = BIG_VALUE;
                int cost;
                
                s1 = s;
                s = Character.toUpperCase(source.charAt(x - 1));
                
                cost = (s == p) ? 0 : 1;

                val = e[y - 1][x - 1] + cost;
                val = Math.min(e[y][x - 1] + 1, val);
                val = Math.min(e[y - 1][x] + 1, val);
                
                if (s == p1 && p == s1) {
                    val = Math.min(e[y - 2][x - 2] + cost, val);
                } // if

                e[y][x] = val;
                
            } // for
        } // for
        
        return (result = 2 * e[m - 1][n - 1] / (m + n - 2.0));
    } // similarity