加入收藏 | 设为首页 | 会员中心 | 我要投稿 汽车网 (https://www.0577qiche.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 教程 > 正文

AIML<set>, <get>标签的用法

发布时间:2023-09-20 13:34:59 所属栏目:教程 来源:
导读:<set>和<get>标签用于处理aimL中的变量。 变量可以是预定义变量或程序员创建的变量。

语法
<set>标签用于设置变量中的值。
<set name = variable-name> variable-value </set>
<get>标签用于从变量中获取值。
<set>和<get>标签用于处理aimL中的变量。 变量可以是预定义变量或程序员创建的变量。

语法
<set>标签用于设置变量中的值。
<set name = variable-name> variable-value </set>
<get>标签用于从变量中获取值。
<get name = variable-name></get>

例如,请考虑以下对话。
Human: I am Mahesh
Robot: Hello Mahesh!
Human: Good Night
Robot: Good Night Mahesh! Thanks for the conversation!

示例

在D:/software/ab/bots/test/aiml目录中创建一个文件:setget.aiml,并在D:/software/ab/bots/test/aimlif目录中创建一个文件:setget.aiml.csv。

文件:setget.aiml -
<?xml version = 1.0 encoding = UTF-8?>
<aiml version = 1.0.1 encoding = UTF-8?>
   <category>
      <pattern>I am *</pattern>
      <template>
         Hello <set name = username> <star/>! </set>
      </template>  
   </category>  
   <category>
      <pattern>Good Night</pattern>
      <template>
         Hi <get name = username/> Thanks for the conversation!
      </template>  
   </category>  
</aiml>

文件:setget.aiml.csv
0,I am *,*,*, Hello <set name = username> <star/>! </set>,setget.aiml
0,Good Night,*,*, Hi <get name = username/> Thanks for the conversation!,setget.aiml

执行程序

打开命令提示符。 进入到目录:D:/software/ab 并键入以下命令 -
java -cp lib/Ab.jar Main bot = test action = chat trace = false
执行上面示例代码,得到以下结果 -
Human: I am Mahesh
Robot: Hello Mahesh!
Human: Good Night
Robot: Good Night Mahesh! Thanks for the conversation!

(编辑:汽车网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章