A conversational agent is a computer program that communicates with the user in natural language, following...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
A conversational agent is a computer program that communicates with the user in natural language, following a specific dialog structure to accomplish a tasks. Common examples are automatic phone systems for making reservations, purchasing, bank inquiries, or personal voice assistants such as Amazon Alexa or Apple Siri. conversational agent will be very simple with a limited vocabulary and a simplistic dialog structure. The goal of the agent will be to allow the user to order from an Italian restaurant serving pizza and salad. The dialog could look as follows (the text highlighted in bold is entered by the user): Would you like pizza or salad? pizza Small, medium, or large? large Add a topping: pepperoni, mushrooms, spinach, or enter 'done. mushrooms Add a topping: pepperoni, mushrooms, spinach, or enter 'done". spinach Add a topping: pepperoni, mushrooms, spinach, or enter done. done You order contains a large pizza with mushrooms and spinach. Would you like to continue ordering? (yes/no) yes Would you like pizza or salad? salad Garden or greek salad? greek Choose a dressing: vinaigrette, ranch, blue cheese, or lemon. blue cheese You order contains a large pizza with mushrooms and spinach and a greek salad with blue cheese dressing. Would you like to continue ordering? (yes/no) no Your order has been placed. Thank you come again! Implement Python functions that repeatedly prompt the user for his/her selection and assemble the order, as illustrated in the following diagram: def choose_pizza(): def main(): "a large pizza with mushrooms and spinach" invoke "Your order contains..." "Would you like to continue..." invoke repeatedly "Small, medium, or large?" def choose_meal(): "Would you like pizza or salad?" invoke "a large pizza with mushrooms and spinach" "a greek salad with blue cheese dressing" "mushrooms and spinach" invoke "a greek salad with blue cheese dressing" def choose_salad(): "Garden or greek salad?" invoke "blue cheese" def add_toppings(): "Add a topping..." The diagram shows the order in which the functions should be invoked, from top to bottom. For example, the function choose_salad() asks the user to select the type of the salad (garden or greek) and then invokes the choose_dressing() function which asks the user for a dressing type. All functions in the above diagram: def choose_dressing(): "Choose a dressing..." 1. take no parameters; 2. ask the user for selection using the built-in method input(); 3. return a string, except the main() function which returns nothing (None). An example string returned by each function is shown in blue. For example, the choose_dressing() function returns a string like "blue cheese". The choose_salad() function combines the type of the salad and the dressing returned by choose_dressing() into a string like "a greek salad with blue cheese dressing". And so on. Checklist for individual functions: main(): This function invokes the function choose_meal() repeatedly. After each invocation, it prints everything ordered so far ("Your order contains...") and then asks the user if they want to continue ordering. If the answer is "no", the function prints the final message "Your order has..." and terminates. • choose_pizza(): Make sure this function returns the correct string if the user adds no toppings. In this case, the function should return "a... pizza" and not "a... pizza with". • add_topings(): This function asks the user for toppings repeatedly until they enter "done". The return value of this function is a single string with all selected toppings, e.g., "pepperoni and mushrooms". If the user selects one topping more than once, the returned string should only contain the topping once. For example, selecting "pepperoni", "pepperoni", "mushroom" returns the string "pepperoni and mushroom". Program development hints: You do not have to validate inputs. The user always enters the correct string. All text entered by the user will be in lower case. • The focus of this homework is on functions and their invocations, i.e., nested function invocations. • All functions should be side-effect free, i.e., they should not modify any data (variables) defined outside of the function body. • Use string formatting with {} placeholders to assemble the strings. • What string method (covered in class) could you use to join an iterable (list) into a string? Surround each function with 1-2 empty lines. Your program will be easier to read and understand that way. ● :. • ● Put all your functions in the file problem1.py. At the end of the file, create the following main program to start the agent: if name main() == " _main__": A conversational agent is a computer program that communicates with the user in natural language, following a specific dialog structure to accomplish a tasks. Common examples are automatic phone systems for making reservations, purchasing, bank inquiries, or personal voice assistants such as Amazon Alexa or Apple Siri. conversational agent will be very simple with a limited vocabulary and a simplistic dialog structure. The goal of the agent will be to allow the user to order from an Italian restaurant serving pizza and salad. The dialog could look as follows (the text highlighted in bold is entered by the user): Would you like pizza or salad? pizza Small, medium, or large? large Add a topping: pepperoni, mushrooms, spinach, or enter 'done. mushrooms Add a topping: pepperoni, mushrooms, spinach, or enter 'done". spinach Add a topping: pepperoni, mushrooms, spinach, or enter done. done You order contains a large pizza with mushrooms and spinach. Would you like to continue ordering? (yes/no) yes Would you like pizza or salad? salad Garden or greek salad? greek Choose a dressing: vinaigrette, ranch, blue cheese, or lemon. blue cheese You order contains a large pizza with mushrooms and spinach and a greek salad with blue cheese dressing. Would you like to continue ordering? (yes/no) no Your order has been placed. Thank you come again! Implement Python functions that repeatedly prompt the user for his/her selection and assemble the order, as illustrated in the following diagram: def choose_pizza(): def main(): "a large pizza with mushrooms and spinach" invoke "Your order contains..." "Would you like to continue..." invoke repeatedly "Small, medium, or large?" def choose_meal(): "Would you like pizza or salad?" invoke "a large pizza with mushrooms and spinach" "a greek salad with blue cheese dressing" "mushrooms and spinach" invoke "a greek salad with blue cheese dressing" def choose_salad(): "Garden or greek salad?" invoke "blue cheese" def add_toppings(): "Add a topping..." The diagram shows the order in which the functions should be invoked, from top to bottom. For example, the function choose_salad() asks the user to select the type of the salad (garden or greek) and then invokes the choose_dressing() function which asks the user for a dressing type. All functions in the above diagram: def choose_dressing(): "Choose a dressing..." 1. take no parameters; 2. ask the user for selection using the built-in method input(); 3. return a string, except the main() function which returns nothing (None). An example string returned by each function is shown in blue. For example, the choose_dressing() function returns a string like "blue cheese". The choose_salad() function combines the type of the salad and the dressing returned by choose_dressing() into a string like "a greek salad with blue cheese dressing". And so on. Checklist for individual functions: main(): This function invokes the function choose_meal() repeatedly. After each invocation, it prints everything ordered so far ("Your order contains...") and then asks the user if they want to continue ordering. If the answer is "no", the function prints the final message "Your order has..." and terminates. • choose_pizza(): Make sure this function returns the correct string if the user adds no toppings. In this case, the function should return "a... pizza" and not "a... pizza with". • add_topings(): This function asks the user for toppings repeatedly until they enter "done". The return value of this function is a single string with all selected toppings, e.g., "pepperoni and mushrooms". If the user selects one topping more than once, the returned string should only contain the topping once. For example, selecting "pepperoni", "pepperoni", "mushroom" returns the string "pepperoni and mushroom". Program development hints: You do not have to validate inputs. The user always enters the correct string. All text entered by the user will be in lower case. • The focus of this homework is on functions and their invocations, i.e., nested function invocations. • All functions should be side-effect free, i.e., they should not modify any data (variables) defined outside of the function body. • Use string formatting with {} placeholders to assemble the strings. • What string method (covered in class) could you use to join an iterable (list) into a string? Surround each function with 1-2 empty lines. Your program will be easier to read and understand that way. ● :. • ● Put all your functions in the file problem1.py. At the end of the file, create the following main program to start the agent: if name main() == " _main__":
Expert Answer:
Answer rating: 100% (QA)
PYTHON CODE function to select the meal pizza and salad def selectmeal empty list to store the selected pizza and salad listpizza listsalad while True getting user choice of pizza or salad choiceinput... View the full answer
Related Book For
Auditing and Assurance services an integrated approach
ISBN: 978-0132575959
14th Edition
Authors: Alvin a. arens, Randal j. elder, Mark s. Beasley
Posted Date:
Students also viewed these programming questions
-
How do I design a register in D - ff , T - ff , J - k or SR format? This register can be wrapped to the right by entering a specific command and to the left by entering a second command. Please...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Googles ease of use and superior search results have propelled the search engine to its num- ber one status, ousting the early dominance of competitors such as WebCrawler and Infos- eek. Even later...
-
Refer to Table 2.3, in which data on EPS, DPS, and PPS for JNJ, Merck, and S&P 500 during the period 19882009 are given. Table 2.3 Please calculate the standard deviation for EPS, DPS, and PPS for...
-
Argue that in a breadth-first search, the value d[u] assigned to a vertex u is independent of the order in which the vertices in each adjacency list are given. Using Figure 22.3 as an example, show...
-
A company's capital structure weights are 20% debt and 80% equity. If the company's cost of equity is 13% and it's after-tax cost of debt is 6%, what is the WACC for this company? Do not round...
-
Match each five number summary with one of the histograms in Figure 2.23. The scale is the same on all four histograms. (a) $(1,3,5,7,9)$ (b) $(1,4,5,6,9)$ (c) $(1,5,7,8,9)$ (d) $(1,1,2,4,9)$ Figure...
-
Multiple Choice Questions 1. The moving average inventory cost flow method is applicable to which of the following inventory systems? Periodic Perpetual a. Yes..... Yes b. Yes..... No c. No..... No...
-
@ Consider y defined as a function of x by the equation: Ax+By+C=0 If A, B and C are constants, show that the graph of y is a straight line. What happens when B=0? Note that we say that the locus of...
-
There are N houses (numbered from 0 to N-1) along a street. In each of them, recyclable trash (plastic, glass, metal) is collected into separate bags. There are three trucks that collect the trash....
-
A free electron has an initial potential energy per unit charge ( voltage ) of 1 7 kJ / C and a velocity of 9 3 Mm / s . Later, its potential energy per unit charge is 6 kJ / C . Determine the change...
-
What is meant by the dual effect of transactions? How does it relate to the accounting equation?
-
Suppose that one of your business' largest customers has written an NSF cheque for \(\$ 9734\) and your boss has just found out about it. This morning he comes flying into your office demanding to...
-
What is a source document? Why does a business need to prepare source documents?
-
Suppose your brother, the owner of The Last Custard Stand (a specialty dessert shop), has asked you for a substantial loan to help him expand his business. Required: What would you like to know about...
-
What is a business' earning process, and when does the business record revenues?
-
Monica Bing, an educated businesswoman-turned-chef, was looking to join a local fitness club, to work off stress after the long hours she puts in at her restaurant, MC Ritzy, which she co-owns with...
-
The words without recourse on an indorsement means the indorser is: a. not liable for any problems associated with the instrument. b. not liable if the instrument is dishonored. c. liable personally...
-
Explain the relationship between the payroll and personnel cycle and inventory valuation.
-
As part of the analytical procedures of Mahogany Products, Inc., you perform calculations of the following ratios: For each of the preceding ratios: Required a. State whether there is a need to...
-
Which services must be preapproved by the audit committee of a public company?
-
Diehl Cleaners has the following statement of financial position items. Instructions Classify each item as an asset, liability, or equity. Analyze the effect of transactions. Accounts payable Cash...
-
Erin Danielle, the bookkeeper for Liverpool Ltd., has been trying to determine the correct statement of financial position for the company. The companys statement of financial position is shown...
-
Which of the following is true? a. Financial frauds have not occurred in U.S. companies because GAAP has detailed accounting and disclosure requirements. b. Transaction analysis is basically the same...
Study smarter with the SolutionInn App