#pip install fuzzywuzzy
from fuzzywuzzy import process
candidate = ["Atlanta Falcons", "New York Jetss", "New York Giants", "Dallas Cowboys"]search = "new york jets"
r1 = process.extract(search, candidate)
#r1 = process.extract(search, candidate, limit=3)
search = "cowboys"r2 = process.extractOne(search, candidate)
search = "new york jets"r3 = process.extractBests(search, candidate, score_cutoff=70)
print(r1)#[('New York Jetss', 96), ('New York Giants', 79), ('Atlanta Falcons', 29), ('Dallas Cowboys', 22)]
print(r2)#('Dallas Cowboys', 90)
print(r3)#[('Dallas Cowboys', 90)]
No comments:
Post a Comment