我想构建一个 trie 来记录短语。因此单位是单词而不是字符。我通过谷歌找到了一个很有前途的实现 here .但是根据他们的documentation , 没有 add
功能。我想知道如何在 trie 中添加/插入单词?提前致谢!
最佳答案
此 trie 实现提供与 dict 相同的接口(interface)。您的 add
函数将只是 mytrie[key] = value
。
关于python - 为什么我不能通过 pygtrie 在 trie 中添加单词?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42875886/