26 if not name
or not candidates:
31 norm_matches = difflib.get_close_matches(norm_name,
48 msg +=
" Did you mean:"
49 for rec
in recommendations:
56 for cand
in sorted(candidates):
58 norm_candidates.setdefault(norm, []).append(cand)
59 return norm_candidates
63 for norm_match
in norm_matches:
64 candidates.extend(norm_candidates[norm_match])
76 cutoff = min_cutoff + len(string) * step
77 return min(cutoff, max_cutoff)
def format_recommendations(msg, recommendations)
Add recommendations to the given message.
def _get_original_candidates(self, norm_candidates, norm_matches)
def __init__(self, normalizer=None)
def _get_normalized_candidates(self, candidates)
def find_recommendations(self, name, candidates, max_matches=10)
Return a list of close matches to name from candidates.
def _calculate_cutoff(self, string, min_cutoff=.5, max_cutoff=.85, step=.03)
Calculate a cutoff depending on string length.