question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Possible to walk the trie?

See original GitHub issue

I don’t see any methods that would allow for just proceeding one edge in the trie, for example:

trie = marisa_trie.Trie([u'key1', u'key2', u'kite'])
trie.edges('k') #would return [u'ke', u'ki']

Using the prefixes method for something like this would be very expensive if the trie is big and the prefix is short. Is there some technical detail I’m missing for why implementing a function for this would be costly, or some other reason this isn’t implemented? It seems like it’s a necessary step in the traversal with the prefixes() method anyway, and quite useful for predictive lookup operations.

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jstypkacommented, Nov 27, 2015

Actually, this is the second time that this feature would be very useful to me, so I thought I might mention it here. I also looked through other Python trie libraries (PyTrie, patricia-trie, python-trie) and neither of them support this.

My usecase (which I would expect to be not that rare) is walking down the tree while computing Levenshtein distance, I use it for fuzzy matches similar to @EliFinkelshteyn.

0reactions
EliFinkelshteyncommented, Mar 14, 2015

Alright, I’ll investigate a bit more, and if it still looks useful, I’ll send over a PR. Closing the issue out here, since it’d be much easier to do for DAWG than the Marisa-Trie.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bottom-up traversal of a Trie - GeeksforGeeks
The idea to do this is to start traversing from the root node of the trie, whenever we find a NON-NULL child node,...
Read more >
Trie Data Structure in C/C++ - DigitalOcean
A Trie data structure acts as a container for a dynamic array. In this article, we shall look at how we can implement...
Read more >
Trie - Wikipedia
In computer science, a trie, also called digital tree or prefix tree, is a type of k-ary search tree, a tree data structure...
Read more >
Trie Data Structure - Medium
Insertion begins by starting at the root node of the tree and walking through the Trie according the string that is being inserted....
Read more >
Iteratively Construct Trie from a Tree - clojure - Stack Overflow
I would propose to take a look at clojure's walk api. It allows you to recursively apply some function to nested collections. In...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found