We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents e85f552 + 488b7aa commit d3bef26Copy full SHA for d3bef26
fuzzymap.py
@@ -12,13 +12,15 @@ class FuzzyMap(dict):
12
does not match any of the keys by the given ratio, it returns `None`.
13
"""
14
15
+ # set the minimum percent of the
16
+ # diff between the compared keys
17
ratio = 60
18
19
def closest_key(self, key):
20
"""Returns the closest key matched by the given ratio"""
21
22
if len(self):
- # Calculate the ratio of each key using fuzzywuzzy
23
+ # Calculate matching coefficient of each key via fuzz.ratio
24
coefficients = {k: fuzz.ratio(k, key) for k in self.keys()}
25
matching = max(coefficients, key=lambda k: coefficients[k])
26
if coefficients[matching] > self.ratio:
0 commit comments