src/main/java/eu/digitisation/ngram/NgramModel.java
public void showDiff(NgramModel other) {
        if (this.order != other.order) {
            throw new IllegalArgumentException("Illegal comparison "
                    + "of n-gram models with different n");
        }
        for (String s : this.occur.keySet()) {
            if (s.length() > 0) {
                int val1 = this.occur.get(s).getValue();
                int val2 = other.occur.containsKey(s)
                        ? other.occur.get(s).getValue() : 0;
                if (val1 != val2) {
                    System.out.println(s.replaceAll(String.valueOf(BOS), "<BoS>")
                            .replaceAll(String.valueOf(EOS), "<EoS>")
                            + " " + val1 + " " + val2);
                }
            }
        }
        for (String s : other.occur.keySet()) {
            if (s.length() > 0 && !this.occur.containsKey(s)) {
                int val2 = other.occur.get(s).getValue();
                System.out.println(s.replaceAll(String.valueOf(BOS), "<BoS>")
                        .replaceAll(String.valueOf(EOS), "<EoS>")
                        + " 0 " + val2);
            }
        }
    }
/**
     * Show differences between two NgramModels (debug function)
     *
     * @param other another NgramModel (order must coincide)
     */
Show differences between two NgramModels (debug function)
@param other another NgramModel (order must coincide)
Show differences between two NgramModels ( debug function ) @param other another NgramModel ( order must coincide )
public void showDiff(NgramModel other) {
        if (this.order != other.order) {
            throw new IllegalArgumentException("Illegal comparison "
                    + "of n-gram models with different n");
        }
        for (String s : this.occur.keySet()) {
            if (s.length() > 0) {
                int val1 = this.occur.get(s).getValue();
                int val2 = other.occur.containsKey(s)
                        ? other.occur.get(s).getValue() : 0;
                if (val1 != val2) {
                    System.out.println(s.replaceAll(String.valueOf(BOS), "<BoS>")
                            .replaceAll(String.valueOf(EOS), "<EoS>")
                            + " " + val1 + " " + val2);
                }
            }
        }
        for (String s : other.occur.keySet()) {
            if (s.length() > 0 && !this.occur.containsKey(s)) {
                int val2 = other.occur.get(s).getValue();
                System.out.println(s.replaceAll(String.valueOf(BOS), "<BoS>")
                        .replaceAll(String.valueOf(EOS), "<EoS>")
                        + " 0 " + val2);
            }
        }
    }
public void showDiff ( NgramModel other ) { if ( this . order != other . order ) { throw new IllegalArgumentException ( "Illegal comparison " + "of n-gram models with different n" ) ; } for ( String s : this . occur . keySet ( ) ) { if ( s . length ( ) > 0 ) { int val1 = this . occur . get ( s ) . getValue ( ) ; int val2 = other . occur . containsKey ( s ) ? other . occur . get ( s ) . getValue ( ) : 0 ; if ( val1 != val2 ) { System . out . println ( s . replaceAll ( String . valueOf ( BOS ) , "<BoS>" ) . replaceAll ( String . valueOf ( EOS ) , "<EoS>" ) + " " + val1 + " " + val2 ) ; } } } for ( String s : other . occur . keySet ( ) ) { if ( s . length ( ) > 0 && ! this . occur . containsKey ( s ) ) { int val2 = other . occur . get ( s ) . getValue ( ) ; System . out . println ( s . replaceAll ( String . valueOf ( BOS ) , "<BoS>" ) . replaceAll ( String . valueOf ( EOS ) , "<EoS>" ) + " 0 " + val2 ) ; } } }
Show differences between two NgramModels (debug function)
 @param other another NgramModel (order must coincide)
Show differences between two NgramModels ( debug function ) @param other another NgramModel ( order must coincide )