The Magpie lab allows you to work with the String class and conditionals with a chatbot.
A chatbot is a computer program that tries to hold a conversation with a user.
Several screenshots will need to be uploaded to the following Google Forms.
Working with a partner is encouraged, however, sharing screenshots with each other is NOT permitted (is considered plagiarism) and will result in a zero for any activities in which screenshots were shared for all students involved.
ACTIVITY 1: EXPLORING CHATBOTS
For Activities #2 and #3 you will be asked to take screenshots of your program code, or your output in the console.
DO NOT upload screenshots of your entire screen, they will not be accepted.
If you are unfamiliar with how to take screenshots on your device, I've included screenshots below for a few of the most commonly used keyboard shortcuts/applications that you can use:
Chromebook: Ctrl + Shift + Show Windows
Windows 10: I recommend using the Snipping Tool
ACTIVITY 2: RUNNING MAGPIE CODE
ACTIVITY 3: BETTER KEYWORD DETECTION
ACTIVITY 4: RESPONSES THAT TRANSFORM STATEMENTS
Single keywords are interesting, but better chatbots look for groups of words.
Statements like “I like cats”, “I like math class”, and “I like Spain” all have the form “I like something”.
The response could be “What do you like about something?”.
This final activity will respond to groupings of words.
Click the link above then "Fork repl" to have a copy of this chatbot in your account!
Try each of the following as the value for the statement in the main method:
> I want to understand French.
> Do you like me?
> You confuse me.
The chatbot is altered to look not only for keywords, but also specific phrases.
Magpie4.java adds two new methods, transformIWantToStatement and transformYouMeStatement.
Additionally, getResponse has been modified to add tests to find "I want to something" statements and "You something me" statements.
Make sure to look at the code and see how it handles "I want to" and you/me statements.
Your task is to add two new methods, transformIWantStatement and transformIYouStatement, and calls to each as described below.
1) In a method transformIWantStatement, have it respond to "I want something" statements with "Would you really be happy if you had something?". You can use the already written transformIWantToStatement method as a guide. In doing this be careful about where you place the call to the method so that it calls the right one. Test with the following:
> Statement: I want fried chicken.
> Response: Would you really be happy if you had fried chicken?
2) In a method transformIYouStatement, have it respond to statements of the form "I something you" with the restructuring "Why do you something me?". You can use the transformYouMeStatement method as a guide. Test with the following:
> Statement: I like you.
> Response: Why do you like me?
To receive credit for Activity #4 of this lab, find some time to meet with me I will test your transformIWantStatement and transformIYouStatement methods to make sure that they work!