tsul
0
Q:

approximate string matching python

from fuzzywuzzy import process
str2Match = "apple inc"
strOptions = ["Apple Inc.","apple park","apple incorporated","iphone"]
Ratios = process.extract(str2Match,strOptions)
print(Ratios)
# You can also select the string with the highest matching percentage
highest = process.extractOne(str2Match,strOptions)
print(highest)
1
#Installation
pip install fuzzywuzzy

#import
from fuzzywuzzy import fuzz

# Compare whole 2 strings
fuzz.ratio("Catherine M Gitau","Catherine Gitau")
#91

# Compares only untill the length of smallest string,
# In below case strings that will be compared are, "Catherine M. Gi" & "Catherine Gitau" 
fuzz.partial_ratio("Catherine M. Gitau","Catherine Gitau")
#100
0

New to Communities?

Join the community