Advertisement
tungSfer

jaccard

Jan 16th, 2022
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.35 KB | None | 0 0
  1. import re
  2.  
  3. s1 = input()
  4. s2 = input()
  5. s1 = s1.lower()
  6. s2 = s2.lower()
  7. s1 = re.sub("[\s+,.?]", "", s1)
  8. s2 = re.sub("[\s+,.?]", "", s2)
  9. list1 = list(s1)
  10. list2 = list(s2)
  11. # print(list1)
  12. # print(list2)
  13. set1 = set(list1)
  14. set2 = set(list2)
  15. af1 = list(set1.intersection(set2))
  16. af2 = list(set1.union(set2))
  17. print("{:.2f}".format(len(af1) / len(af2)))
  18.  
  19.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement