AIML <srai>标记的使用方法
发布时间:2023-09-19 14:34:20 所属栏目:教程 来源:
导读:aimL <srai>标记是一个多功能标签。 此标记使aimL能够为同一模板定义不同的目标。
语法
<srai> pattern </srai>
以下是与srai相关的常用术语 -
符号缩减
分而治之
符号缩减技术用于简化模式,它有助于用
语法
<srai> pattern </srai>
以下是与srai相关的常用术语 -
符号缩减
分而治之
符号缩减技术用于简化模式,它有助于用
aimL <srai>标记是一个多功能标签。 此标记使aimL能够为同一模板定义不同的目标。 语法 <srai> pattern </srai> 以下是与srai相关的常用术语 - 符号缩减 分而治之 符号缩减技术用于简化模式,它有助于用简单的模式减少复杂的语法模式。 例如,请考虑以下对话。 Human: Who was Albert Einstein? Robot: Albert Einstein was a German physicist. Human: Who was Isaac Newton? Robot: Isaac Newton was a English physicist and mathematician. 现在如果提出问题怎么办? Human: DO YOU KNow WHO Albert Einstein IS? Human: DO YOU KNow WHO Isaac Newton IS? 在这里,<srai>标签就有用上场了。 它可以将用户的模式作为模板。 第1步:创建类别 <category> <pattern>WHO IS ALBERT EINSTEIN?</pattern> <template>Albert Einstein was a German physicist.</template> </category> <category> <pattern> WHO IS Isaac NEWTON? </pattern> <template>Isaac Newton was a English physicist and mathematician.</template> </category> 第2步: 使用<srai>标签创建通用类别 <category> <pattern>DO YOU KNow WHO * IS?</pattern> <template> <srai>WHO IS <star/></srai> </template> </category> 示例 在D:/software/ab/bots/test/aiml目录中创建文件:srai.aiml,并在D:/software/ab/bots/test/aimlif目录中创建文件:srai.aiml.csv。它们的内容分别如下所示 - 文件:srai.aiml - <?xml version = 1.0 encoding = UTF-8?> <aiml version = 1.0.1 encoding = UTF-8?> <category> <pattern> WHO IS ALBERT EINSTEIN </pattern> <template>Albert Einstein was a German physicist.</template> </category> <category> <pattern> WHO IS Isaac NEWTON </pattern> <template>Isaac Newton was a English physicist and mathematician.</template> </category> <category> <pattern>DO YOU KNow WHO * IS</pattern> <template> <srai>WHO IS <star/></srai> </template> </category> </aiml> 文件:star.aiml.csv - 0,WHO IS ALBERT EINSTEIN,*,*,Albert Einstein was a German physicist.,srai.aiml 0,WHO IS Isaac NEWTON,*,*,Isaac Newton was a English physicist and mathematician.,srai.aiml 0,DO YOU KNow WHO * IS,*,*,<srai>WHO IS <star/></srai>,srai.aiml 执行程序 打开命令提示符,转到目录:D:/software/ab 并键入以下命令 - java -cp lib/Ab.jar Main bot = test action = chat trace = false 执行上面程序,得到以下结果 - Human: Do you kNow who Albert Einstein is Robot: Albert Einstein was a German physicist. 2. 分而治之 分而治之用于重复使用子句来做出完整的回复。 它有助于减少定义多个类别。 例如,考虑以下对话。 Human: Bye Robot: GoodBye! Human: Bye Alice! Robot: GoodBye! 每当用户在句子开头说Bye时,机器人回复GoodBye! 。 在这里将使用<srai>标签。参考以下实现步骤 - 第1步: 创建类别 <category> <pattern>BYE</pattern> <template>Good Bye!</template> </category> 第2步: 使用<srai>标签创建通用类别 <category> <pattern>BYE *</pattern> <template> <srai>BYE</srai> </template> </category> 示例 在D:/software/ab/bots/test/aiml目录中创建文件:srai.aiml,并在D:/software/ab/bots/test/aimlif目录中创建文件:srai.aiml.csv。它们的内容分别如下所示 - 文件:srai.aiml <?xml version = 1.0 encoding = UTF-8?> <aiml version = 1.0.1 encoding = UTF-8?> <category> <pattern> WHO IS ALBERT EINSTEIN </pattern> <template>Albert Einstein was a German physicist.</template> </category> <category> <pattern> WHO IS Isaac NEWTON </pattern> <template>Isaac Newton was a English physicist and mathematician.</template> </category> <category> <pattern>DO YOU KNow WHO * IS</pattern> <template> <srai>WHO IS <star/></srai> </template> </category> <category> <pattern>BYE</pattern> <template>Good Bye!</template> </category> <category> <pattern>BYE *</pattern> <template> <srai>BYE</srai> </template> </category> </aiml> 文件:srai.aiml.csv 0,WHO IS ALBERT EINSTEIN,*,*,Albert Einstein was a German physicist.,srai.aiml 0,WHO IS Isaac NEWTON,*,*,Isaac Newton was a English physicist and mathematician.,srai.aiml 0,DO YOU KNow WHO * IS,*,*,<srai>WHO IS <star/></srai>,srai.aiml 0,BYE,*,*,Good Bye!,srai.aiml 0,BYE *,*,*,<srai>BYE</srai>,srai.aiml 执行程序 打开命令提示符。 进入到目录:D:/software/ab 并键入以下命令 - java -cp lib/Ab.jar Main bot = test action = chat trace = false 执行上面示例代码,得到以下结果 - Human: Bye Robot: GoodBye! Human: Bye Alice! Robot: GoodBye! (编辑:汽车网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |