-
-
Notifications
You must be signed in to change notification settings - Fork 87
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
Add fuzzy-matching for autocomplete #601
Comments
Hey @tconbeer - this program is awesome! thanks for making it! I'm really keen to have fuzzy-matching, i often don't know what column names are in my database, so i rely on fuzzy matching (in tools like dbeaver) to get them for me. Would it be as simple as changing the line here for what constitutes a matched completion option? I'd imagine, for fuzzy matching, everything would have a "score" which you could threshold.. or maybe, you'd just sort all options by the score (so that the list will be everything but the most likely options are near the top) This could be quite slow in straight python... do you have any rules / guidelines for adding in C libs into the application? FZF comes to mind. This might turn out to be a simple change, that I can have a look at doing if you would like.. I'm not sure what the difference between word and member completion classes are though 😅 |
Yes, you're on the right track there. To answer your questions:
self._query_regex = compile(
".{0,5}?".join(f"({escape(character)})" for character in query),
flags=0 if case_sensitive else IGNORECASE,
) |
Hey there! I crunched some of the numbers (extracted the values from WordCompleter.completions) And made 2 simple options for the fuzzy find, one that is pretty much the implementation you posted (2 characters instead of 5 as max intermediates) and one that also adds So for "sele", the expression would be:
For the word "select": if lets say ... I want to find the column "europe_sales" and I query "sale" sooo ... I think none of these cases is slow beyond being usable but there might be tradeoffs depending on what you want out of them. LMK if you want me to write the PR and if you have a preference on the implementation! [I also thought about potential 'hybrid' options ... like using the regex only if there are no suggestions on an exact match ... which might be a happy medium where you pay 100us for mis-typing the first character] functions code used for the test:
|
ESPECIALLY for member autocomplete (fuzzy-matching table and column names, etc.).
The text was updated successfully, but these errors were encountered: