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

<category>
<pattern>BOTCHECK JOHN</pattern>
<template>

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

</category>

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:

<category>
<pattern>BOTCHECK *</pattern>

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


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
http://www.square-bear.co.uk/aiml/botcompare.aiml

No comments:

Post a Comment

 

blogger templates | Make Money Online