Skip to content

Commit d3bef26

Browse files
Merge pull request from ArtyomVancyan/master (GH-3)
2 parents e85f552 + 488b7aa commit d3bef26

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

fuzzymap.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@ class FuzzyMap(dict):
1212
does not match any of the keys by the given ratio, it returns `None`.
1313
"""
1414

15+
# set the minimum percent of the
16+
# diff between the compared keys
1517
ratio = 60
1618

1719
def closest_key(self, key):
1820
"""Returns the closest key matched by the given ratio"""
1921

2022
if len(self):
21-
# Calculate the ratio of each key using fuzzywuzzy
23+
# Calculate matching coefficient of each key via fuzz.ratio
2224
coefficients = {k: fuzz.ratio(k, key) for k in self.keys()}
2325
matching = max(coefficients, key=lambda k: coefficients[k])
2426
if coefficients[matching] > self.ratio:

0 commit comments

Comments
 (0)