Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for substring search #2

Closed
jacobdufault opened this issue Apr 26, 2017 · 1 comment
Closed

Support for substring search #2

jacobdufault opened this issue Apr 26, 2017 · 1 comment

Comments

@jacobdufault
Copy link

Great project! I'd like to use it in cquery for faster global symbol search; is it possible to add substring search, ie, the search Foo matches the string void Foo()? equal_prefix_range comes close but will not match because of the preceding void.

(Even better would be a fuzzy search, ie, vF matches void Foo(), or a custom match function, but I suspect that's out of scope).

@Tessil
Copy link
Owner

Tessil commented Apr 26, 2017

It would be difficult, the HAT-trie is designed to be a prefix tree. What you need is a suffix tree or suffix array.

You could easily use the HAT-trie if you only want to know if a substring is in the tree. For example, instead of just inserting "foobar" in the tree, you would also add "oobar", "obar", "bar", "ar" and "a". Then you could do equal_prefix_range("oo") and if the range is not empty you know there is a string with "oo" inside the tree (but not which original one, the range would return "oobar"). It could be possible to keep track of the list of strings the suffix belongs too, but I think it's more efficient to go with a suffix array instead.

Concerning the fuzzy-search you may look into metric trees.

@Tessil Tessil closed this as completed Apr 28, 2017
This was referenced Mar 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants