Skip to content

Exercises for you to complete

biosopher edited this page Nov 4, 2015 · 14 revisions

Here are recommended improvements that you can make to the IPA demo in order to better understand how the Watson NLC and Dialog services work.

Exercise 1: Support Answers to Off-Topic Questions

When a user asks an off-topic question like "Why is the sky blue" or "What's your favorite color", reply with either a generic or witty answer. You could do this by adding a new pipeline javascript file with appropriate answers for various off-topic questions. This can imbue your IPA with a personality. If you want, add additional off-topic questions to your NLC training file nlc/ipa-web-nlc_training.csv and train a new classifier.

Extra Credit: Also see the exercise below for chaining multiple NLC classifier together to obtain a more granular classification of the user's input text.

Exercise 2: Support Scheduling an Alarm

For this exercise, train the NLC classifier to recognize requests to set an alarm and update the dialog to extract the date and time for the alarm. You should look at the flow for setting a meeting as the process is similar except for there's no meeting attendee.

  1. Create your own training rows in the NLC training file nlc/ipa-web-nlc_training.csv to detect the various ways a person could attempt to schedule an alarm.

  2. Delete the old classifier and create a new NLC classifier using your udpated nlc/ipa-web-nlc_training.csv.

  3. Update the Watson Dialog XML dialog/ipa-v1.xml to support extracting the day and time for the alarm.

  4. Delete the old dialog file from the Dialog service and upload your updated Dialog XML dialog/ipa-v1.xml.

Exercise 3: Add Support for Inviting More Than One Person

At present, you can only send emails, SMS, and meeting invites to a single person. As a start, search dialog/ipa-v1.xml for var_invite_attendee1. Determine how that variable is set and then add support for additional attendee variables.

  1. Update the Watson Dialog XML dialog/ipa-v1.xml to support inviting multiple contact.

  2. Delete the old dialog file from the Dialog service and upload your updated Dialog XML dialog/ipa-v1.xml.

Exercise 4: Add Support for Map Directions

The challenge here is to detect a location entity. This could be the name of a business (Peets Coffee), location in the user's phone books (Kelly's house), or an address (425 Market St, San Francisco).

  • Navigate to *
  • Directions to *
  • Find directions to *
  1. Create your own training rows in the NLC training file nlc/ipa-web-nlc_training.csv. The first question in doing this is whether each of these map request types is a unique NLC intent class or should be grouped under one: e.g. action-map-directions (column 2 of training rows).

  2. Delete the old classifier and create a new NLC classifier using your udpated nlc/ipa-web-nlc_training.csv.

  3. Decide whether you need to use Dialog or not. If so delete the old dialog file and update the Watson Dialog XML dialog/ipa-v1.xml to support map directions.

Exercise 5: Add Support for Recommendations

The challenge here is to detect a location entity. This could be the name of a business (Peets Coffee), location in the user's phone books (Kelly's house), or an address (425 Market St, San Francisco).

  • Where's the nearest *
  • Show me recommendations for *
  • Where's the best place to get *
  • Where's the closest *
  1. Create your own training rows in the NLC training file nlc/ipa-web-nlc_training.csv. The first question in doing this is whether each of these map request types is a unique NLC intent class or should be grouped under one: e.g. action-map-directions (column 2 of training rows).

  2. Delete the old classifier and create a new NLC classifier using your udpated nlc/ipa-web-nlc_training.csv.

  3. Decide whether you need to use Dialog or not. If so delete the old dialog file and update the Watson Dialog XML dialog/ipa-v1.xml to support map directions.

Exercise 6: Chain Multiple Classifiers Together

Sometimes it helps to use an NLC classifier to perform an initial classification of the user text and to then pass this text onto a 2nd NLC classifier to obtain a more granular classification. This can often be useful as the max # of training pairs for NLC is currently capped at 10,000 lines along with a limit of 1,000 classes per classifier.

A great example of this is handling off-topic questions. The first NLC classifier would determine whether a user's text was off-topic. The 2nd would determine exactly how to handle the off-topic question. E.g. here are a few sub-classifications for off-topic:

  • off_topic-favorite_color
  • off_topic-why_sky_blue
  • off_topic-meaning_of_life
  • off_topic-does_god_exist
  • ...