public int levenshtein() {
        int levenshtein = 0;
        int insertions = 0;
        int deletions = 0;
        for (Change aDiff : getChangeList()) {
            switch (aDiff.operation) {
                case INSERT:
                    insertions += aDiff.text.length();
                    break;
                case DELETE:
                    deletions += aDiff.text.length();
                    break;
                case EQUAL:
                    // A deletion and an insertion is one substitution.
                    levenshtein += Math.max(insertions, deletions);
                    insertions = 0;
                    deletions = 0;
                    break;
            }
        }
        levenshtein += Math.max(insertions, deletions);
        return levenshtein;
    }
public int levenshtein ( ) { int levenshtein = 0 ; int insertions = 0 ; int deletions = 0 ; for ( Change aDiff : getChangeList ( ) ) { switch ( aDiff . operation ) { case INSERT : insertions += aDiff . text . length ( ) ; break ; case DELETE : deletions += aDiff . text . length ( ) ; break ; case EQUAL : levenshtein += Math . max ( insertions , deletions ) ; insertions = 0 ; deletions = 0 ; break ; } } levenshtein += Math . max ( insertions , deletions ) ; return levenshtein ; }
Compute the Levenshtein distance; the number of inserted, deleted or
substituted characters.

@return Number of changes.