1

I am trying to compare if the user's input matches the expected answer in AIML. I found this code that works well when the value is true but, for some reason I can't understand, fails when the match is false (there is no match for the and goes to UDC). If it worked, I could easily replace the second * with my maps result.

From: https://github.com/pandorabots/aiml-utilities/blob/master/lib/aimlstandardlibrary.aiml

<!-- STRING EQUALS-->
<category>
    <pattern>XEQ * XS *</pattern>
    <template>
        <learn>
            <category>
                <pattern>
                    <eval>
                        <uppercase>XFALSE <star/></uppercase>
                    </eval>
                </pattern>
                <template>TRUE</template>
            </category>
        </learn>
        <srai>XFALSE <star index="2"/></srai>
        <learn>
            <category>
                <pattern>
                    <eval>
                        <uppercase>XFALSE <star/></uppercase>
                    </eval>
                </pattern>
                <template>FALSE</template>
            </category>
        </learn>
    </template>
</category>

Does anyone have a better way to do it? Thanks a lot.

A. Kootstra
  • 6,827
  • 3
  • 20
  • 43
AClark
  • 13
  • 3

1 Answers1

1

Did you include the entire library AIML file? You need this category for it to work (it's at the top of the file):

<category>
  <pattern>
  XFALSE *
  </pattern>
  <template>FALSE</template>
</category>

Without it, the UDC will be called. A more efficient method would be to use the condition tag. This removes the need to use the <learn> tag to set up extra categories:

<category>
    <pattern>XEQ * XS *</pattern>
    <template>
        <think>
            <set name="value1"><star/></set>
            <set name="value2"><star index="2"/></set>
        </think>
        <condition name="value1">
            <li><value><get name="value2"/></value>TRUE</li>
            <li>FALSE</li>
        </condition>
    </template>
</category>
Steve Worswick
  • 880
  • 2
  • 5
  • 11
  • Thanks a lot Steve. You're right I hadn't included the entire library, and I certainly find your solution easier to understand. I tested it and works fine. – AClark Feb 03 '20 at 13:28