Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Marketing The Ultimate Marketing Tool

Authors: Edward L. Nash

1st Edition

0070460639, 978-0070460638

More Books

Students also viewed these Databases questions