src/main/java/eu/digitisation/distance/ArrayEditDistance.java
public static <Type> int levenshtein(Type[] first, Type[] second) {
        int i, j;
        int[][] A;

        // intialize
        A = new int[first.length + 1][second.length + 1];

        // Compute first row
        A[0][0] = 0;
        for (j = 1; j <= second.length; ++j) {
            A[0][j] = A[0][j - 1] + 1;
        }

        // Compute other rows
        for (i = 1; i <= first.length; ++i) {
            A[i][0] = A[i - 1][0] + 1;
            for (j = 1; j <= second.length; ++j) {
                if (first[i - 1] == second[j - 1]) {
                    A[i][j] = A[i - 1][j - 1];
                } else {
                    A[i][j] = min(A[i - 1][j] + 1, A[i][j - 1] + 1,
                            A[i - 1][j - 1] + 1);
                }
            }
        }
        return A[first.length][second.length];
    }
/**
     * @param <Type> the type of object in the array
     * @param first the first string.
     * @param second the second string.
     * @return the Levenshtein distance between first and second.
     */
@param  the type of object in the array
@param first the first string.
@param second the second string.
@return the Levenshtein distance between first and second.
@param the type of object in the array @param first the first string . @param second the second string . @return the Levenshtein distance between first and second .
public static <Type> int levenshtein(Type[] first, Type[] second) {
        int i, j;
        int[][] A;
        A = new int[first.length + 1][second.length + 1];
        A[0][0] = 0;
        for (j = 1; j <= second.length; ++j) {
            A[0][j] = A[0][j - 1] + 1;
        }
        for (i = 1; i <= first.length; ++i) {
            A[i][0] = A[i - 1][0] + 1;
            for (j = 1; j <= second.length; ++j) {
                if (first[i - 1] == second[j - 1]) {
                    A[i][j] = A[i - 1][j - 1];
                } else {
                    A[i][j] = min(A[i - 1][j] + 1, A[i][j - 1] + 1,
                            A[i - 1][j - 1] + 1);
                }
            }
        }
        return A[first.length][second.length];
    }
public static < Type > int levenshtein ( Type [ ] first , Type [ ] second ) { int i , j ; int [ ] [ ] A ; A = new int [ first . length + 1 ] [ second . length + 1 ] ; A [ 0 ] [ 0 ] = 0 ; for ( j = 1 ; j <= second . length ; ++ j ) { A [ 0 ] [ j ] = A [ 0 ] [ j - 1 ] + 1 ; } for ( i = 1 ; i <= first . length ; ++ i ) { A [ i ] [ 0 ] = A [ i - 1 ] [ 0 ] + 1 ; for ( j = 1 ; j <= second . length ; ++ j ) { if ( first [ i - 1 ] == second [ j - 1 ] ) { A [ i ] [ j ] = A [ i - 1 ] [ j - 1 ] ; } else { A [ i ] [ j ] = min ( A [ i - 1 ] [ j ] + 1 , A [ i ] [ j - 1 ] + 1 , A [ i - 1 ] [ j - 1 ] + 1 ) ; } } } return A [ first . length ] [ second . length ] ; }
@param <Type> the type of object in the array
 @param first the first string.
@param <Type > the type of object in the array @param first the first string .
// intialize // Compute first row // Compute other rows