41 lines
847 B
Python
41 lines
847 B
Python
import re
|
|
|
|
line = input().strip()
|
|
|
|
sylcounts = [5, 7, 5]
|
|
|
|
words = re.findall('[a-zA-Z]+', line)
|
|
originals = line.split()
|
|
final = ''
|
|
|
|
for word, original in zip(words, originals):
|
|
word = word.lower().replace('qu', 'q')
|
|
word = re.sub('y[aoeui]', 'b', word)
|
|
|
|
if re.match('.*e$', word) and not re.match('.*[^aoeuiy]le$', word):
|
|
word = word[:-1]
|
|
|
|
if re.match('.*es$', word) and not re.match('.*[^aoeuiy][^aoeuiy]es', word):
|
|
word = word[:-2]
|
|
|
|
word = re.sub('[aoeuiy]+', 'A', word)
|
|
|
|
syllables = word.count('A') or 1
|
|
|
|
sylcounts[0] -= syllables
|
|
final += original + ' '
|
|
|
|
if sylcounts[0] == 0:
|
|
del sylcounts[0]
|
|
final = final[:-1] + '\n'
|
|
continue
|
|
if sylcounts[0] < 0:
|
|
final = line
|
|
sylcounts = []
|
|
break
|
|
|
|
if sylcounts:
|
|
final = line
|
|
|
|
print(final.strip())
|