pandorabots 2,473,917,501 pandorabot responses served!
  Help Policies [Last Updated 9.26.2015]
Support About Most Popular

In order to follow the examples in this tutorial you will need to login using the panel to the left. If you don't have a Pandorabots account you can sign-up for an account here.

Previous | Next | Contents | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | All   Printable View

A Tutorial For Adding Knowledge to Your Robot

So many ways to write the same thing... What is <srai>?

You can write a sentence with the same meaning in many different ways. Most people would accept the following sentences as roughly equivalent:

Empty, can you please tell me if you are seeing anyone else right now?
Empty, can you please tell me if you are seeing anyone else now?
Empty, can you please tell me if you are seeing anyone else ?
Empty, please tell me if you are seeing anyone else?
Empty, tell me if you are seeing anyone else?
Empty, tell me, are you seeing anyone else?
Empty, are you seeing anyone else?
Are you seeing anyone else?
And this is an example of a general problem - how do you enter all the categories for inputs with equivalent meanings? Or how do you answer these kinds of questions? No one has provided a satisfactory mechanism for finding all the similar sentences. Here is what can be done though.

In this example we are going to use a new tag and introduce the "_" character. Earlier we wrote that "*" matches any pattern. "_" is another form of "*" and is useful for matching patterns at the ends of sentences. The category containing "* NOW" will be matched after the one containing "_ NOW".

Let's begin by adding two new categories so that Empty responds as follows:

Human: Are you seeing anyone else?
Empty: Everyone I run into is either someone I've already seen or someone I am going to see in the future.
Human: You are seeing anyone else?
Empty: Everyone I run into is either someone I've already seen or someone I am going to see in the future.
Then, by adding the category:
<category>
  <pattern>EMPTY *</pattern>
  <template>
    <srai><star/></srai>
  </template>
</category>
Empty responds with:
Human: Empty, are you seeing anyone else?
Empty: Everyone I run into is either someone I've already seen or someone I am going to see in the future.
Adding:
<category>
<pattern>_ TELL ME *</pattern>
<template>
<srai><star index="2" /></srai>
</template>
</category>
...produces:
Human: Empty, tell me are you seeing anyone else?
Empty: Everyone I run into is either someone I've already seen or someone I am going to see in the future.
Adding:
<category>
  <pattern>_ TELL ME IF *</pattern>
  <template>
    <srai><star index="2" /></srai>
  </template>
</category>
...produces:
Human: Empty, tell me if you are seeing anyone else?
Empty: Everyone I run into is either someone I've already seen or someone I am going to see in the future.
Finally, after adding:
<category>
  <pattern>_ NOW</pattern>
  <template>
    <srai><star/></srai>
  </template>
</category>

<category>
  <pattern>_ RIGHT NOW</pattern>
  <template>
    <srai><star/></srai>
  </template>
</category>
...we can now get the same answer to all the questions:
Human: Empty, can you please tell me if you are seeing anyone else right now
Empty: Everyone I run into is either someone I've already seen or someone I am going to see in the future.
Human: Empty, can you please tell me if you are seeing anyone else now?
Empty: Everyone I run into is either someone I've already seen or someone I am going to see in the future.
Human: Empty, can you please tell me if you are seeing anyone else?
Empty: Everyone I run into is either someone I've already seen or someone I am going to see in the future.
Human: Empty, please tell me if you are seeing anyone else?
Empty: Everyone I run into is either someone I've already seen or someone I am going to see in the future.
Human: Empty, tell me if you are seeing anyone else?
Empty: Everyone I run into is either someone I've already seen or someone I am going to see in the future.
Human: Empty, tell me are you seeing anyone else?
Empty: Everyone I run into is either someone I've already seen or someone I am going to see in the future.
Human: Empty, are you seeing anyone else?
Empty: Everyone I run into is either someone I've already seen or someone I am going to see in the future.
So, what has happened here? We've simplified progressively more complex sentences into two "standard" sentences: (Are you seeing anyone else? and You are seeing anyone else?)

The general technique is called recursion - and it means applying the same solution - in this example <srai><star/></srai> over and over again. Recursion is useful for a variety of tasks. We will just mention a few here. More details can be found in The Anatomy of Alice.

Example 6 - Handling Multiple Sentences

The following exchange is generated with the categories below. (Your robot can handle multiple sentences - and does it by responding to each one in turn in separate output lines.)

Human: Empty, are you seeing anyone else?
Empty: Everyone I run into is either someone I've already seen or someone I am going to see in the future.
Human: I see.
Empty: I am glad you see.
Human: Why do you think you can get away with that?
Empty: Full disclosure is always best don't you think?
<category>
  <pattern>I SEE *</pattern>
  <template>
    <srai>I SEE</srai>
    <srai><star/></srai>
  </template>
</category>

<category>
  <pattern>I SEE</pattern>
  <template>I am glad you see</template>
</category>

<category>
  <pattern>
    WHY DO YOU THINK YOU CAN GET AWAY WITH THAT
  </pattern>
  <template>
     Full disclosure is always best don't you think?
  </template>
</category>

Example 7 - Spelling and Grammar corrections

Often we want to correct spelling errors or suggest alternate forms of grammar - and here is one way to do it:

<category>
  <pattern>YOUR A *</pattern>
  <template>
    I presume you mean "you are a ..." <srai>YOU ARE A <star/></srai>
  </template>
</category>

Example 8 - Keywords

Sometimes we want the robot's response to be determined by just one word (a keyword) you've typed. Here is an example in which the keyword is "LOVE":

<category>
  <pattern>LOVE</pattern>
  <template>Tell me more about what you are seeking.</template>
</category>

<category>
  <pattern>_ LOVE</pattern>
  <template>
    <srai>LOVE</srai>
  </template>
</category>

<category>
  <pattern>LOVE _</pattern>
  <template>
    <srai>LOVE</srai>
  </template>
</category>

<category>
  <pattern>_ LOVE *</pattern>
  <template>
    <srai>LOVE</srai>
  </template>
</category>
The first category matches the single word input of love. The second and third categories match a sentence ending in love and beginning in love respectively. The final category matches a sentence in which the word love appears.

Copyright © 2002 - 2004 Doubly Aimless

Previous | Next | Contents | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | All   Printable View