Someone
public text v1 · immutable
def jaccardsim(s1, s2): #s1 and s2 are strings
#Approach: Count the number of common elements, then divide by the union
uniqueset = []
commonset = []
for i in range(0, len(s1)):
if (not(s1[i] in uniqueset)):
uniqueset.append(s1[i])
if ((s1[i] in s2) and not(s1[i] in commonset)):
commonset.append(s1[i])
for j in range(0, len(s2)):
if not(s2[j] in uniqueset):
uniqueset.append(s2[j])
return len(commonset)/float(len(uniqueset))