Guest User

Untitled

a guest
Dec 10th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. #!/usr/local/bin/python3
  2. #
  3. # Paul Evans (pevans@sandiego.edu)
  4. # 24 November 2018
  5. # 8 December 2018
  6. # 9 December 2018
  7. # 10 December 2018
  8. #
  9. import Levenshtein
  10. import re
  11. #
  12. def main():
  13. list_Sg = listify(re.split('\W', open('./Sg.txt', 'r').read()))
  14. list_edF = listify(re.split('\W', open('./edF.txt', 'r').read()))
  15. dedup(list_Sg, list_edF)
  16. #
  17. for Sg_word in list_Sg:
  18. for edF_word in list_edF:
  19. if (len(Sg_word) == len(edF_word)):
  20. if (Levenshtein.hamming(Sg_word, edF_word) == 1):
  21. print(Sg_word, edF_word)
  22. #
  23. def listify(words):
  24. list = []
  25. for word in words:
  26. if word:
  27. word = word.lower()
  28. if word not in list: # add it
  29. list.append(word)
  30. else:
  31. pass
  32. list.sort()
  33. return(list)
  34. #
  35. def dedup(list_A, list_B):
  36. dups = []
  37. for word in list_A:
  38. if word in list_B:
  39. dups.append(word)
  40. else:
  41. pass
  42. for dup in dups:
  43. list_A.remove(dup)
  44. list_B.remove(dup)
  45. #
  46. if __name__ == '__main__':
  47. main()
Add Comment
Please, Sign In to add comment