Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import re
- def past_verb(word):
- suffix = "ed"
- path = "./rules.txt"
- rules = {}
- if os.path.isfile(path):
- f = open(path)
- words = f.read()
- words = words.split()
- else:
- return "rules.txt をダウンロードしてpast_verb.pyと同じフォルダに格納して下さい"
- for i in words:
- tmp = i.split(",")
- rules[tmp[0]] = tmp[1]
- if word in norules:
- suffix = ""
- word = rules[word]
- elif word[-1] == "e":
- suffix = "d"
- elif word[-1] == "p":
- suffix = word[-1] + suffix
- elif word[-1] == "y":
- word = word[:-1] + "i"
- res = word + suffix
- return res
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement