vibes/levenshtein — pull request #1 by fojas (2012-07-09 16:59:33+00:00)
Title: added a fuzzy_search method that uses levenshtein distance to fuzzy search a string.

This allows searches that have exact matches inside the target string to have higher precedence than strings that have all the character matches, but less deletions.

example:
distance "foo", "f1o1o" # => 2
distance "foo", "foobar giraffe" # => 11

fuzzy_search "foo", "f1o1o" # => 0
fuzzy_search "foo", "foobar giraffe" # => -2

The fuzzy search returns a lower value, making it a better match. I'm not super happy about returning negative values to mean exact matches within the string, but it was the most performant way I could think of making this work.