dhp.search¶
fuzzy_search¶
given a list of strings(haystack) to search, return those elements, ranked, that fuzzily match the search term(needle).
-
fuzzy_search
(needle, haystack)¶ return a ranked list of elements from haystack that fuzzily match needle
Parameters: - needle – what you are searching to find
- haystack – list of things to search
Return type: ranked sublist of haystack elements matching needle
from dhp.search import fuzzy_search
haystack = ['.bob', 'bob.', 'bo.b', 'fred']
assert fuzzy_search(needle='bob', haystack) == ['bob.', '.bob', 'bo.b']
Use case: create a “Sublime Text” like search experience