Navigation

  • index
  • modules |
  • next |
  • previous |
  • dhp 0.0.15 documentation »

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

Table Of Contents

  • dhp.search
    • fuzzy_search

Previous topic

dhp.math

Next topic

dhp.structures

This Page

  • Show Source

Quick search

Enter search terms or a module, class or function name.

Navigation

  • index
  • modules |
  • next |
  • previous |
  • dhp 0.0.15 documentation »
© Copyright 2016, Jeff Hinrichs. Created using Sphinx 1.3.5.