AIML 模式匹配 - 如何?
我在尝试了解 AIML 模式匹配的工作原理时遇到问题。 _
和 *
有什么区别?我应该如何使用它们来获得最佳匹配?
我只有此文档,但缺少一些很好的示例。
I'm having a problem trying to understand how does AIML pattern matching works.
What's the difference between _
and *
? And how I should use them to get the best match?
I have this document only, but it lacks some good examples.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
A * 将匹配任何内容,除非一个单词或多个单词的模式匹配
即使一个单词或多个单词的模式可以匹配
BYE _
, _ 将匹配任何内容没有意义,因为BYE *
匹配相同的模式,但BYE _
将遮蔽BYE * 再见
而 BYE * 不会。小心使用 _,例如 _ 会匹配任何内容,并且您的机器人每次都会给出相同的答案。
_ A COUPLE OF WORDS *
和_ A COUPLE OF WORDS
是使用 _ 的正确方法如果您想捕获句子内部或末尾的所有单词。A * will match anything unless a pattern of a word or several words are matched
A _ will match anything even if a pattern of a word or several words could match
<pattern>BYE _</pattern>
does not make sense since<pattern>BYE *</pattern>
matches the same patterns but<pattern>BYE _</pattern>
will shadow<pattern>BYE * SEE YOU</pattern>
whereas BYE * won't.Use _ carefully, for example _ would match anything and your bot will give the same answer every times.
<pattern>_ A COUPLE OF WORDS *</pattern>
and<pattern>_ A COUPLE OF WORDS</pattern>
is the proper way to use _ if you want to catch every times A COUPLE OF WORDS is inside or at the end of a sentence._ 和 * 都是通配符,区别在于它们在模式匹配中应该使用的位置。
请参阅:AIML 规范
为了更好地理解这一点,可能值得查看示例在现有的 AIML 机器人中。
请参阅:下载,这个 Saluations.aiml 有示例
_ and * are both wildcards, the difference is where they should be used in pattern matching.
See: AIML spec
To understand this better it may be worth looking at examples in the existing AIML bots.
See: Downloads, this one Saluations.aiml has examples