Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A Dialog System for Ordering Pizza A dialog system (or conversational agent) is a computer program intended to communicate with humans in natural language, following

A Dialog System for Ordering Pizza

A dialog system (or conversational agent) is a computer program intended to communicate with humans in natural language, following a specific dialog structure to accomplish a specific tasks. Common examples are automatic phone systems for flight reservations or personal assistants such as Siri and Alexa. The system should allow the user to order from an Italian restaurant by asking specific questions. Here is an example Dialog:

Python prints: "Hello, would you like pizzaor salad?"

User types: "pizza"

Python: "Small, medium, or large?"

User: "large"

Python: "Add a topping: pepperoni, mushrooms, spinach, or say 'done'"

User: "mushrooms"

Python: "Add a topping: pepperoni, mushrooms, spinach, or say 'done'"

User: "spinach"

Python: "Add a topping: pepperoni, mushrooms, spinach, or say 'done'"

User: "done"

Python: "You ordered a large pizza with mushrooms and spinach. Place another order or say 'done'.

Hello, would you like pizza or salad?"

User: "salad"

Python: "Would you like a garden salad or greek salad"

User: "greek"

Python: "please choose a dressing: vinaigrette, ranch, blue cheese, lemon"

User: "blue cheese"

Python: "You ordered a large pizza with mushrooms and spinachand a greek salad with blue cheesedressing.Place another order or say'done'.

Hello, would you like pizza or salad?"

User: "done"

Python: "Your order has been placed. Goodbye."

Implement functions to prompt the user, as illustrated in the diagram below. For example, the salad()function should ask the user for a type of salad. Then the salad() functions calls the dressing() method to asks for a dressing.

All functionsreturna string, so that you can assemble the order as a string in the calling function. The dressing() function would return the type of dressing, for example "blue cheese". The salad() function would combine the dressing and the salad type into "greek salad with lemon dressing". Finally, the select_meal() function would assemble the complete order in a string.

Note that the functions do not have any parameters. Instead, they should all read user input and then return that input formatted as a string or a list.

The following diagram illustrates the order in which the functions should be called and how the result string should be assembled from the return values step-by-step.

Some complications:

  • The toppings() functionshould ask for toppings repeatedly until the user types "done". The return valueof the toppings method should be a single string including the toppings, for example "pepperoni and mushrooms and spinach".
  • The select_meal functionshould ask the user repeatedly to add an item until the user types "done". It should assemble a string representing the complete order.

Hints:

  • None of the functions take any parameters. The important part in this problem is that you are calling functions from within other functions ("nested" function calls).
  • Use string formatting with {} place holders to assemble the strings. Make sure to write all functions specified in the diagram, and only those functions with the specified behavior.

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

Students also viewed these Programming questions

Question

How does clustering in unsupervised learning help in data analysis?

Answered: 1 week ago