Open ArlanCooper opened 3 years ago
Found a way to update the trie tree node
We could find the way to initailize the trie tree is adding a list of words to the marisa_trie.Trie
Just appending the new node(word) to the list, and update trie. This is how it works for me
if i want to insert new nodes,how can i insert into the trie? i can't find the methord of insert or add in the class?
@wyk201722 would you mind providing a minimal code :pray: ?
No sure I got what the "insert new node" mean in this question, but I tried in this way.
just attached a simple test here, there is no "balabala" in the word_list or trie initially. We appended it in to the word_list and then we "reinitialize" or "insert" the word_list with "balabala" to the trie. In the second prefix_search, we could find "balabala".
I was wondering whether the index of item in word_list would change the key value of the node in trie. Therefore, I tried another test insert another word "foo" into the second place in the word_list, and then update the trie. The result shows the key value of the node in trie is not related with the position/index of the word in word_list, but the sequence/order of word insertion.
Just modifing(insert/delete) the item in the list would update the nodes in trie. Hope this works for you.
Found a way to update the trie tree node We could find the way to initailize the trie tree is adding a list of words to the
marisa_trie.Trie
Just appending the new node(word) to the list, and update trie. This is how it works for meif i want to insert new nodes,how can i insert into the trie? i can't find the methord of insert or add in the class?
maybe not the best way. We need marisa-trie mostly because we can not afford for the memory usage of a keeping plain list.
if i want to insert new nodes,how can i insert into the trie? i can't find the methord of insert or add in the class?