Skip to content

Instantly share code, notes, and snippets.

@lukealbao
Created February 11, 2015 17:38
Show Gist options
  • Save lukealbao/692a87f6ca02279e86f7 to your computer and use it in GitHub Desktop.
Save lukealbao/692a87f6ca02279e86f7 to your computer and use it in GitHub Desktop.
Substrings contained in a string
def build_candidates(input_string, lexicon=LEXICON):
code = encode(''.join(re.findall('[a-z]+', input_string.lower())))
d = {}
for word in lexicon:
_code = lexicon.encoded(word)
if code % _code == 0:
d[word] = lexicon[word]
return d.keys()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment