Created
June 10, 2010 11:30
-
-
Save neilkod/432852 to your computer and use it in GitHub Desktop.
This file contains 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
# not my code but very similar to what i'm trying to accomplish | |
""" | |
Formula: | |
Na = number of set A elements | |
Nb = number of set B elements | |
Nc = number of common items | |
T = Nc / (Na + Nb - Nc) | |
""" | |
def tanimoto(a, b): | |
c = [v for v in a if v in b] | |
return float(len(c)) / (len(a)+len(b)-len(c)) | |
def name_compare(name1, name2): | |
return tanimoto(name1, name2) | |
>>> name_compare("James Brown", "Brown, James") | |
0.91666666666666663 | |
>>> name_compare("Berry Tsakala", "Bernard Tsakala") | |
0.75 | |
>>> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment