src/main/java/eu/digitisation/ngram/NgramModel.java
public double logLikelihood(String context, String input) {
        int contextLength = context.length();
        double loglike = 0;
        for (int pos = 0; pos < input.length(); ++pos) {
            String s;
            if (pos >= contextLength) {
                s = input.substring(pos - contextLength, pos + 1);
            } else {
                s = context.substring(pos)
                        + input.substring(0, pos + 1);
            }
            loglike += Math.log(smoothProb(s));
        }
        return loglike;
    }
/**
     *
     * @param context the preceding context
     * @param input a non-empty string
     * @return the log probability of the string after the given context
     */
@param context the preceding context
@param input a non-empty string
@return the log probability of the string after the given context
@param context the preceding context @param input a non - empty string @return the log probability of the string after the given context
public double logLikelihood(String context, String input) {
        int contextLength = context.length();
        double loglike = 0;
        for (int pos = 0; pos < input.length(); ++pos) {
            String s;
            if (pos >= contextLength) {
                s = input.substring(pos - contextLength, pos + 1);
            } else {
                s = context.substring(pos)
                        + input.substring(0, pos + 1);
            }
            loglike += Math.log(smoothProb(s));
        }
        return loglike;
    }
public double logLikelihood ( String context , String input ) { int contextLength = context . length ( ) ; double loglike = 0 ; for ( int pos = 0 ; pos < input . length ( ) ; ++ pos ) { String s ; if ( pos >= contextLength ) { s = input . substring ( pos - contextLength , pos + 1 ) ; } else { s = context . substring ( pos ) + input . substring ( 0 , pos + 1 ) ; } loglike += Math . log ( smoothProb ( s ) ) ; } return loglike ; }
@param context the preceding context
 @param input a non-empty string
 @return the log probability of the string after the given context
@param context the preceding context @param input a non - empty string @return the log probability of the string after the given context