I am learning AIML and have seen examples of the <condition>
element, such as:
<category>
<pattern>DO YOU FIND ME ATTRACTIVE</pattern>
<template>
<condition name="gender">
<li value="male">I find you very handsome.</li>
<li value="female">I find you very pretty.</li>
<li>I find you very attractive.</li>
</condition>
</template>
</category>
I would like to know if there is a way to form conjunctions or disjunctions. To extend the example, I would like to have outputs depend not just on gender
but also on a flag adult
.
Can conditions be nested, or could I use <think>
and <set>
when modifying variables or before the condition to get the same effect? I am using Pandorabots, in case that has any extensions (although I don't see any in their documentation).
You can do nested conditions but this soon starts to get very messy, especially if you have 3 or 4 levels. I would do this by setting a var with the contents of the predicates I want to check. Why a var rather than a name? Because you don't need to keep this predicate. It's only going to be used for this category. Vars are flushed after the category has been activated whereas "name" predicates are kept for other categories to use.
<category>
<pattern>DO YOU FIND ME ATTRACTIVE</pattern>
<template>
<think>
<set var="check"><get name="gender"/> <get name="adult"/></set>
</think>
<condition var="check">
<li value="male yes">I find you very handsome.</li>
<li value="female yes">You are a very beautiful woman.</li>
<li value="male no">Yes, you are a handsome boy.</li>
<li value="female no">Yes, you are a very pretty girl.</li>
<li>I find you very attractive.</li>
</condition>
</template>
</category>