[alicebot-general] Response order
Dr. Rich Wallace
drwallace at gmail.com
Fri Feb 2 12:06:14 PST 2007
Hi Troy, one simple solution would be to change the * A$$ pattern to _
A$$, because the _ has higher matching priority in AIML.
(we all know that you can't have $ in patterns, but the example is
good because it shows a case where one keyword has priority over
another).
But generally speaking, there is a kind of "keyword priority problem"
in AIML. The typical technique for detecting keywords in AIML is to
use 4 categories per keyword:
<pattern>_ KEY</pattern>
<template><srai>KEY</srai></template>
<pattern>_ KEY _</pattern>
<template><srai>KEY</srai></template>
<pattern>KEY _</pattern>
<template><srai>KEY</srai></template>
and finally
<pattern>KEY</pattern>
<template>The answer.</template>
The problem arises when you have two or more keys that have an
ordering, like your example of FRIEND and A$$. You want to say that
the keyword A$$ "comes first". But if a sentence contains both
keywords, AIML makes no assumptions over which will match first, if
the mathcing patterns either both contain a prefix _ or are both
atomic. (This statement should be a little more complicated, because
as your example shows you can create a priority problem even if you
are using a * prefix to detect keywords).
Perhaps it should.
In this example, the patterns _ FRIEND _ and _ A$$ create a priority
problem. Whichever one is picked as the first match, depends on the
hashing algorithm used in the root Nodemapper.
Some people have solved the keyword priority problem by applying a
pre-processor to the AIML input, which will look for any of the "bad
keywords" and, if found, replace the whole AIML input with a special
pattern like "BAD WORD".
Yours sincerely,
Dr. Rich Wallace
On 2/2/07, Troy Vinson <troy.vinson at dal.tribalddb.com> wrote:
> In need of an AIML suggestion concerning ordering of a match or
> pre-scanning a sentence. Given these two patterns:
>
> <category>
> <pattern>
> * FRIEND *
> </pattern>
> <template>
> <srai>
> FRIEND RESPONSE
> </srai>
> </template>
> </category>
>
> <category>
> <pattern>
> * A$$
> </pattern>
> <template>
> <srai>
> BADWORD RESPONSE
> </srai>
> </template>
> </category>
>
>
> And the input "my friend can kiss my a$$". The desire is to have the
> pattern match and send a response for BADWORD RESPONSE instead of FRIEND
> RESPONSE.
>
> Any help would be greatly appreciated.
> _______________________________________________
> This is the alicebot-general mailing list
> Reply to alicebot-general at list.alicebot.org
> Unsubscribe and change preferences at http://list.alicebot.org/mailman/listinfo/alicebot-general
> Learn netiquette at http://www.dtcc.edu/cs/rfc1855.html
> Learn to read at http://www.literacy.org/
>
More information about the alicebot-general
mailing list