src/main/java/eu/digitisation/ngram/NgramModel.java
public double logProb(String context, char c) {
        double res = 0;
        int len = context.length() + 1; // the length of the context + character
        String s = (len > order)
                ? context.substring(len - order) + c
                : context + c;
        double p = smoothProb(s);

        return (p > 0)
                ? Math.log(p)
                : Double.NEGATIVE_INFINITY;
    }
/**
     * Compute probability of a character after a given context. This
     * implementation only takes into account the preceding context
     *
     * @param context a sequence of characters
     * @param c a character
     * @return the log-probability (base e) that the character c follows the
     * given context
     */
Compute probability of a character after a given context. This
implementation only takes into account the preceding context

@param context a sequence of characters
@param c a character
@return the log-probability (base e) that the character c follows the
given context
Compute probability of a character after a given context . This implementation only takes into account the preceding context @param context a sequence of characters @param c a character @return the log - probability ( base e ) that the character c follows the given context
public double logProb(String context, char c) {
        double res = 0;
        int len = context.length() + 1; 
        String s = (len > order)
                ? context.substring(len - order) + c
                : context + c;
        double p = smoothProb(s);
        return (p > 0)
                ? Math.log(p)
                : Double.NEGATIVE_INFINITY;
    }
public double logProb ( String context , char c ) { double res = 0 ; int len = context . length ( ) + 1 ; String s = ( len > order ) ? context . substring ( len - order ) + c : context + c ; double p = smoothProb ( s ) ; return ( p > 0 ) ? Math . log ( p ) : Double . NEGATIVE_INFINITY ; }
Compute probability of a character after a given context.
Compute probability of a character after a given context .
// the length of the context + character