diff --git a/conjugate.py b/conjugate.py new file mode 100644 index 0000000..d5725be --- /dev/null +++ b/conjugate.py @@ -0,0 +1,13 @@ +def conjugate(verb): + if verb[-2:] == 'ed' and verb[-3] not in {'a', 'e', 'i', 'o', 'u'}: + verb = verb[:-2] + if verb[-1] in {'a', 'i', 'o', 'u'}: + verb = verb + 'es' + elif verb[-1] != 'e' and (verb[-1] in {'s', 'x'} or verb[-2] in {'s', 'x'} or verb[-2:] == 'ch'): + verb = verb + 'es' + elif verb[-1] == 'y' and verb[-2] not in {'a', 'e', 'i', 'o', 'u'}: + verb = verb[:-1] + 'ies' + else: + verb = verb + 's' + + return verb diff --git a/ljfbot.py b/ljfbot.py index f89c1ce..2a51b15 100755 --- a/ljfbot.py +++ b/ljfbot.py @@ -1,8 +1,8 @@ #!/usr/bin/env python import random +from conjugate import conjugate from mastodon import Mastodon -import os import json5 as json with open('config.json') as f: @@ -25,17 +25,7 @@ postform = random.choice(( '{gender} who {verb}', )) gender = random.choice(('lgf', 'lbf', 'lef')) -verb = random.choice(verbs) -if verb[-2:] == 'ed' and verb[-3] not in {'a', 'e', 'i', 'o', 'u'}: - verb = verb[:-2] -if verb[-1] in {'a', 'i', 'o', 'u'}: - verb = verb + 'es' -elif verb[-1] in {'s', 'x'} or verb[-2] in {'s', 'x'} or verb[-2:] == 'ch': - verb = verb + 'es' -elif verb[-1] == 'y' and verb[-2] not in {'a', 'e', 'i', 'o', 'u'}: - verb = verb[:-1] + 'ies' -else: - verb = verb + 's' +verb = conjugate(random.choice(verbs)) adjective = random.choice(adjectives) content = postform.format(adjective=adjective, gender=gender, verb=verb) print(content)