Hiya, Roger!
Yes, the _ wildcard always trumps the *
But bear in mind that the _ wildcard also trumps a direct match, as well. For example, let’s say you have 2 AIML categories that have the following patterns:
I LIKE _ BECAUSE ITS *
I LIKE PIZZA BECAUSE ITS *
If someone types in “I like pizza because its got cheese”, the first category will get selected instead of the direct match. In fact, because pattern #1 exists, pattern #2 will never get selected, ever, because the _ wildcard takes precedence. Furthermore, of the 2 examples that you list in your most recent post, the second one will also never be selected, for exactly the same reason. The _ wildcard is so powerful that it should only be used under very specific circumstances. The most common use is the removal of adverbs or other “filler words”, in a process known as “symbolic reduction”. Here are some full examples:
<category>
<pattern>_ JUST *</pattern>
<template><srai><star index="1"/> <star index="2"/></srai></template>
</category>
<category>
<pattern>_ REALLY *</pattern>
<template><srai><star index="1"/> <star index="2"/></srai></template>
</category>
<category>
<pattern>_ VERY *</pattern>
<template><srai><star index="1"/> <star index="2"/></srai></template>
</category>
<category>
<pattern>I M _</pattern>
<template><srai>I AM <star index="1"/></srai></template>
</category>
These categories will reduce inputs from these:
I just went to the store last night
She is really pretty
I’m very sorry
To these:
I went to the store last night
She is pretty
I am sorry
This is very useful for reducing the number of AIML categories that have to be written, but again, care must be used, because sometimes words are important, and removing the wrong word in a sentence can completely change the meaning.
Another potential use for the _ wildcard is for pre-processing every single input. Below is an example of such a pre-processing AIML category, similar to ones used in a popular Second Life chatbot script:
<category>
<pattern>_ NPCID * * * * * * * * *</pattern>
<template>
<think>
<set name="parm1"><star index="2"/></set>
<set name="parm2"><star index="3"/></set>
<set name="parm3"><star index="4"/></set>
<set name="parm4"><star index="5"/></set>
<set name="parm5"><star index="6"/></set>
<set name="parm6"><star index="7"/></set>
<set name="parm7"><star index="8"/><set>
<set name="parm8"><star index="9"/></set>
<set name="parm9"><star index="10"/></set>
</think>
<sr/>
</template>
</category>
In the example above, the SL script generates all of the content from “NPCID” to the end, and appends it to the user’s chat input. This pre-processor category then sets all of the passed parameters, and then sends the user’s chat along to be parsed. When used in this way, it’s extremely useful, and generally won’t cause issues.
I hope that this helps.