英文:
AIML <sr /> Tag Pattern Matching
问题
Here is the translation of your text:
问候 Stack Overflow 社区,我目前正在开发 AIML 聊天机器人,并遇到了一个问题,我想知道我的类别写法是否正确,或者是否会影响未来的类别。
以下是主要类别:
<category>
<pattern>你叫什么名字</pattern>
<template>我的名字是聊天机器人</template>
</category>
方法一:
<category>
<pattern>告诉我 *</pattern>
<template><srai>什么是<star/></srai></template>
</category>
方法二:
<category>
<pattern>告诉我 *</pattern>
<template><sr/></template>
</category>
我知道这两种类别方法都会匹配 "你叫什么名字"。
但是,如果用户问 "告诉我你是否对我感到舒适",在这种情况下,
<category>
<pattern>如果你对我感到舒适</pattern>
<template>是的</template>
</category>
但这个类别将会匹配:
<category>
<pattern>告诉我 *</pattern>
<template><srai>什么是<star/></srai></template>
</category>
但是,如果我在 "告诉我" 而不是 "什么是" 中使用 <sr/>
标签,将会发生什么情况?如果我以这种方式编写,模式是否会匹配失败?我想知道哪种方法是正确的。
正确的方法是如何编写 "告诉我" 类别以匹配 "你叫什么名字" 和 "如果你对我感到舒适或不舒适"。
英文:
greetings stackoverflow community i am currently developing aiml chatbot and stumbled across a problem i want to know if my method of writing category is correct or not? or will it affect future categories.
here is the main category
<category>
<pattern>WHAT IS YOUR NAME</pattern>
<template>My name is chatbot</template>
</category>
method no 1
<category>
<pattern>TELL ME *</pattern>
<template><srai>WHAT IS <star/></srai></template>
</category>
method no 2
<category>
<pattern>TELL ME *</pattern>
<template><sr/></template>
</category>
i knew that both category methods would match "what is your name"
but what if user asks "tell me if you are comfortable with me or not" in this case this <srai> category would not match
<category>
<pattern>IF YOU ARE COMFARTABLE WITH ME
</pattern>
<template>Yes</template>
</category>
<category>
<pattern>TELL ME *</pattern>
<template><srai>WHAT IS <star/></srai></template>
</category>
but this category would match
<category>
<pattern>TELL ME *</pattern>
<template><sr/></template>
</category>
it would match both "what is *" and "if you are comfortable with me or not" but my real question will it affect future categories if i use
<sr />
tag for "tell me" instead of "what is". Will patterns fail to match if i write in this way? i want to know which method is correct.
What is the correct way to write "tell me" catgeory in order to Match "what is your name" and "if you are comfartable with me or not"
答案1
得分: 0
你的方法2实际上不会起作用,因为类似于"TELL ME THE TIME"会变成"THE TIME"。
<category>
<pattern>TELL ME *</pattern>
<template><sr/></template>
</category>
我会说你的方法1是最好的,因为"Tell me..."通常意味着"What is..."。对于"Tell me if you are comfortable or not",我会创建缩短输入的类别,如下所示:
<category>
<pattern>TELL ME IF * ARE *</pattern>
<template><srai>Are <star index="1"/> <star index="2"/></srai></template>
</category>
"Tell me if you are comfortable..."变成"Are you comfortable..."。
英文:
Your method 2 wouldn't really work, as something like TELL ME THE TIME would become THE TIME
<category>
<pattern>TELL ME *</pattern>
<template><sr/></template>
</category>
I would say your method 1 is the best, as "Tell me..." usually means "What is...". For "Tell me if you are comfortable or not", I would make categories that shorten the input like this:
<category>
<pattern>TELL ME IF * ARE *</pattern>
<template><srai>Are <star index="1"/> <star index="2"/></srai></template>
</category>
"Tell me if you are comfortable..." becomes "Are you comfortable..."
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论