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 6.5. 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 find_prob_dist has at least one row, since that means there are more words we can add to our title. Our stopping condition, therefore, is when find_prob_dist 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 generate_title returns a randomly generated episode title. Some comments are included to help you.File "/tmp/ipykernel_186/3704249357.py", line 12generated_title = generated_title +1,+ new_word I dont understand what i am doing wrong
 Question 6.5. Now that we know how to generate titles based

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 Databases Questions!