src/main/java/eu/digitisation/langutils/TermFrequency.java
public int editDistance(TermFrequency other) {
        int dplus = 0;    // excess
        int dminus = 0;   // fault
        for (String word : this.keySet()) {
            int delta = this.value(word) - other.value(word);
            if (delta > 0) {
                dplus += delta;
            } else {
                dminus += delta;
            }
        }
        for (String word : other.keySet()) {
            if (!this.containsKey(word)) {
                int delta = this.value(word) - other.value(word);
                if (delta > 0) {
                    dplus += delta;
                } else {
                    dminus += delta;
                }
            }
        }
        return Math.max(dplus, dminus);
    }
/**
     * Compute the order-independent edit-distance between two documents
     * (equivalent to a bags of words model).
     *
     * @param other another TermFrequency
     * @return the number of differences between this and the other bag of words
     */
Compute the order-independent edit-distance between two documents
(equivalent to a bags of words model).

@param other another TermFrequency
@return the number of differences between this and the other bag of words
Compute the order - independent edit - distance between two documents ( equivalent to a bags of words model ) . @param other another TermFrequency @return the number of differences between this and the other bag of words
public int editDistance(TermFrequency other) {
        int dplus = 0;    
        int dminus = 0;   
        for (String word : this.keySet()) {
            int delta = this.value(word) - other.value(word);
            if (delta > 0) {
                dplus += delta;
            } else {
                dminus += delta;
            }
        }
        for (String word : other.keySet()) {
            if (!this.containsKey(word)) {
                int delta = this.value(word) - other.value(word);
                if (delta > 0) {
                    dplus += delta;
                } else {
                    dminus += delta;
                }
            }
        }
        return Math.max(dplus, dminus);
    }
public int editDistance ( TermFrequency other ) { int dplus = 0 ; int dminus = 0 ; for ( String word : this . keySet ( ) ) { int delta = this . value ( word ) - other . value ( word ) ; if ( delta > 0 ) { dplus += delta ; } else { dminus += delta ; } } for ( String word : other . keySet ( ) ) { if ( ! this . containsKey ( word ) ) { int delta = this . value ( word ) - other . value ( word ) ; if ( delta > 0 ) { dplus += delta ; } else { dminus += delta ; } } } return Math . max ( dplus , dminus ) ; }
Compute the order-independent edit-distance between two documents
 (equivalent to a bags of words model).
Compute the order - independent edit - distance between two documents ( equivalent to a bags of words model ) .
// excess // fault