FuzzyWuzzy

Fuzzy string matching for Python


In [ ]:
from fuzzywuzzy import fuzz

In [ ]:
fuzz.ratio('this is a test', 'this is a test!')

In [ ]:
fuzz.partial_ratio('this is a test', 'this is a test!')

In [ ]:
fuzz.token_sort_ratio('fuzzy wuzzy was a bear', 'wuzzy fuzzy was a bear')

In [ ]:
fuzz.token_sort_ratio('fuzzy wuzzy was a bear', 'wuz fuzz was a bear')

In [ ]:
from fuzzywuzzy import process

In [ ]:
choices = ['Atlanta Falcons', 'New York Jets', 'New York Giants', 'Dallas Cowboys']

In [ ]:
process.extract('new york jets', choices, limit=2)

In [ ]:
process.extract('jets', choices, limit=2)

In [ ]:
process.extractOne('cowboys', choices)

In [ ]:
with open('colors.txt') as colorfile:
    colors = [l.strip() for l in colorfile.readlines()]
colors[:10]

In [ ]:
process.extractOne('mavue', colors)

In [ ]:
process.extract('purple, green, and blue', colors)