According to http://www.alicebot.org/TR/2001/WD-aiml/ the tag and topic patterns should be appended to the match tree. That means, more specific <pattern> patterns have higher priority than more specific <that> patterns.
Using the code (and categories 1-5) below as an example.
This would give us the following matches:
in: THAT ASD
out: THAT ASD (cat 1)
in: THAT ASD
out: that THAT ASD (cat 4)
in: PATTERN ASD
out: pattern/that ASD (cat 5, not cat 2 because of ‘that’)
so far so good. reset interpreter.
in: THAT ASD (just to setup the ‘that’ again)
out: THAT ASD (cat 1)
in: PATTERN PATTERN ASD
out: pattern pattern ASD (here cat 3 has priority over cat 5)
So my question is: Is that the expected behavior or is my interpreter or my understanding of the AIML specs wrong? And if that is the correct behavior, how can I achieve similar results, eg. matching shorter patterns if a more specific ‘that’ is given.
<?xml version="1.0" encoding="utf-8"?>
<aiml versi>
<category>
<pattern>*</pattern>
<that>*</that>
<template><star/></template>
</category>
<category>
<pattern>PATTERN *</pattern>
<that>*</that>
<template>pattern <star/></template>
</category>
<category>
<pattern>PATTERN PATTERN *</pattern>
<that>*</that>
<template>pattern pattern <star/></template>
</category>
<category>
<pattern>*</pattern>
<that>THAT *</that>
<template>that <star/></template>
</category>
<category>
<pattern>PATTERN *</pattern>
<that>THAT *</that>
<template>pattern/that <star/></template>
</category>
</aiml>
Thanks for your help!