Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

USE JAVA** Magpie Chatbot Lab: Student Guide Introduction From Eliza in the 1960s to Siri and Watson today, the idea of talking to computers in

USE JAVA**

Magpie Chatbot Lab: Student Guide Introduction From Eliza in the 1960s to Siri and Watson today, the idea of talking to computers in natural language has fascinated people. More and more, computer programs allow people to interact with them by typing English sentences. The field of computer science that addresses how computers can understand human language is called Natural Language Processing (NLP). NLP is a field that attempts to have computers understand natural (i.e., human) language. There are many exciting breakthroughs in the field. While NLP is a complicated field, it is fairly easy to create a simple program to respond to English sentences. For this lab, you will explore some of the basics of NLP. As you explore this, you will work with a variety of methods of the String class and practice using the if statement. You will trace a complicated method to find words in user input.

Activity 2: Introduction to the Magpie Class In this activity, you will work Magpie, with a simple implementation of a chatbot. You will see how it works with some keywords and add keywords of your own. Prepare Have available: the code for the Magpie the code for the MagpieRunner a computer with your Java development tools Start Get to know the Magpie class. Run it, using the instructions provided by your teacher. How does it respond to: My mother and I talked last night. I said no! The weather is nice. Do you know my brother? Exploration Look at the code. See how the if statement assigns a value to the response and returns that response. The method getRandomResponse picks a response from a group of String objects. Exercises Alter the code: Have it respond Tell me more about your pets when the statement contains the word dog or cat. For example, a possible statement and response would be: Statement: I like my cat Mittens.

5 Response: Tell me more about your pets. Have it respond favorably when it sees the name of your teacher. Be sure to use appropriate pronouns! For example, a possible statement and response would be: Statement: Mr. Finkelstein is telling us about robotics. Response: He sounds like a good teacher. Have the code check that the statement has at least one character. You can do this by using the trim method to remove spaces from the beginning and end, and then checking the length of the trimmed string. If there are no characters, the response should tell the user to enter something. For example, a possible statement and response would be: Statement: Response: Say something, please. Add two more noncommittal responses to the possible random responses. Pick three more keywords, such as no and brother and edit the getResponse method to respond to each of these. Enter the three keywords and responses below. Keyword Response

What happens when more than one keyword appears in a string? Consider the string My mother has a dog but no cat. Explain how to prioritize responses in the reply method. Question 1. What happens when a keyword is included in another word? Consider statements like I know all the state capitals and I like vegetables smothered in cheese. Explain the problem with the responses to these statements.

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

C++ Database Development

Authors: Al Stevens

1st Edition

1558283579, 978-1558283572

More Books

Students also viewed these Databases questions

Question

How do Dimensional Database Models differ from Relational Models?

Answered: 1 week ago

Question

What type of processing do Relational Databases support?

Answered: 1 week ago

Question

Describe several aggregation operators.

Answered: 1 week ago