Python fuzzy string comparison

Fuzzy string comparison

>>> import difflib
>>> s=difflib.SequenceMatcher(None, "abcd","bcde")
# Return a measure of the sequences’ similarity as a float in the range [0, 1].
# This is 1.0 if the sequences are identical, and 0.0 if they have nothing in common.
>>> print s.ratio()
0.75

Bibliography

  1. http://stackoverflow.com/questions/682367/good-python-modules-for-fuzzy-string-comparison
  2. http://docs.python.org/library/difflib.html
Avatar
Andreas Maier
Data Alchemist

My interests include machine learning, software development, physics and mathematics

Related