public double wordProb(String word) {
        double ret = 1;

        if(backoff) {
            int i = 0;
            current = first;
            word = fullWord(word);
            for (char c : word.toCharArray()) {
                if(!alfabet.contains(""+c)) ret *= EPSILON;

                if(!current.hasConnection(""+c)) {
                    current = nextState("" + c);
                }
                ret *= current.prob("" + c);
                current = nextState("" + c);
            }
        } else {
            int i = 0;
            current = first;
            word = fullWord(word);
            for (char c : word.toCharArray()) {
                if(!alfabet.contains(""+c)) ret *= EPSILON;
                
                ret *= current.prob("" + c);
                current = nextState("" + c);
            }
        }
        return ret;
    }