Leveraging previous posts regarding math and “greater than” and “less than” functionality it is possible to create a BETWEEN category (it is not terribly fast but it is possible).
Using the between category it is possible to bracket ranges. In the sample pattern below inputs of 1-33 return an “A” rating; 34-66 a “B” rating, and 67-100 a “C” rating. You do not have to code all 100 inputs in a long condition statement. It is not fast or efficient and I doubt you could test very many ranges before the system bogs down. But for simple comparisons this will give your web hosted AIML Pandorabot an edge in the Turing test over other bots!
Code:
<?xml version="1.0" encoding="UTF-8"?>
<aiml versi>
<!-- This file requires the following other aiml files to work properly -->
<!-- File Dependencies: -->
<!-- basicmath_greaterthan.aiml -->
<!-- basicmath_lessthan.aiml -->
<!-- Between: -->
<category><pattern>IS * BETWEEN * AND * </pattern>
<template><think>
<set name="ANSWER"></set>
<set name="ANSWER"><srai>XIF <star/> BETWEEN <star index="2"/> AND <star index="3"/> THEN RETURN TRUE ELSE RETURN FALSE</srai></set>
</think><condition name="ANSWER">
<li value="TRUE">Why yes, <star/> is indeed between <star index="2"/> and <star index="3"/>. </li>
<li value="FALSE">Actually no, <star/> is not between <star index="2"/> and <star index="3"/>. </li>
<li>Huh, where am I? I was thinking about <get name="ANSWER"/></li>
</condition>
</template>
</category>
<category><pattern>XIF * BETWEEN * AND * THEN RETURN * ELSE RETURN *</pattern>
<template><think>
<set name="GREATERTHAN"><srai>XMATHCALC <star/> GREATER THAN <star index="2"/></srai></set>
<set name="LESSTHAN"><srai>XMATHCALC <star/> LESS THAN <star index="3"/></srai></set>
</think><condition name="GREATERTHAN">
<li value="1"><condition name="LESSTHAN">
<li value=" dash 1"><star index="4"/></li>
<li><star index="5"/></li>
</condition>
</li>
<li><star index="5"/></li>
</condition>
</template>
</category>
<category><pattern>GIVEN * WHAT IS THE RATING</pattern>
<template><think>
<set name="ANSWER">NOTFOUND</set>
<set name="ANSWER"><srai>XIF <star/> BETWEEN 0 AND 34 THEN RETURN A ELSE RETURN NOTFOUND</srai></set>
<condition name="ANSWER" value="NOTFOUND"><set name="ANSWER"><srai>XIF <star/> BETWEEN 33 AND 67 THEN RETURN B ELSE RETURN NOTFOUND</srai></set></condition>
<condition name="ANSWER" value="NOTFOUND"><set name="ANSWER"><srai>XIF <star/> BETWEEN 66 AND 101 THEN RETURN C ELSE RETURN NOTFOUND</srai></set></condition>
</think>The rating is <get name="ANSWER"/></template>
</category>
</aiml>