-
Notifications
You must be signed in to change notification settings - Fork 557
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
fuzzy match for typoes #34
Comments
@cole-h and I did some work on this, and it seems like this feature might take a while, since none of the existing solutions for Rust seem to suit our purpose. |
Have you tried https://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance ? It considers transpositions. The strsim crate has a lot of useful stuff for this. :) |
@bbqsrc I have tried Levenshtein distance, but I haven't yet found a satisfactory way to apply it. The major problem is that the number of characters in a query is typically 3-4, so even one edit can significantly change the word. Moreover, there can be multiple words in a query which have to match the path in order. Allowing all of them to be fuzzy can sometimes significantly alter results. I do have a rough algorithm in mind, but I'd gladly appreciate any inputs! |
Note that Damerau-Levenshtein is a different algorithm derived from Levenshtein. You can introduce your own penalty weighting based on the distance of the result to device whether a 'typo' is sufficient to be considered the winner. You can also pass the decision to the user. I don't really have a convenient answer for your use case, unfortunately. But I'd be happy to provide feedback on any proposed algorithm, particularly if you can provide example cases of what you would hope the behaviour to be. My day to day work is basically in supporting linguistic tooling so I hope i can be of some use. xD |
@bbqsrc Thanks, that would be great! Regarding strsim, I don't think that fits my use case, since I'm trying to match a substring within the path, and I would require the last index of the match. I'll do some searching. I have a hectic week ahead, but I'll get back to you with something concrete as soon as I can. |
@NightMachinary, I'm not sure that is the kind of fuzzy matching we're looking for. I think this issue about fuzziness as a solution to minor spelling errors, where the correct spelling is one or two characters off the query. fzf expects each of the input characters to be present in the output in order (no errors), but allows an arbitrary number of characters in between each matching character. This works well for fzf as a selector, but I have my doubts about how well it will work for something like zoxide. According to me, there'd be a large number of paths in a typical database containing a All the same, you'd get similar results if you tried something like |
I think that if you add a penalty to their score for drifting edit distances, things will be fine even if the fuzziness leads to lots of matches? (Also, on my system, I currently have no match for Another interesting thing is to support a query like |
@NightMachinary fzf already does add a penalty to edit distance, but still I doubt it would work well outside of this isolated case. However, since zoxide matches each keyword in order in the path, matching against z sc ja |
Closing this - zoxide queries are almost always just a few characters long, and fuzzy matching would only lower their accuracy at this point. It also makes queries annoyingly unpredictable in the case where it's wrong. |
Sorry to bring this up again - but just raising the voice of us that uses zoxide differently. I'm never typing |
I'd also love such a feature. Especially because it's kind of annoying to rewrite the entire command just because of one small typo. You could only use fuzzy matching when there are no results. |
Maybe it could be configurable?
Also this |
@ajeetdsouza I decided to check in again. I have some really long directory names, and the whole point of a directory jumper is being lazy and not typing in a full path. I don't really get the logic. Can you reconsider? |
since this is the top search result for
zf () {
cd $(zoxide query --list --score | fzf --height 40% --layout reverse --info inline --border --preview "eza --all --group-directories-first --header --long --no-user --no-permissions --color=always {2}" --no-sort | awk '{print $2}')
} |
Can we do a search with levensteins distance with threshold incase when no results are found. This should keep zoxide as fast as it is now given a match exists. If not it can try and pick the closest one. Having used autojump all this time and Given how often i make typos this feature is indispensable. After all even if it slower than other algos, its still faster than me going back and editing my shell command. @ajeetdsouza |
Hi, I'm coming from using
autojump
after being recommended this from a coworker. I love the blazing speed of zoxide.Below are some examples for fuzzy matching.
( Note: you can see the echo that's mentioned in #22 )
I also miss
jo
(open matching directory. for mac this is something likeopen (zoxide query $argv) )
The text was updated successfully, but these errors were encountered: