Question: Question 6 . 5 . Now that we know how to generate titles based on pairs of words, let's write a function that takes no
Question Now that we know how to generate titles based on pairs of words, let's write a function that takes no inputs, and returns a randomly generated title by starting with the word 'The' then adding a new word based on the conditional probabilities of words that can follow 'The'. We'll continue adding new words after each previous word, until we encounter a word that never had any words after it in an episode title like 'Proposes' in our example above At that point, we'll stop generating new words.
Since we don't know how many words we'll be adding in advance, it's hard to implement this with a for loop, since we don't know how many iterations we'll need. Instead, we'll use what's known as a while loop, which runs continuously, with as many iterations as needed, until some stopping condition is met. In our case, we'll keep adding new words as long as the DataFrame returned by findprobdist has at least one row, since that means there are more words we can add to our title. Our stopping condition, therefore, is when findprobdist produces a DataFrame with no rows.
We've implemented the while loop for you. Your task is to fill in the missing lines so that generatetitle returns a randomly generated episode title. Some comments are included to help you.File tmpipykernelpy line generatedtitle generatedtitle newword I dont understand what i am doing wrong
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
