Sunday, November 13, 2011

C# .NET Web based chatterbot development with AIML - Part 3

Hi, here we go again.
As stated last time, today it is going to be the learning of some useful tags of AIML language, and the usage of the wild cards.


First we are going to talk about the <srai></srai> tag.


1) <srai></srai> tag is used to write the recursive categories. The usage of the <srai> tag gives the botmaster the opportunity to map the user input correctly with the knowledge base categories and give the most relevant answer.
Some interesting usages of the <srai> tag can be the partitioning of the sentence and the usage of synonyms.


a) Partitioning of the sentence
For example , an input sentence that begins with the word “Yes” and which has more words,” Yes” can be treated as a one sub sentence. The method can be implemented in the AIML language as follows.
<category>
<pattern>YES *</pattern>
<template><srai>YES</srai> <sr/></template>
</category>

Note -: </sr> tag is the shorten form for the tags <srai><star/></srai> .


Therefore, if the user input would be "Yes, I want to play cricket.", then the chatterbot will partition the sentence into two as "YES" and "I want to play cricket.". These two parts can be directed to two different categories which makes a proper output.


b) Synonyms
We all know that something can be said in more than one ways.
If we consider the following two categories:-

<category>
<pattern>HELLO</pattern>
<template>Hi there!</template>
</category>

<category>
<pattern>HI</pattern>
<template><srai>HELLO</srai></template>
</category>



Considering an example for an input pattern” HELLO” , the chatterbot response template would be “Hi there!” .And if the input pattern is “HI” then using the <srai> tag  "HI" will be directed to "HELLO"which also gives the answer “Hi there!”.


2) <that></that>


That tag refers to a previous chatterbot output.


If we consider an example input pattern “YES”. Then the chatterbot has to check for its previous response and output the answer. The example can be written in AIML as follows.
               <category> 
               <pattern>YES</pattern> 
               <that> DO YOU LIKE MOVIES </that> 
               <template> What's your favourite movie? </template> 
              </category>



There are lot more useful tags in the AIML language, and I strongly recommend you all to read the A Comparison Between Alice and Elizabeth Chatbot Systems to get a good knowledge and understanding about the chatterbot systems and the AIML language characteristics, importance and the usage.


Ok, now I hope you all will do your background reading to improve your understanding in the language of AIML. But lets talk a little about the wildcards usage here too.


1) "*"
If we take the examples as follows :-

<category>
<pattern>NO, I DO NOT WANT TO PLAY BECAUSE *</pattern>
<template>Ok, then let's talk about something else.</template>
</category>

Here the wildcard "*" used to represent all the wolds after the word "BECAUSE". The star wild card is used to represent one or more words in a pattern. If the chatterbot does not want to consider the user's reason for not liking the to play, then the category can be written as above.


2) A clarification to the wildcard "_" can be found in the following forum post.
AIML Pattern Matching


I hope you all are a little satisfied with the above explanation and the details. If you need more details about certain things you can read the links I have given throughout my posts. And today also I am giving you some of the valuable forum posts links.


1)AIML Pattern Matching - sentence splitting using the "_"
2)AIML Pattern Matching
3)AIML ‘topic’ tag
4)PROGRAM#- that tag issue with Web Site chatterbot development in c#


With my next post, I will discuss about how to design the brain (knowledge base) of the chatterbot with the needed categories.


Cheers!!


No comments:

Post a Comment