code: function Spellcheck(wordlist) {
      this.trie = new Trie();
      this.trie.addStrings(wordlist);
      this.word2frequency = {};
      for(var i in wordlist) {
          if(!this.word2frequency[wordlist[i]]) {
              this.word2frequency[wordlist[i]] = 0;
          }
          this.word2frequency[wordlist[i]]++;
      }
  }
docs: Probabilistic spellchecker based on http://norvig.com/spell-correct.html The general idea is simple. Given a word, the spellchecker calculates all strings that are some user-defined edit distance away. Of those many candidates, it filters the ones that are not words and then returns an array of possible corrections in order of decreasing probability, based on the edit distance and the candidate's frequency in the input corpus Words that are an edit distance of n away from the mispelled word are considered infinitely more probable than words that are of an edit distance >n wordlist is a corpus (an array) from which word probabilities are calculated (so something like /usr/share/dict/words (on OSX) will work okay, but real world text will work better)