fix conjugation of verbs ending in `e`, move the conjugation to a separate file
This commit is contained in:
parent
b0d072bbf2
commit
3c26fcf701
|
@ -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
|
14
ljfbot.py
14
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)
|
||||
|
|
Loading…
Reference in New Issue