code: function trainTriples(words) {
    var probs = {};
    var count = 0;
  
    words.forEach(function(w) {
      w = clean(w);
  
      for (var i = 0; i < w.length - 2; i++) {
        if (!probs[w[i]]) probs[w[i]] = {};
        if (!probs[w[i]][w[i + 1]]) probs[w[i]][w[i + 1]] = {};
        if (!probs[w[i]][w[i + 1]][w[i + 2]]) probs[w[i]][w[i + 1]][w[i + 2]] = 1;
        else probs[w[i]][w[i + 1]][w[i + 2]]++;
        count++;
      }
    });
  
    Object.keys(probs).forEach(function(first) {
      Object.keys(probs[first]).forEach(function(second) {
        Object.keys(probs[first][second]).forEach(function(third) {
          probs[first][second][third] = percent(
            probs[first][second][third],
            count
          );
        });
      });
    });
  
    return probs;
  }
docs: Extract probabilities of word triples.