Search code examples
chatbotaiml

In AIML How To Use Wildcard Without Space


In Aiml I'm trying to detect random nonsense words but why is it not working? Here is the code

<category> 
<pattern>* f g h *</pattern> 
<template>What nonsense did you just typed??</template>
</category>

The response is

Human: hdhfghjrur
Robot: pattern did not matched

How do you use wildcards without giving space

Why is fgh not matching?


Solution

  • Wildcards match whole words, not just strings of letters but you can add an entry in your normal substitution file for each nonsense string you want to catch.

    ["fgh", " BadInput "],
    

    This will convert your sample input of hdhfghjrur to hdh BadInput jrur and then you can create a category to deal with this:

    <category>
        <pattern># BadInput ^</pattern>
        <template>What nonsense did you just type??</template>
    </category>