@Override
    public void addWord(String word, int t) {
        int len = word.length();
        String aux = "";
        // Pes relatiu per a cada paraula:
        // tenim 2^(len-1) maneres de dividir una paraula
        //double weight = Math.pow(2, len - 1);
        // normalitzem per a totes les paraules
        //weight = weight / Math.pow(2,len);
        // weight = 2^(len-1) / 2^(len) = 2^(len-1-len) = 2^(-1) = 1/2
        double weight = 0.5 * t;


        int max_len = len;
        if(this.length>0)
            max_len = Math.min(len,this.length);

        // hi ha 2^(len-1) * (len+2) segments possibles
        I.addTimes(weight * (len + 2));
        I.addRestart(EOW, weight);
        for (int i = 0; i < len; ++i) {
            State q = I;
            double w = (i == 0) ? 2 * weight : weight;
            int j = i;
            for (; j < max_len; ++j) {
                Character c = word.charAt(j);
                w *= 0.5;
                q.addRestart(c, w);
                aux = q.getName();
                q = safeNext(q, c);
                q.setName(aux + c);
                q.addTimes(w);
            }
            if(max_len < len)
                q.addRestart(word.charAt(j), w);
            else
                q.addRestart(EOW, w);
        }
    }