2

I'm trying to learn AIML and can't understand where I've gone wrong:

<aiml>
    <category>
        <pattern>I LIKE * ROME</pattern>
        <template>
            I love talking about 
            <set name="topic">rome</set>
            too!
            <random>
                <li>Did you know that slaves made up 40% of the population of Ancient Rome?</li>
                <li>Did you know the Colosseum could sit 250'000 people?</li>
            </random>
        </template>
    </category>
    <topic name="rome">
        <category>
            <pattern>No *</pattern>
            <that>Did you know that slaves made up 40% of the population of Ancient Rome?</that>
            <template>So I've taught you something!</template>
        </category>
    </topic>
</aiml>

The first part works fine, if I enter something like: "I like the history of Rome", I get the expected default answer and one of the random answers.

But then if he gives me the "slave" random answer and I say "No I didn't know that", he doesn't give me the "So I've taught you something" answer". He's getting the answer from somewhere else in his code, but considering that I have set the "topic" and the < that > tag, I have been quite specific and would expect my custom answer.

Greg
  • 2,163
  • 1
  • 21
  • 23
Juicy
  • 11,840
  • 35
  • 123
  • 212

3 Answers3

1

There is

<pattern>No _</pattern>

some where in your aiml files.

ittgung
  • 134
  • 1
  • 2
  • 6
0

The use of the <that> tag is your choke point. For what a picture is worth, I changed your response in the initial template, and it worked.

With respect to the second reply of the bot. If it is used, then the category in the rome topic will never work because the 40$'ers in the <that> tag has to be the last response by the bot.

There may be some confusion in the chat bot's reply. Before the topic was always changed to "rome", but in order for the pattern in the topic "rome" to work, the chat bot had to talk about the 40%'ers. I just combined the two to get the same result.

Also note that the question mark in the <that> tag was not placed there. The bot will strip it off and store the remaining result.

<?xml version="1.0" encoding="UTF-8"?>
<aiml>
<category>
  <pattern>I LIKE * ROME</pattern>
  <template>
    <random>
      <li>Did you know that slaves made up 40% of the population of Ancient <set name="topic">Rome</set>?</li>
      <li>Did you know the Colosseum in could sit 250'000 people?</li>
    </random>
  </template>
</category>
<topic name="rome">
  <category>
    <pattern>No *</pattern>
    <that>Did you know that slaves made up 40% of the population of Ancient Rome</that>
    <template>
      So I've taught you something!
    </template>
  </category>
</topic>
</aiml>
insane User
  • 159
  • 1
  • 2
  • 7
0

You can use wildcards (*) in <that> tag, so you can match only part of bot's answer (e.g. "DID YOU KNOW THAT SLAVES MADE UP").

Also note, that topic can be set inside <think> tag, which does not displays its content.

I tested the following code with Python AIML interpreter. It works as expected, but when topic name and content of <that> and <pattern> tags were lowercase, it didn't work.

<aiml>
<category>
    <pattern>I LIKE * ROME</pattern>
    <template>
        I love talking about Rome too!
        <think><set name="topic">ROME</set></think>
        <random>
            <li>Did you know that slaves made up 40 of the population of Ancient Rome?</li>
            <li>Did you know the Colosseum could sit 250'000 people?</li>
        </random>
    </template>
</category>
<topic name="ROME">
    <category>
        <pattern>NO</pattern>
        <that>* DID YOU KNOW THAT SLAVES MADE UP *</that>
        <template>So I've taught you something!</template>
    </category>
</topic>
</aiml>
trivelt
  • 1,913
  • 3
  • 22
  • 44