src/main/java/eu/digitisation/ngram/NgramModel.java
protected double smoothProb(String s) {
        double result;

        if (s.length() > 1) {
            if (s.charAt(0) == BOS && s.length() > 2) {
                result = smoothProb(s.substring(s.length() - 2, s.length()));
            } else {
                double lam = lambda(s.length() - 1);
                result = (1 - lam) * prob(s) + lam * smoothProb(tail(s));
            }
        } else {
            result = prob(s);
        }
        return result;
    }
/**
     * @param s a a non-empty string
     * @return the conditional probability of the string relative to its head,
     * and interpolated with lower-order models.
     */
@param s a a non-empty string
@return the conditional probability of the string relative to its head,
and interpolated with lower-order models.
@param s a a non - empty string @return the conditional probability of the string relative to its head and interpolated with lower - order models .
protected double smoothProb(String s) {
        double result;
        if (s.length() > 1) {
            if (s.charAt(0) == BOS && s.length() > 2) {
                result = smoothProb(s.substring(s.length() - 2, s.length()));
            } else {
                double lam = lambda(s.length() - 1);
                result = (1 - lam) * prob(s) + lam * smoothProb(tail(s));
            }
        } else {
            result = prob(s);
        }
        return result;
    }
protected double smoothProb ( String s ) { double result ; if ( s . length ( ) > 1 ) { if ( s . charAt ( 0 ) == BOS && s . length ( ) > 2 ) { result = smoothProb ( s . substring ( s . length ( ) - 2 , s . length ( ) ) ) ; } else { double lam = lambda ( s . length ( ) - 1 ) ; result = ( 1 - lam ) * prob ( s ) + lam * smoothProb ( tail ( s ) ) ; } } else { result = prob ( s ) ; } return result ; }
@param s a a non-empty string
 @return the conditional probability of the string relative to its head,
 and interpolated with lower-order models.
@param s a a non - empty string @return the conditional probability of the string relative to its head and interpolated with lower - order models .