AP Java Enhancing the Chatbot.

Slides:



Advertisements
Similar presentations
String Processing Word processing term papers, writing memoirs, sending messages, responding to surveys, placing online orders and registering.
Advertisements

PIIT Computer Science Summer Camp - Alice July 10, 2012 Brenda Parker Computer Science Department MTSU.
Classes, methods, and conditional statements We’re past the basics. These are the roots.
Student-Centered Coaching Instructional Design and Assessment Presented by Diane Sweeney Author of: Student-Centered Coaching (Corwin, 2010), Student-
Variables in Java Part 2. ICS-3M1 - Mr. Martens - Variables Part 2 Recall the “int” Data Types When you divide one integer by another – you always get.
Working with Numbers in Alice - Converting to integers and to strings - Rounding numbers. - Truncating Numbers Samantha Huerta under the direction of Professor.
THE BIG PICTURE. How does JavaScript interact with the browser?
By the end of this session you should be able to...
3/31/10. Electromagnet Fishing Derby 2010 Take out your project worksheet and complete the top section of STEP 6.
1 Chapter 3 Syntax, Errors, and Debugging Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
Make a dice challenge! This is a starter activity and should take 5 minutes [ slide 1 ] 1.Log in to your computer 2.Open IDLE 3.Copy the code below in.
My Python Programmes NAME:.
Exceptions Chapter 16 This chapter explains: What as exception is Why they are useful Java exception facilities.
AP Java Enhancing the Chatbot. Natural Language Processing Note: What is Natural Language Processing? What are some of the opportunities? What are some.
Introduction Chapter 1 1/22/16. Check zyBooks Completion Click on the boxes for each section.
Special Methods in Java. Mathematical methods The Math library is extensive, has many methods that you can call to aid you in your programming. Math.pow(double.
AP Java Java’s version of Repeat until.
WHAT IS A CHATTERBOT? A chatterbot is a computer program that simulates a conversation between two people. That is, one person writes something and the.
Iowa Department of Education ::: 2006 ::: Principle 2 ::: PPT/Transparency :::L2-1 Principle 2 Children need frequent opportunities to talk about their.
Warm up 1 Take a syllabus from the front table marked with your hour by it. Read through. Write 3 sentences on what you learned from the syllabus.
Learning to use a ‘For Loop’ and a ‘Variable’. Learning Objective To use a ‘For’ loop to build shapes within your program Use a variable to detect input.
Thank you for coming in quietly, Your Pencil & Daily Catch Binders off tables and out of way WARM UP Which of these is the most Valid? Why? Explain. What.
Good Communication FCS Overview. What is Communication? 0 The sending and receiving of messages.
Monday. In 2-3 sentences, explain what you think this quote means… “Before I can walk in another’s shoes, I must first remove my own.”
© A+ Computer Science - Magpie Magpie is a lab that focuses on classes, randomness, and Strings. This lab will make sure that you.
CompSci 4 Java 1 Apr 2, 2009 Prof. Susan Rodger. Announcements Assignment 7 questions? –Beware having two events that kick in at the same time! –Beware.
Section 6.1 Introduction to String Methods. Section 6.1 Introduction to String Methods.
Some Assignments  Write a program which prints the following information about at least 5 persons: NAME MAIL-ID EMPLOYEE-CODE PHONE Eg. Umesh
AP Java Elevens Lab.
Mrs. Bates’ Classroom Procedures and Expectations
Intro CS – Screens and Variables
More Sophisticated Behavior
Content Programming Overview The JVM A brief look at Structure
I can’t hear you through the static
AP Java Enhancing the Chatbot.
© A+ Computer Science - Magpie Chatbot Lab © A+ Computer Science -
Introducing Instructions
Week of 12/12/16 Test Review.
CSE 311 Foundations of Computing I
Fundamentals of Programming I Dictionaries redux
Warm-up Program Use the same method as your first fortune cookie project and write a program that reads in a string from the user and, at random, will.
Psuedo Code.
Engineering Innovation Center
Exposure Java 2015 AP®CS Edition Chapter 8 Slides Manipulating Strings
Antigone Short Position Paper.
Computer Science and an introduction to Pascal
You can work in groups on this program.
Computer Science 2 Hashing
Fill the screen challenge!
Academic Communication Lesson 3
Writer’s Eye (I) Serves two purposes:
AP Magpie Chatbox "If a computer could think, how could we tell?"
Giving and Receiving Compliments
I Can Follow Directions!
Introduction to TouchDevelop
Coding Concepts (Data- Types)
Python 21 Mr. Husch.
Python 19 Mr. Husch.
Agenda Warmup Lesson 1.6 (Do-while loops, sentinels, etc)
Second Line Social Responsibility Lesson
Data Types Every variable has a given data type. The most common data types are: String - Text made up of numbers, letters and characters. Integer - Whole.
Conversations Starting and Stopping.
Magpie/Chatbot Activity 5
Basic Mr. Husch.
while loop Condition Statement list
Python 19 Mr. Husch.
What are rhyming words? Mrs. Taylor.
Software Development Techniques
CMPT 120 Lecture 4 – Unit 1 – Chatbots
Presentation transcript:

AP Java Enhancing the Chatbot

Watson Video

Leaning Objectives Take a look at Natural Language Processing and some of its’ challenges and opportunities. Be able to use Java Docs to look up and use additional String methods. Practice reading a program that uses String methods in developing a Chatbot Enhance your Chatbot

Summarize the following String Methods You might need to look at JavaDocs Summarize the following String methods with your partner. int position = stringVar.indexOf (String) int position = stringVar.indexOf(String, int) String answer = stringVar.toLowerCase() String answer = stringVar.trim() stringVar.compareTo(stringVar2) stringVar.length()

Magpie Activity 3 Project Open the Magpie Activity 3 We are going to analyze and enhance the Magpie3 class. Start with the findKeyWord() method.

findKeyword("She's my sister", "sister", 0); private int findKeyword(String statement, String goal, int startPos) { String phrase = statement.trim().toLowerCase(); goal = goal.toLowerCase(); int psn = phrase.indexOf(goal, startPos); while (psn >= 0) { String before = " ", after = " "; if (psn > 0) { before = phrase.substring(psn - 1, psn); } if (psn + goal.length() < phrase.length()) { after = phrase.substring(psn + goal.length(), psn + goal.length() + 1); /* determine the values of psn, before, and after at this point in the method. */ if (((before.compareTo ("a") < 0 ) || (before.compareTo("z") > 0)) && ((after.compareTo ("a") < 0 ) || (after.compareTo("z") > 0))) { return psn; psn = phrase.indexOf(goal, psn + 1); return -1; Dry Run using the call statements on the bottom of the page. Record your answers in the packet. Write the variable names and step through the method using the given inputs. findKeyword("She's my sister", "sister", 0); findKeyword("Brother Tom is helpful", "brother", 0); findKeyword("I can't catch wild cats.", "cat", 0); findKeyword("I know nothing about snow plows.", "no", 0); findKeyword(“That that isn’t is that that is not is not is that it it is”, “is”,0);

Modifying the Magpie Copy the Activity3 Folder from the Magpie project into your Magpie Project folder Repeat the changes made to Magpie2 to the Magpie3 class. Demo to Smith for signoff

Modify the Magpie3 Demo to Smith • 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. 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.

Questions: Prepare for the next activity Single keywords are interesting, but better chatbots look for groups of words. Consider statements like “I like cats,” “I like math class,” and “I like Spain.” All of these have the form “I like something.” The response could be “What do you like about something?” The next activity will expand on these groups. You will get to add one of your own, so it’s a good idea to start paying close attention to common phrases in your own conversations.

MagPie 4 I want.., I something Open Activity4 How has the getResponse() method changed? Read and understand what the transformIWantStatement() method does. Read and understand what the transformYouMeStatement() method does. Modify this code to do the following…

getResponse() // Responses which require transformations else if (findKeyword(statement, "I want to", 0) >= 0) { response = transformIWantToStatement(statement); } else // Look for a two word (you <something> me) // pattern int psn = findKeyword(statement, "you", 0); if (psn >= 0 && findKeyword(statement, "me", psn) >= 0) response = transformYouMeStatement(statement); response = getRandomResponse();

private String transformIWantToStatement(String statement) private String transformIWantToStatement(String statement) { // Remove the final period, if there is one statement = statement.trim(); String lastChar = statement.substring(statement.length() - 1); if (lastChar.equals(".")) statement = statement.substring(0, statement.length() - 1); } int psn = findKeyword (statement, "I want to", 0); String restOfStatement = statement.substring(psn + 9).trim(); return "What would it mean to " + restOfStatement + "?";

private String transformYouMeStatement(String statement) { // Remove the final period, if there is one statement = statement.trim(); String lastChar = statement.substring(statement.length() - 1); if (lastChar.equals(".")) statement = statement.substring(0, statement.length() - 1); } int psnOfYou = findKeyword (statement, "you", 0); int psnOfMe = findKeyword (statement, "me", psnOfYou + 3); String restOfStatement = statement.substring(psnOfYou + 3,psnOfMe).trim(); return "What makes you think that I " + restOfStatement + " you?";

Chatbot Activity 4 Look at the code. See how it handles “I want to” and you/me statements. Have it respond to “I want something” statements with “Would you really be happy if you had something?” In doing this, you need to be careful about where you place the check. Be sure you understand why. For example: Statement: I want fried chicken. Response: Would you really be happy if you had fried chicken? Have it respond to statements of the form “I something you” with the restructuring “Why do you something me?” For example: Statement: I like you. Response: Why do you like me? Demonstrate your program(s) to Mr. Smith to get these programming exercises checked off Use this tool to include additional phrases to improve the quality of your responses.