Search code examples
pythonalgorithmpython-2.7data-structurestrie

Why can't I add word in a trie via pygtrie?


I want to build a trie to record the phrases. Thus the unit is word instead of character. And I have found a promising implementation by google here. But according to their documentation, there is no add function. I wonder how can I add/insert a word into a trie? Thanks in advance!


Solution

  • This trie implementation provides the same interface as a dict. Your add function would simply be mytrie[key] = value.