This is brilliant Steve. I would have never thought of using <learn>
and <eval> to make a dynamic extension to the language. The
On Fri, Mar 28, 2008 at 4:08 PM, Dr. Rich Wallace <
> This is brilliant Steve. I would have never thought of using <learn>
> and <eval> to make a dynamic extension to the language. The
> possibilities are endless...
>
> On Thu, Mar 27, 2008 at 12:22 PM, Square Bear <
steve@...> wrote:
>
> > Excuse the lengthy post. I was checking through some old mailshots and found
> > that someone was wondering how to compare two variables to see if they
> > matched and so created a piece of AIML to do the job.
> >
> > With AIML, there is no easy way to compare two variables. Say for example,
> > you wanted to know if <get name="name"/> and <get name="friend"/> were the
> > same, you would have to do something like:
> >
> > <set name="check"><get name="name"/><get name="friend"/></set>
> > <condition name="check">
> > <li value="PAUL PAUL">They match.</li>
> > <li value="STEVE STEVE">They match.</li>
> > <li value="ALICE ALICE">They match.</li>
> > ....
> > ....
> > ....
> > and so on, including every name
> > ....
> > ....
> > ....
> > <li>They do not match.</li>
> > </condition>
> >
> > This would be ok if there were just a few options to check, but in the
> > example above, you would have to include EVERY possible person's name for
> > the category to work.
> >
> > I have written some AIML to get around this problem:
> >
http://www.square-bear.co.uk/aiml/botcompare.aiml> >
> > This contains a category called BOTCOMPARE which compares two values and
> > returns a variable called "match" which will be either YES if they are the
> > same, NO if they are different and FAIL if the BOTCOMPARE was called
> > incorrectly (no parameters or not enough parameters sent to BOTCOMPARE etc).
> >
> > In the example above we can now say:
> >
> > BOTCOMPARE <get name="name"/><get name="friend"/>
> >
> > <condition name="match">
> > <li value="YES">They match.</li>
> > <li value="NO">They do not match.</li>
> > </condition>
> >
> > The only limitation is that it can only check one word variables at the
> > moment.
> >
> > How it works
> >
> > It works by using the <eval> and <learn> tags of Pandorabots to create a
> > temporary category with the first value which it then checks using the
> > second value. Let's show an example.
> >
> > BOTCOMPARE PAUL STEVE
> >
> > This will set up a temporary category called BOTCHECK PAUL and then
> > <srai>BOTCHECK STEVE</srai>. As no category matches BOTCHECK STEVE, it calls
> > BOTCHECK * which sets the variable "match" to NO.
> >
> > However, the example "BOTCOMPARE PAUL PAUL" will do the same as above but
> > this time the <srai> will be to BOTCHECK PAUL which matches the temporary
> > category and sets the variable "match" to YES.
> >
> > One important thing to do after the comparison check is to clear the
> > temporary category. We do this by setting a new temporary category BOTCHECK
> > PAUL which is set to return "match" as NO and overwrites the original
> > temporary category. Otherwise BOTCHECK PAUL will exist and be called in
> > occurances such as BOTCHECK JAMES PAUL. This will return a match which would
> > be incorrect.
> >
> > Hope that all makes sense.
> >
> > You can see a demo of it by saying DEMOCOMPARE which will choose 10 random
> > things to compare.
> >
> > As usual, feel free to use it as you wish, upload it to your Pandorabot,
> > republish and you can call BOTCOMPARE in any AIML you wish. Due to it using
> > <eval> and <learn>, it will only work in a Pandorabot.
> >
> > Kind Regards
> > - Steve Worswick (Square Bear)
> >
http://www.square-bear.co.uk> >
> > _______________________________________________
> > This is the pandorabots-general mailing list
> > To Post, reply to
pandorabots-general@...
> > Unsubscribe and change preferences at
http://list.pandorabots.com/mailman/listinfo/pandorabots-general> > Learn netiquette at
http://www.dtcc.edu/cs/rfc1855.html> > Learn to read at
http://www.literacy.org/> >
>