Created
January 25, 2013 11:50
-
-
Save fjavieralba/4633857 to your computer and use it in GitHub Desktop.
A simple but maybe useful distance definition for texts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from difflib import SequenceMatcher | |
def distance(url1, url2): | |
ratio = SequenceMatcher(None, url1, url2).ratio() | |
return 1.0 - ratio | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment