A lot of what you’re asking is extremely dependent upon the AIML interpreter that you’re using, but ideally, your second scenario is the case. HOWEVER:
your category is incomplete. Whenever there is one or more wildcard(s) (‘_’ or ‘*’) within a pattern, every single one should be accounted for. For example, in your category:
<category>
<pattern>_NAME IS *</pattern>
<template>
<sr/> <srai>NAME IS</srai>
</template>
</category>
<category>
there are two problems that I see. First off, there ALWAYS needs to be a space between your wildcard and the next or previous word. Where your pattern shows “_NAME IS *”, it needs to be “_ NAME IS *”. the reason is that your AIML interpreter will certainly have problems seeing a wildcard if it’s attached as part of another word. Thus the need for a space between.
The second problem is that the last wildcard isn’t processed at all, and in almost every circumstance, that completely ignores what could be important information, with respect to the context of the conversation (in this case, the person’s name). Your category just ignores the second wildcard, which loses data needed for the context. A better way to construct that particular category is as follows:
<category>
<pattern>_ NAME IS *</pattern>
<template>
<sr/> <srai>NAME IS</srai> <star index="2"/>
</template>
</category>
<category>
And even that is prone to cause some problems. Take for example, the following input:
“His name is synonymous with evil” (referring to Bill Gates, of course. )
That sentence is certain to be misinterpreted by the script, and will likely cause problems. This is a good example of why very careful thought should go into whether or not you should use the underscore wildcard in a pattern. The underscore is very powerful, but can be misused with frightening ease.
Now, notice that the second wildcard was referred to in the template as <star index=“2”>? This is to assure that one wildcard value doesn’t overwrite another. Consider this:
<category>
<pattern>* is * and * is *</pattern>
<template>
Do you mean to say that <star index="3"/> is <star index="4"/> while <star/> is <star index="2"/>?
</template>
</category>
What we see here is that you can have as many wildcards as we have words to separate them. You can’t have two wildcards in a row, without having at least a word or phrase between them (at least, as far as I know), because the interpreter won’t know where the cutoff is between one wildcard and the next. This category also shows an interesting way to make the bot appear to be listening, and taking an interest in the conversation, by rephrasing the given statement, and asking the user if this was what they meant.
I hope this helps.
[edit]
By the way, in your last category example, you left out a slash or two that would indicate a closing tag. It should look like this:
<category>
<pattern>HI HOW ARE YOU</pattern>
<template>
<srai>HI</srai><srai>HOW</srai><srai>ARE YOU</srai>
</template>
</category>
<category>
And by the way, while you CAN, indeed, have categories like this one, it’s not really recommended. When creating your own categories, it’s a good idea to come up with a basic pattern, and then think of how many other ways that you can say the exact same thing, but in different words, then try to reduce all of those ways into the fewest statements possible, by using one or two wildcards. Then, taking the same original statement, Think of how many different ways that you would respond to it, if someone else were to say it to you, and then reduce THEM down to as few responses as you can by using <srai> and <star> tags. Also remember that the <sr> tag will only substitute for the FIRST wildcard in a pattern. Any other wildcards to be processed by an <srai> tag will have to be coded out in full (e.g. <srai><star index=“2”></srai>, etc.).
[/edit]