In Activity 4, we're teaching Magpie to respond to phrases, rather than just keywords. Statements like...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
In Activity 4, we're teaching Magpie to respond to phrases, rather than just keywords. Statements like "I like CodeHS," "I like programming," "I like popsicles" all have the form of "I like x." A response to this could be "What do you like about x?" Exploration The Magpie class in the starter code here has revisions to handle phrases like this. Test Magpie by telling it "I want to build a robot," "Do you like me?" and "You confuse me." Exercises 1. Change the code so the response to "I want x" is "Would you really be happy if you had x?" 2. Change the code so the response to "1 x you" is "Why do you x me?" Then, find an example of a statement that doesn't make sense with this response. How could you improve it? Extra Credit Try adding a new keyphrase structure to Magpie. Here are some examples: -"Have you x?" -> "I haven't x, have you?" - "I'm going to x." -> "Good luck with x ! It sounds fun." New MagpieRunner.java Magpie.java 2.1.7 Activity 4: Responses that Transform Statements 1 import java.util.Scanner; 2 3 public class Magpie Runner 4- { 5 6▾ 7 8 9 10 public static void main(String[] args). { Magpie magpie = new Magpie(); System.out.println("M> " + magpie.greeting()); Scanner scanner = new Scanner(System.in); String statement = scanner.nextLine(); while (!statement.equals("Bye")) 11 12 13- { 14 15 16 17 18 } 19 20 21 System.out.println("M > " + magpie.getResponse(statement)); statement = scanner.nextLine(); scanner.close(); Submit + Continue Save Output Docs Assignment Grade More 5 points Status: Not Submitted In Activity 4, we're teaching Magpie to respond to phrases, rather than just keywords. Statements like "I like CodeHS," "I like programming," "I like popsicles" all have the form of "I like x." A response to this could be "What do you like about x?" Exploration The Magpie class in the starter code here has revisions to handle phrases like this. Test Magpie by telling it "I want to build a robot," "Do you like me?" and "You confuse me." Exercises ལ་ 1. Change the code so the response to "I want x " is "Would you really be happy if you had x?" 2. Change the code so the response to "I x you" is "Why do you x me?" Then, find an example of a statement that doesn't make sense with this response. How could you improve it? Extra Credit Try adding a new keyphrase structure to Magpie. Here are some examples: - "Have you x?" -> "I haven't x, have you?" - "I'm going to x." -> "Good luck with x ! It sounds fun." 1 2- { 3- 4 5 6 7 New + MagpieRunner.java Magpie.java 2.1.7 Activity 4: Responses that Transform Statements public class Magpie * Gets a default greeting. * @return String */ public String greeting() Submit + Continue Save Output Docs Assignment Grade More 5 points Status: Not Submitted G /** 8 { 9 return "Hey, what's up?"; 10 } 11 12 /** 13 14 15 16 17 18 19- { 20 21 22- { 23 24 } 25- 26 27 28 29 30 31 32 33 } 34 35 36 37 * Resturns a response to a user statement @param statement * @return String *1 public String getResponse(String statement) String response = ""; if (findKeyword(statement, "no") >= 0) response = "Don't be so negative!"; else if ( findKeyword(statement, "mother") >= 0 || findKeyword(statement, "brother") >= 0 || findKeyword(statement, "sister") >= 0 || findKeyword(statement, "father") >= 0 response = "Tell me more about your family!"; else if ( findKeyword(statement, "weather") >= 0 || findKeyword(statement, "sun") >= 0 || findKeyword(statement, "rain") >= 0 Extra Credit Try adding a new keyphrase structure to Magpie. Here are some examples: -"Have you x?" -> "I haven't x, have you?" - "I'm going to x." -> "Good luck with x! It sounds fun." In Activity 4, we're teaching Magpie to respond to phrases, rather than just keywords. Statements like "I like CodeHS," "I like programming," "I like popsicles" all have the form of "I like x." A response to this could be "What do you like about x?" Exploration The Magpie class in the starter code here has revisions to handle phrases like this. Test Magpie by telling it "I want to build a robot," "Do you like me?" and "You confuse me." Exercises 1. Change the code so the response to "I want x " is "Would you really be happy if you had x?" 2. Change the code so the response to "I x you" is "Why do you x me?" Then, find an example of a statement that doesn't make sense with this response. How could you improve it? 38 39- { 40 41 42 43- { 44 response = "The weather here is really nice."; else if (findKeyword(statement, "I want to", 0) >= 0) response = transformIWantToStatement (statement); 45 46 In Activity 4, we're teaching Magpie to respond to phrases, rather than just keywords. Statements like "I like CodeHS," "I like programming," "I like popsicles" all have the form of "I like x." A response to this could be "What do you like about x?" Exploration The Magpie class in the starter code here has revisions to handle phrases like this. Test Magpie by telling it "I want to build a robot," "Do you like me?" and "You confuse me." Exercises 1. Change the code so the response to "I want x" is "Would you really be happy if you had x?" 2. Change the code so the response to "1 x you" is "Why do you x me?" Then, find an example of a statement that doesn't make sense with this response. How could you improve it? Extra Credit Try adding a new keyphrase structure to Magpie. Here are some examples: -"Have you x?" -> "I haven't x, have you?" - "I'm going to x." -> "Good luck with x ! It sounds fun." New MagpieRunner.java Magpie.java 2.1.7 Activity 4: Responses that Transform Statements 1 import java.util.Scanner; 2 3 public class Magpie Runner 4- { 5 6▾ 7 8 9 10 public static void main(String[] args). { Magpie magpie = new Magpie(); System.out.println("M> " + magpie.greeting()); Scanner scanner = new Scanner(System.in); String statement = scanner.nextLine(); while (!statement.equals("Bye")) 11 12 13- { 14 15 16 17 18 } 19 20 21 System.out.println("M > " + magpie.getResponse(statement)); statement = scanner.nextLine(); scanner.close(); Submit + Continue Save Output Docs Assignment Grade More 5 points Status: Not Submitted In Activity 4, we're teaching Magpie to respond to phrases, rather than just keywords. Statements like "I like CodeHS," "I like programming," "I like popsicles" all have the form of "I like x." A response to this could be "What do you like about x?" Exploration The Magpie class in the starter code here has revisions to handle phrases like this. Test Magpie by telling it "I want to build a robot," "Do you like me?" and "You confuse me." Exercises ལ་ 1. Change the code so the response to "I want x " is "Would you really be happy if you had x?" 2. Change the code so the response to "I x you" is "Why do you x me?" Then, find an example of a statement that doesn't make sense with this response. How could you improve it? Extra Credit Try adding a new keyphrase structure to Magpie. Here are some examples: - "Have you x?" -> "I haven't x, have you?" - "I'm going to x." -> "Good luck with x ! It sounds fun." 1 2- { 3- 4 5 6 7 New + MagpieRunner.java Magpie.java 2.1.7 Activity 4: Responses that Transform Statements public class Magpie * Gets a default greeting. * @return String */ public String greeting() Submit + Continue Save Output Docs Assignment Grade More 5 points Status: Not Submitted G /** 8 { 9 return "Hey, what's up?"; 10 } 11 12 /** 13 14 15 16 17 18 19- { 20 21 22- { 23 24 } 25- 26 27 28 29 30 31 32 33 } 34 35 36 37 * Resturns a response to a user statement @param statement * @return String *1 public String getResponse(String statement) String response = ""; if (findKeyword(statement, "no") >= 0) response = "Don't be so negative!"; else if ( findKeyword(statement, "mother") >= 0 || findKeyword(statement, "brother") >= 0 || findKeyword(statement, "sister") >= 0 || findKeyword(statement, "father") >= 0 response = "Tell me more about your family!"; else if ( findKeyword(statement, "weather") >= 0 || findKeyword(statement, "sun") >= 0 || findKeyword(statement, "rain") >= 0 Extra Credit Try adding a new keyphrase structure to Magpie. Here are some examples: -"Have you x?" -> "I haven't x, have you?" - "I'm going to x." -> "Good luck with x! It sounds fun." In Activity 4, we're teaching Magpie to respond to phrases, rather than just keywords. Statements like "I like CodeHS," "I like programming," "I like popsicles" all have the form of "I like x." A response to this could be "What do you like about x?" Exploration The Magpie class in the starter code here has revisions to handle phrases like this. Test Magpie by telling it "I want to build a robot," "Do you like me?" and "You confuse me." Exercises 1. Change the code so the response to "I want x " is "Would you really be happy if you had x?" 2. Change the code so the response to "I x you" is "Why do you x me?" Then, find an example of a statement that doesn't make sense with this response. How could you improve it? 38 39- { 40 41 42 43- { 44 response = "The weather here is really nice."; else if (findKeyword(statement, "I want to", 0) >= 0) response = transformIWantToStatement (statement); 45 46
Expert Answer:
Answer rating: 100% (QA)
Heres an code implementation of the Magpie class in Java incorporating the changes requested in the exercises import javautilScanner public class Magpie public String getResponseString statement Strin... View the full answer
Related Book For
Foundations of Financial Management
ISBN: 978-1259024979
10th Canadian edition
Authors: Stanley Block, Geoffrey Hirt, Bartley Danielsen, Doug Short, Michael Perretta
Posted Date:
Students also viewed these programming questions
-
Write a report on Home and Automobile: These are two of the most important financial purchases we will make. These decisions, especially housing, will affect much of your ability to meet your...
-
What are the IRRs for the following projects? a. An initial outlay of $10,000 resulting in a single cash inflow of $17,182 in 8 years b. An initial outlay of $10,000 resulting in a single cash inflow...
-
Its an important tradition in the Santos family that they eat the same meal at their favorite restaurant every Sunday. By contrast, the Chen family spends exactly $50 for their Sunday meal at...
-
Consider the following one-dimensional problem: This is a concave problem, since the leading term in the quadratic objective is negative, so that the second-order derivative is negative everywhere....
-
A lighting company seeks to study the percentage of defective glass shells being manufactured. Theoretically, the percentage of defectives is dependent on temperature, humidity, and the level of...
-
You are a Japanese investor. The current spot rate of JPY/USD is 100. In one period, the exchange rate is expected to go up to JPY/USD 110 or JPY/USD 90. The JPY risk free interest rate is 8%. There...
-
Q1. What is ERP and ERP II and why are they used in supply chain? and what are their disadvantages Q2.What is perfect information? What costs would you associate with receiving information that is...
-
Calculate Gross Pay for a Piecework Employee Calculate gross pay for each employee. All are paid overtime wage rates that are 1 . 5 times their respective regular wage rates. NOTE: For simplicity,...
-
explain how the output for this code is 10? public class F { public static void main(String[] args) { k = 0; for (int i = 0; i < 10; i++) { for (int j = 0; j < 5; j++) { if (j % 2 == 0) { continue;...
-
In setting standards and if there is a labor union contract how does a company increase the expectations of its operational units? Any thoughts?
-
What resource is essential for up-to-date investment information and investment research?
-
What is needed when sending medical records via fax?
-
Write a short paper on Pak-US Relation in the Post 911 Era 2001-2020). n
-
6 (a) Briefly develop a mathematical model of the behaviour of a copper-twisted pair cable (b) Derive the magnetic energy from: w given that: K + w, where the - - k symbols have their usual meaning...
-
The Landry Corporation needs to raise $1 million of debt on a 25-year issue. If it places the bonds privately, the interest rate will be 11 percent, and $30,000 in out-of-pocket costs will be...
-
David's Magic Stores has an operating profit of $210,000. Interest expense for the year was $30,000; preferred dividends paid were $24, 700; and common dividends paid were $36,000. The tax was...
-
Todd Winningham IV has $4,000 to invest. He has been looking at Gallagher Tennis Clubs Inc. common stock. Gallagher has issued a rights offering to its common shareholders. Six rights plus $38 cash...
-
Cumulative Normal distribution \(\Phi_{(\mu, \sigma)}\) and probability (a) \(X \sim \phi_{(0,1)}\); what is \(P(X \leq 1.43)\) ? (b) \(X \sim \phi_{(0,1)}\); what is \(P(X>1.43)\) ? (c) \(X \sim...
-
Inverse cumulative Normal distribution \(z\) (a) Find \(z_{0.05}\). (b) Find \(z_{0.95}\). (c) Let \(X \sim \phi_{(2,1)}\). Find \(a\) such that \(P(X \leq a)=0.05\). (d) Let \(X \sim \phi_{(2,1)}\)....
-
The Normal approximation (a) A discrete stochastic variable \(X\) has expected value \(\mu_{X}=3\) and \(\sigma_{X}=1.2\). Use the Normal approximation to find \(P(X \leq 4)\). (b) A continuous...
Study smarter with the SolutionInn App