Last active
August 29, 2015 14:05
-
-
Save olslash/6cc6859e53d19a45e174 to your computer and use it in GitHub Desktop.
T9 blogpost - 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Trie.prototype.insert = function(word, useFrequency) { | |
// Traverse the tree to the node where the word should be inserted. If any | |
// needed nodes do not exist along the way, they are created. | |
var nodeToAddWord = traverseAddingNodes(this); | |
// Insert the word into the wordlist of the node returned above. Use the | |
// data provided (frequency of use in English text) to place the word in | |
// the correct position, so that we can recommend more common words first. | |
insertWordIntoListByFrequency(nodeToAddWord.words, word, useFrequency); | |
function traverseAddingNodes(node) { | |
// ... | |
} | |
function insertWordIntoListByFrequency(list, word, useFrequency) { | |
// ... | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment