Question: Inside the file poetry _ generator.py , you have been provided with several functions that you will use to implement your poetry generator. 1 .

Inside the file poetry_generator.py, you have been provided with several functions that you will use to implement your poetry generator. 1. next_word_generator(), will generate a random word using the conditional frequency distribution derived from the bigrams in your selected corpus. You pass in a source word and the function will return a new word, such that the new word is one that frequently follows the source word in the corpus according to the relations in the CFD. For example, if you called the function like this: next_word_generator('to') then, it would return a new word. The selection is made proportional to the conditional frequency of all words in the corpus, conditioned on the source word to. If the source word argument is left out, then its value defaults to None. If the parameter has value None, then the function returns a new word randomly selected from the entire corpus. 2. count_syllables(), will return an integer representing the number of syllables in the word passed in as argument. For words that have multiple pronunciations with differing numbers of syllables, the function returns the max number of syllables for any pronunciation of that word. 3. get_rhymes(), takes a word as input and returns a list of words that rhyme with the input word. The list has been filtered so that it only includes words from the corpus. 4. get_stresses(), takes a word as input and returns a list of the patterns of stresses that can be used to pronounce the word. Some words can be pronounced in multiple ways, and each way will have a different pattern of stresses. Each element of the list is a string of numbers, one number per syllable in a

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!