Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. import os
  2. import re
  3.  
  4. def past_verb(word):
  5. suffix = "ed"
  6. path = "./rules.txt"
  7. rules = {}
  8.  
  9. if os.path.isfile(path):
  10. f = open(path)
  11. words = f.read()
  12. words = words.split()
  13. else:
  14. return "rules.txt をダウンロードしてpast_verb.pyと同じフォルダに格納して下さい"
  15.  
  16. for i in words:
  17. tmp = i.split(",")
  18. rules[tmp[0]] = tmp[1]
  19.  
  20. if word in norules:
  21. suffix = ""
  22. word = rules[word]
  23. elif word[-1] == "e":
  24. suffix = "d"
  25. elif word[-1] == "p":
  26. suffix = word[-1] + suffix
  27. elif word[-1] == "y":
  28. word = word[:-1] + "i"
  29.  
  30. res = word + suffix
  31. return res
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement