Skip to content

Instantly share code, notes, and snippets.

@lambdaman2
Created October 1, 2012 12:48
Show Gist options
  • Select an option

  • Save lambdaman2/3811584 to your computer and use it in GitHub Desktop.

Select an option

Save lambdaman2/3811584 to your computer and use it in GitHub Desktop.
Python: Statistical String Comparison
>>> import difflib
>>> difflib.SequenceMatcher(None, 'abcde', 'abcde').ratio()
1.0
>>> difflib.SequenceMatcher(None, 'abcde', 'zbcde').ratio()
0.80000000000000004
>>> difflib.SequenceMatcher(None, 'abcde', 'zyzzy').ratio()
0.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment