public double wordLogProb(String word) {
        double res = 0;

        // afegim el final de la paraula
        if (word.length() < 1) {
            System.err.println("Cannot compute probability of " + word);
            System.exit(1);
        } else {
            word = word + EOW;
        }

        // preparem l'inici dels ngrames
        String s = new String();
        while (s.length() < order) {
            s += BOW;
        }
        for (int last = 0; last < word.length(); ++last) {
            s = tail(s) + word.charAt(last);
            double p = backProb(s);

            if (p == 0) {
                System.err.println(s + " has 0 probability");
                return -100.0;
            } else {
                res += Math.log10(p);
            }
        }
        return res;
    }