Getting the closest string match

后端 未结 13 897
难免孤独
难免孤独 2020-11-22 10:57

I need a way to compare multiple strings to a test string and return the string that closely resembles it:

TEST STRING: THE BROWN FOX JUMPED OVER THE RED COW         


        
13条回答
  •  无人共我
    2020-11-22 11:29

    You might be interested in this blog post.

    http://seatgeek.com/blog/dev/fuzzywuzzy-fuzzy-string-matching-in-python

    Fuzzywuzzy is a Python library that provides easy distance measures such as Levenshtein distance for string matching. It is built on top of difflib in the standard library and will make use of the C implementation Python-levenshtein if available.

    http://pypi.python.org/pypi/python-Levenshtein/

提交回复
热议问题