Skip to content

Instantly share code, notes, and snippets.

@jaradc
Last active September 23, 2019 17:30
Show Gist options
  • Save jaradc/14c1aa7bbb6ba3bf915ec0b055125185 to your computer and use it in GitHub Desktop.
Save jaradc/14c1aa7bbb6ba3bf915ec0b055125185 to your computer and use it in GitHub Desktop.
import difflib
"""
This simple piece of code can help detect similar strings using SequenceMatcher
"""
data = ['temporary tatoos', 'temporary tatto', 'tempoary tatoo', 'tempoary tattoo', 'temporary tattoos']
for line in data:
for word in line.split():
i = difflib.SequenceMatcher(None, word, 'tattoo').ratio()
if i > 0.6:
print(word, i)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment