src/main/java/eu/digitisation/document/TermFrequencyVector.java
public int distance(TermFrequencyVector other) {
        int dplus = 0;    // excess
        int dminus = 0;   // fault
        for (Integer word : this.tf.keySet()) {
            int delta = this.tf.value(word) - other.tf.value(word);
            if (delta > 0) {
                dplus += delta;
            } else {
                dminus -= delta;
            }
        }
        for (Integer word : other.tf.keySet()) {
            if (!this.tf.containsKey(word)) {
                int delta = this.tf.value(word) - other.tf.value(word);
                if (delta > 0) {
                    dplus += delta;
                } else {
                    dminus -= delta;
                }
            }
        }
     
        return Math.max(dplus, dminus);
    }
/**
     * Compute the distance between two bag of words (order independent
     * distance)
     *
     * @param other another bag of words
     * @return the number of differences between this and the other bag of words
     */
Compute the distance between two bag of words (order independent
distance)

@param other another bag of words
@return the number of differences between this and the other bag of words
Compute the distance between two bag of words ( order independent distance ) @param other another bag of words @return the number of differences between this and the other bag of words
public int distance(TermFrequencyVector other) {
        int dplus = 0;    
        int dminus = 0;   
        for (Integer word : this.tf.keySet()) {
            int delta = this.tf.value(word) - other.tf.value(word);
            if (delta > 0) {
                dplus += delta;
            } else {
                dminus -= delta;
            }
        }
        for (Integer word : other.tf.keySet()) {
            if (!this.tf.containsKey(word)) {
                int delta = this.tf.value(word) - other.tf.value(word);
                if (delta > 0) {
                    dplus += delta;
                } else {
                    dminus -= delta;
                }
            }
        }
        return Math.max(dplus, dminus);
    }
public int distance ( TermFrequencyVector other ) { int dplus = 0 ; int dminus = 0 ; for ( Integer word : this . tf . keySet ( ) ) { int delta = this . tf . value ( word ) - other . tf . value ( word ) ; if ( delta > 0 ) { dplus += delta ; } else { dminus -= delta ; } } for ( Integer word : other . tf . keySet ( ) ) { if ( ! this . tf . containsKey ( word ) ) { int delta = this . tf . value ( word ) - other . tf . value ( word ) ; if ( delta > 0 ) { dplus += delta ; } else { dminus -= delta ; } } } return Math . max ( dplus , dminus ) ; }
Compute the distance between two bag of words (order independent
 distance)
Compute the distance between two bag of words ( order independent distance )
// excess // fault