def best_scoring_value(self, groups):
'''
Finds best fuzzy match
Compares each elem of the group with each keyphrase/word in loc_map
Returns the location with best matching
'''
best_match = ''
best_score = 0
groups = list(groups)
# Append the whole of the group to the things to be checked
# For instance, for the group ('a', 'b'), 'a b' will also be matched
groups.append(' '.join(groups))
for g in groups:
for key in self.loc_map:
if fuzz.ratio(key, g) > best_score:
best_score = fuzz.ratio(key, g)
best_match = self.loc_map[key]
return best_match
评论列表
文章目录