AI Zone Admin Forum Add your forum

NEWS: Chatbots.org survey on 3000 US and UK consumers shows it is time for chatbot integration in customer service!read more..

How to set multiple questions into one category
 
 

Is there a way to fit different questions with multiple answers into one category?

 

 
  [ # 1 ]

Can you give an example please?

 

 
  [ # 2 ]

Here is an example.

<?xml version="1.0" encoding="UTF-8"?>
<aiml>
    <
category>
        <
pattern>* NEW YORK</pattern>
        <
template>New York is a state in the northeastern United States.</template>
    </
category>

    <
category>
        <
pattern>WHAT iS NEW YORK</pattern>
        <
template>Newyork is a state.</template>
    </
category>

    <
category>
        <
pattern>* NEW YORK *</pattern>
        <
template>New York is a state in the northeastern United States.</template>
    </
category>

    <
category>
        <
pattern>* MEXICO</pattern>
        <
template>Mexico is located in North America</template>
    </
category>

    <
category>
        <
pattern>WHAT IS MEXICO</pattern>
        <
template>Mexico is a federal republic in the southern portion of North America.
        </
template>
    </
category>

    <
category>
        <
pattern>* MEXICO *</pattern>
        <
template>Mexico is a federal republic in the southern portion of North America.
        </
template>
    </
category>

    <
category>
        <
pattern>WHAT IS THE POPULATION OF MEXICO</pattern>
        <
template>Roughly around 127.5 million.</template>
    </
category>

  <
category>
      <
pattern>* IN MEXICO</pattern>
      <
template>Roughly around 127.5 million.</template>
</
category>

  <
category>
      <
pattern>* ANTARTICA</pattern>
      <
template>I dont know where Antarctica is</template>
</
category>

  <
category>
      <
pattern>^ NOT</pattern>
      <
that>I dont know where Antarctica is</that>
      <
template>Because it is not in my knowledgebase.</template>
</
category>

  <
category>
      <
pattern>HOW MANY PEOPLE LIVE IN ANTARCTICA</pattern>
      <
template>I dont know</template>
</
category>

  <
category>
      <
pattern>WHY ^</pattern>
      <
that>I dont know</that>
      <
template>Because i do not have the required data</template>
</
category>

  <
category>
      <
pattern>HOW MANY PEOPLE LIVE IN ANTARCTICA</pattern>
      <
that>Because i do not have the required data</that>
      <
template>I have no idea.</template>
</
category>

</
aiml

 

 
  [ # 3 ]
Anonymous . - Oct 2, 2017:

Is there a way to fit different questions with multiple answers into one category?

Since any one AIML category can only have one <pattern> tag, the short answer is no. However, you can save yourself some coding time/effort by using the <srai> tag. To use a few AIML categories from your example code:

<category>
        <
pattern>WHAT IS NEW YORK</pattern>
        <
template>New York is a state in the northeastern United StatesIt is also a city that is located in that statwe.</template>
    </
category>

    <
category>
        <
pattern>* NEW YORK</pattern>
        <
template><srai>WHAT IS NEW YORK</srai></template>
    </
category>

    <
category>
        <
pattern>* NEW YORK *</pattern>
        <
template><srai>WHAT IS NEW YORK</srai></template>
    </
category

However, I should warn you that the above AIML categories will cause some unexpected results, if you’re not careful and thorough with your code. For example, with only these 3 AIML categories about New York, what do you suppose would happen if the following input:

I like New York Strip steaks 

Instead of talking about food, the bot is now spouting geography, which is, of course, unacceptable. In short, it’s wise to compose AIML that covers every reasonable meaning for a given term or phrase.

 

 
  [ # 4 ]

Thank you Dave for the answer. I have another question. Is it possible to display different answers for same question in one category.
For example:

[/code]
  
<category>
      <
pattern>* ANTARTICA</pattern>
      <
template>I dont know where Antarctica is</template>
</
category>

  <
category>
      <
pattern>WHY ^</pattern>
      <
that>I dont know where Antarctica is</that>
      <
template>Because it is not in my knowledgebase.</template>
</
category>

  <
category>
      <
pattern>HOW MANY PEOPLE LIVE IN ANTARCTICA</pattern>
      <
template>I dont know</template>
</
category>

  <
category>
      <
pattern>WHY ^</pattern>
      <
that>I dont know</that>
      <
template>Because i do not have the required data</template>
</
category>

  <
category>
      <
pattern>HOW MANY PEOPLE LIVE IN ANTARCTICA</pattern>
      <
that>Because i do not have the required data</that>
      <
template>I have no idea.</template>
</
category>[code] 
[/code][code] 
[/code] 

 

 
  [ # 5 ]

I see from your use of the caret (^) wildcard that you’re using an interpreter that supports AIML 2.0 - I REALLY need to get on the stick and get Program O to support that version. big surprise

Once again, the short answer to your question is “no”, but there are ways to get that result by using only a few categories. One of those ways is by using the <that> tag, as you’ve shown. Another, more efficient (though more complex to implement) is to use the <set> and <condition> tags. Composing a relevant, real world example of such code will take me a while, however, because I’m in the middle of work, so it will have to wait till I have some time to get it done. I’ll try to get it done tonight, but no promises. smile

 

 
  [ # 6 ]

Thanks again Dave.

 

 
  login or register to react