Fuzzywuzzy
Fuzzywuzzy is a native python fuzzy string matching library. It uses Levenshtein Distance to calculate the differences between sequences in a simple-to-use package.
Install
pip install fuzzywuzzy
Usage
Import
from fuzzywuzzy import fuzz
from fuzzywuzzy import process
Simple Ratio
fuzz.ratio("this is a test", "this is a test!")
# 97
Partial Ratio
fuzz.partial_ratio("this is a test", "this is a test!")
# 100
Process
choices = ["Atlanta Falcons", "New York Jets", "New York Giants", "Dallas Cowboys"]
process.extract("new york jets", choices, limit=2)
# [('New York Jets', 100), ('New York Giants', 78)]
process.extractOne("cowboys", choices)
# ("Dallas Cowboys", 90)