AIML 标签模式匹配

huangapple go评论40阅读模式
英文:

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

&lt;category&gt;
&lt;pattern&gt;WHAT IS YOUR NAME&lt;/pattern&gt;
&lt;template&gt;My name is chatbot&lt;/template&gt;
&lt;/category&gt;

method no 1

&lt;category&gt;
&lt;pattern&gt;TELL ME *&lt;/pattern&gt;
&lt;template&gt;&lt;srai&gt;WHAT IS &lt;star/&gt;&lt;/srai&gt;&lt;/template&gt;
&lt;/category&gt;

method no 2

&lt;category&gt;
&lt;pattern&gt;TELL ME *&lt;/pattern&gt;
&lt;template&gt;&lt;sr/&gt;&lt;/template&gt;
&lt;/category&gt;

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

&lt;category&gt;
&lt;pattern&gt;IF YOU ARE COMFARTABLE WITH ME
&lt;/pattern&gt;
&lt;template&gt;Yes&lt;/template&gt;
&lt;/category&gt;
&lt;category&gt;
&lt;pattern&gt;TELL ME *&lt;/pattern&gt;
&lt;template&gt;&lt;srai&gt;WHAT IS &lt;star/&gt;&lt;/srai&gt;&lt;/template&gt;
&lt;/category&gt;

but this category would match

&lt;category&gt;
&lt;pattern&gt;TELL ME *&lt;/pattern&gt;
&lt;template&gt;&lt;sr/&gt;&lt;/template&gt;
&lt;/category&gt;

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

&lt;sr /&gt; 

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

&lt;category&gt;
&lt;pattern&gt;TELL ME *&lt;/pattern&gt;
&lt;template&gt;&lt;sr/&gt;&lt;/template&gt;
&lt;/category&gt;

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:

&lt;category&gt;
  &lt;pattern&gt;TELL ME IF * ARE *&lt;/pattern&gt;
  &lt;template&gt;&lt;srai&gt;Are &lt;star index=&quot;1&quot;/&gt; &lt;star index=&quot;2&quot;/&gt;&lt;/srai&gt;&lt;/template&gt;
&lt;/category&gt;

"Tell me if you are comfortable..." becomes "Are you comfortable..."

huangapple
  • 本文由 发表于 2023年7月10日 21:50:17
  • 转载请务必保留本文链接:https://go.coder-hub.com/76654419.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定