src/main/java/eu/digitisation/distance/EditDistance.java
public static int[] wordDistance(String s1, String s2,
            WordSet stopwords, int chunkLen) {
        MinimalPerfectHash mph = new MinimalPerfectHash(true); // case sensitive
        TokenArray a1 = new TokenArray(mph, s1);
        TokenArray a2 = new TokenArray(mph, s2);
        EditSequence seq = new EditSequence(a1, a2, chunkLen);
        int d = 0;
        int n1 = 0;
        int n2 = 0;
        for (EdOp op : seq.ops) {
            String word = a1.wordAt(n1);
            if (op != EdOp.KEEP && !stopwords.contains(word)) {
                ++d;
            }
            if (op != EdOp.INSERT) {
                ++n1;
            }
            if (op != EdOp.DELETE) {
                ++n2;
            }
        }
        return new int[]{a1.length(), a2.length(), d};
    }
/**
     * @param s1 the first string.
     * @param s2 the second string.
     * @param stopwords a set of stop-words
     * @param chunkLen the length of the chunks analyzed at every step (must be
     * strictly greater than 1)
     * @return the length (number of words) of first, the length (number of
     * words) of second, and the approximate (linear time) word-based
     * Levenshtein distance between first and second. Whenever a stop-word in
     * the first string is aligned (substituted) with a different target word in
     * the second string or with no string at all (deleted), this difference
     * does not contribute to the distance
     */
@param s1 the first string.
@param s2 the second string.
@param stopwords a set of stop-words
@param chunkLen the length of the chunks analyzed at every step (must be
strictly greater than 1)
@return the length (number of words) of first, the length (number of
words) of second, and the approximate (linear time) word-based
Levenshtein distance between first and second. Whenever a stop-word in
the first string is aligned (substituted) with a different target word in
the second string or with no string at all (deleted), this difference
does not contribute to the distance
@param s1 the first string . @param s2 the second string . @param stopwords a set of stop - words @param chunkLen the length of the chunks analyzed at every step ( must be strictly greater than 1 ) @return the length ( number of words ) of first the length ( number of words ) of second and the approximate ( linear time ) word - based Levenshtein distance between first and second . Whenever a stop - word in the first string is aligned ( substituted ) with a different target word in the second string or with no string at all ( deleted ) this difference does not contribute to the distance
public static int[] wordDistance(String s1, String s2,
            WordSet stopwords, int chunkLen) {
        MinimalPerfectHash mph = new MinimalPerfectHash(true); 
        TokenArray a1 = new TokenArray(mph, s1);
        TokenArray a2 = new TokenArray(mph, s2);
        EditSequence seq = new EditSequence(a1, a2, chunkLen);
        int d = 0;
        int n1 = 0;
        int n2 = 0;
        for (EdOp op : seq.ops) {
            String word = a1.wordAt(n1);
            if (op != EdOp.KEEP && !stopwords.contains(word)) {
                ++d;
            }
            if (op != EdOp.INSERT) {
                ++n1;
            }
            if (op != EdOp.DELETE) {
                ++n2;
            }
        }
        return new int[]{a1.length(), a2.length(), d};
    }
public static int [ ] wordDistance ( String s1 , String s2 , WordSet stopwords , int chunkLen ) { MinimalPerfectHash mph = new MinimalPerfectHash ( true ) ; TokenArray a1 = new TokenArray ( mph , s1 ) ; TokenArray a2 = new TokenArray ( mph , s2 ) ; EditSequence seq = new EditSequence ( a1 , a2 , chunkLen ) ; int d = 0 ; int n1 = 0 ; int n2 = 0 ; for ( EdOp op : seq . ops ) { String word = a1 . wordAt ( n1 ) ; if ( op != EdOp . KEEP && ! stopwords . contains ( word ) ) { ++ d ; } if ( op != EdOp . INSERT ) { ++ n1 ; } if ( op != EdOp . DELETE ) { ++ n2 ; } } return new int [ ] { a1 . length ( ) , a2 . length ( ) , d } ; }
@param s1 the first string.
@param s1 the first string .
// case sensitive