我在尝试理解AIML模式匹配是如何工作时遇到了问题。
_
和*
之间有什么区别?我应该如何使用它们来获得最佳匹配?
我只有this document,但缺少一些好的例子。
答案 0 :(得分:4)
A *将匹配任何内容,除非匹配单词或多个单词的模式
即使一个单词或多个单词的模式匹配
,_也会匹配任何内容 <pattern>BYE _</pattern>
没有意义,因为<pattern>BYE *</pattern>
匹配相同的模式,但<pattern>BYE _</pattern>
会影响<pattern>BYE * SEE YOU</pattern>
,而BYE *则不会。{/ p>
小心使用_,例如_会匹配任何东西,你的机器人每次都会给出相同的答案。
<pattern>_ A COUPLE OF WORDS *</pattern>
和<pattern>_ A COUPLE OF WORDS</pattern>
是使用_的正确方法,如果你想每次都能听到句子内部或句子末尾的句子。
答案 1 :(得分:0)
_和*都是通配符,不同之处在于它们应该用于模式匹配。
_ should be used before the word or phrase you're matching on
* should be used after the word or phrase you're matching on.
请参阅:AIML spec
为了更好地理解这一点,可能值得查看现有AIML机器人中的示例。
请参阅:Downloads,此Saluations.aiml有示例