How fuzzy is get_close_matches() in difflib?

John Henry john106henry at hotmail.com
Thu Nov 16 23:19:50 EST 2006


I did try them and I am impressed.  It helped me found a lot of useful
info.   I just want to get a feel as to what constitutes a "match".


Steven D'Aprano wrote:
> On Thu, 16 Nov 2006 16:40:49 -0800, John Henry wrote:
>
> > I am just wondering what's with get_close_matches() in difflib.  What's
> > the magic?   How fuzzy do I need to get in order to get a match?
>
>
> Why don't you try it and see?
>
> >>> from difflib import get_close_matches
> >>> get_close_matches("appel", ["ape", "apple", "peach", "puppy"])
> ['apple', 'ape']
> >>> import keyword as _keyword
> >>> get_close_matches("wheel", _keyword.kwlist)
> ['while']
> >>> get_close_matches("apple", _keyword.kwlist)
> []
> >>> get_close_matches("accept", _keyword.kwlist)
> ['except']
>
>
> Those example, by the way, come from here:
> 
> >>> help(get_close_matches)
> 
> 
> 
> 
> -- 
> Steven




More information about the Python-list mailing list