pytries / marisa-trie

Static memory-efficient Trie-like structures for Python based on marisa-trie C++ library.
https://marisa-trie.readthedocs.io/en/latest/
MIT License
1.03k stars 91 forks source link

Added Prefix Function #15

Closed KCzar closed 1 year ago

KCzar commented 9 years ago

A frequent use of Tries - and one of the primary benefits of the Trie structure - is the ability to find the longest prefix match. Here I add a "prefix" function to only return the longest match in a more efficient manner than storing the entire list of prefixes, then selecting the longest match (which, now that I've seen the implementation of the prefixes function, would always be the last item in the list).

I'm working towards using this package for bulk find replace. Would there be any interest in adding such a thing to this package? Let me know.

BoboTiG commented 3 years ago

Edit: no need to work on the fork. If you are still interested, just update the PR.


Hello @KCzar,

I know it is quite late but I would be OK to merge such feature into https://github.com/BoboTiG/marisa-trie ;)

BoboTiG commented 3 years ago

ℹ️ If someone wants to work on it, I would love to see tests as well :)