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 poetrygenerator.py you have been provided with several functions that you will use to implement your poetry generator. nextwordgenerator 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: nextwordgeneratorto 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. countsyllables 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. getrhymes 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. getstresses 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
