Skip to content

Instantly share code, notes, and snippets.

@jacobian
Created February 21, 2012 21:03
Show Gist options
  • Save jacobian/1878924 to your computer and use it in GitHub Desktop.
Save jacobian/1878924 to your computer and use it in GitHub Desktop.
# stuff = {'term': (title, url)}
# e.g. {'RequestFactory',: ('django.test.client.RequestFactory/', 'http://...'), ...}
def find(term):
score, found = 0, None
for candidate in stuff:
cand_score = stringslipper.score(candidate.lower(), term)
if cand_score > score:
score = cand_score
found = (candidate, stuff[candidate])
return score, found
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment