Tomas-M / xlunch

Graphical app launcher for X with minimal dependencies
http://xlunch.org
GNU General Public License v3.0
219 stars 37 forks source link

Added a proposal for fuzzy search #47

Closed PMunch closed 6 years ago

PMunch commented 7 years ago

As discussed in issue #46 fuzzy searching could be a nice feature to have. This is an implementation of fuzzy searching which is both minimally obtrusive to the original data structure and works fairly well. The weighting is a bit random but from the tests I've tried it is rather robust. With the --fuzzysearch switch it will now use a mix between Levenshtein distance and a substring/starts-with check to award each entry a score and then sort them based on that score. This is all done in an auxiliary structure both for sorting speed reasons and to not change the original structure.

renkam commented 6 years ago

I've just tested this. It feels strange. With extra/sample_entries.dsv file and added -z flag to command from make test, I am getting following. When I type inl I get Terminal entry at front which is correct, but other entries are still visible, even that they don't have letter (small) 'L' in name. That is unexpected. IMHO those should be filtered out.

PMunch commented 6 years ago

Well, each entry is scored based on how close it is to the typed result. Then it is decided which entries should be shown based on the scores. The other two entries are simply close enough in overall score to all be shown. Note however that if you had the latest branch from this pr -z also takes a required argument, the keyword "trim" or something else. If you do -z "trim" then it will trim entries from the list, if -z "notrim" (or anything else really) is passed then it will not trim away entries. This also means that if you had -z -O for example "-O" would be considered the argument for -z.

renkam commented 6 years ago

Indeed option trim works as expected. I couldn't find this in --help output and didn't see in code. I'll try to glue this with reading *.desktop files and use for couple of days instead of dmenu and share my findings.

PMunch commented 6 years ago

It seems i forgot to add it to the documentation, thanks for noticing.

PMunch commented 6 years ago

@renkam what do you think? Have you had time to use it? This PR is straying further and further from the main branch so I would like to either get it merged or close it ASAP.

renkam commented 6 years ago

@PMunch Looks good to me. Last time I was playing with it was OK.