Friday, April 25, 2008

How to compare two variables in AIML

Steve Worswick (Square-Bear) has done something amazing. In AIML, there is no obvious way to compare to variables (or predicates, as they are called in AIML). But with a clever use of the Pandorabots AIML extensions and , Steve has come up with a way to compare to variables.

Pandorabots implemented and in order to help botmasters write scripts for their bots to learn new AIML categories from conversations. Steve has discovered that these extensions can also be used to create a dynamic extension to the language, that allows the botmaster to compare two variables.

Suppose the botmaster wants to compare two predicates with the values JOHN and PAUL.
The basic "trick" behind Steve's method is to "learn" a new category like

<pattern>BOTCHECK JOHN</pattern>

<set name="match">YES</set>


The comparison uses symbolic reduction to test <srai>BOTCHECK PAUL</srai>. This does not match the newly learned categroy with the pattern BOTCHECK JOHN. It does however match another category:

<pattern>BOTCHECK *</pattern>

<think><set name="match">NO</set> </think>

Only the input BOTCHECK JOHN will match the first category, in which case the predicates have the same value. The AIML Steve developed is a little more complicated than that, and you can find out all the details in his post to the mailing list.

You can download the free AIML variable comparison set from

No comments:

Post a Comment


blogger templates | Make Money Online