Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
61 lines (44 sloc) 1.35 KB
# coding: utf-8
# In[ ]:
import pycorpora
import random
import pronouncing
def get_words(pos):
if (pos is "adjs"):
all_words = pycorpora.words.adjs["adjs"]
elif (pos is "verbs"):
all_words = [w["present"] for w in pycorpora.words.verbs["verbs"]]
keepers = []
#created fuctions to draw words from pycorpora adjective and verb lists
for n in all_words:
pl = pronouncing.phones_for_word(n)
if (len(pl) > 0):
syllablecount = pronouncing.syllable_count(pl[0])
if (syllablecount == 1):
return keepers
#making sure the meter stayed consistent
def get_pairs():
adjs = get_words("adjs")
verbs = get_words("verbs")
for a in adjs:
for v in verbs:
if (a in pronouncing.rhymes(v)):
pairs.append( (a,v))
return pairs
#creating adj/verb pairs that rhyme from the list, my list came up with a lot of pairs!!!!
template = """
It is full winter now: the trees are {0},
Save where the cattle huddle from the cold
Beneath the pine, for it doth never {1}
The autumn's gaudy livery whose gold
Her jealous brother pilfers, but is true
To the green doublet; bitter is the wind, as though it blew
pair = random.choice(get_pairs())
poem = template.format(
print (poem)