Jump to content

Fuzzy filtering


dfay
 Share

Recommended Posts

FWIW, I've been thinking about writing a command-line program that replaces "Alfred Filters Results" with a fuzzy algorithm. Probably the one I use in my Go library, which is based on Forrest Smith's algorithm plus diacritic folding.

 

You'd use it like this:

./fuzzy --query "$1" /usr/bin/python myscript.py

where the arguments are the command to run. It'd capture the JSON output by your script (and cache it for the session), filter the items against a keyword field (or title if that's missing), then pass the filtered JSON on to Alfred.

 

What do you think?

Edited by deanishe
Link to comment
Share on other sites

If it's written in Swift/ObjC (which it would have to be, imo), the difference in speed wouldn't be particularly noticeable in most cases. The workflow would likely be the speed bottleneck in most cases (unless that's also written in a compiled language).

 

Native would of course be better, but I don't know if Andrew would go for it. Fuzzy search is massively slower than Alfred's "word starts with" search, and Andrew is all about speed.

 

On my machine, Alfred can easily handle ~50k items. My fuzzy search (in Go) can handle about a fifth of that. (In both cases, "handle" means "filter in well under a second".)

 

Even if 10k results filtered in under a second sounds awesome fast, we're still talking about putting a toggle into Alfred that would make search 4-5X slower.

Edited by deanishe
Link to comment
Share on other sites

Hmm. I think that would still be a lot faster than many script filters that pull results off the net.  On reflection, I think the approach you describe is quite good b/c it would require next  to no modification of existing workflows.

Link to comment
Share on other sites

Going by the workflows I've written in Go, I think it would be perceptibly, but insignificantly, slower than "Alfred Filters Results" in most cases (i.e. not thousands and thousands or results).

 

And yeah, the main thing would be that it's super-easy to add to your workflow. The top-level variables Andrew recently added to the feedback are essentially "session" variables, so I can use those to run the workflow once and cache the results only as long as the user is using the workflow (like Alfred does).

 

That's the key to making is simple to add.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...