Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The Datamuse API returns its responses in a JSON format. The API attempts to determ words that are the best fit for your query, and

image text in transcribed
The Datamuse API returns its responses in a JSON format. The API attempts to determ words that are the best fit for your query, and it lists what it believes to be the most like first, ranked by a score. For example, you may expect responses to use the following fo [("word": "fda", "score": 1448, "numSyllables": 2}, ("word": "beverage", "score": 1437, "numSyllables": 3}, ("word": "nutrition", "score": 1382, "numSyllables": 3} ] Suppose that you use json. loads() to load the response above into a Python JSON parse data. A for loop can efficiently sift through your response, such as: for line in data: print("Word:", line["word"]) print("Syllables:", line["numSyllables"]) The printout would be: Word: fda Syllables: 2 Word: beverage Syllables: 3 Word: nutrition Syllables: 3 The Datamuse API is not perfect. As you can see above, it reports that the word "FDA syllables (probably "F-DA"), whereas it is usually pronounced as 3 syllables ("F-D-A purposes of this assignment, you may assume that the results of the API are valid, and need to correct any mistakes that the API may make. Allocating words to use exactly 5, 7, and 5 syllables in each line can be a complicated For the purposes of this assignment, you may have some flexibility in how you address problem. One approach, which is strongly recommended, is to always use a fixed num syllables for each word in the Haiku. For example, the implementation in the example uses (3-2) to achieve 5 syllables in the first line, (3-2-2) to achieve 7 syllables in the se and (3-2) achieve to 5 syllables in the third line. You may experiment with different so you may use the same scheme mentioned here. Occasionally, using this approach, you that some topics cannot result in valid Haikus because of a lack of related and/or rhyme Should this occur, simply print a message stating that a valid Haiku could not be gener Hello, welcome to the predictive text Haiku generator! What would you like to see a Haiku about

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

Step: 3

blur-text-image

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

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions