- AIML 教程
- AIML - 主页
- AIML - 简介
- AIML - 环境设置
- AIML - 第一个应用
- AIML - 基本标签
- AIML - <star> 标签
- AIML - <srai> 标签
- AIML - <random> 标签
- AIML - <set>、<get> 标签
- AIML - <that> 标签
- AIML - <topic> 标签
- AIML - <think> 标签
- AIML - <condition> 标签
- AIML 有用资源
- AIML - 快速指南
- AIML - 有用资源
- AIML - 讨论
AIML - <think> 标签
<think> 标签用于在 AIML 中存储变量,而不会通知用户。
语法
使用 <think> 标签存储值
<think> <set name = "variable-name"> variable-value </set> </think>
例如,请考虑下列对话。
Human: My name is Mahesh Robot: Hello! Human: Byeee Robot: Hi Mahesh Thanks for the conversation!
示例
在C > ab > bots > test > aiml 和C > ab > bots > test > aimlif 目录中创建 think.aiml 和 think.aiml.csv。
think.aiml
<?xml version = "1.0" encoding = "UTF-8"?>
<aiml version = "1.0.1" encoding = "UTF-8"?>
<category>
<pattern>My name is *</pattern>
<template>
Hello!<think><set name = "username"> <star/></set></think>
</template>
</category>
<category>
<pattern>Byeee</pattern>
<template>
Hi <get name = "username"/> Thanks for the conversation!
</template>
</category>
</aiml>
think.aiml.csv
0,My name is *,*,*, Hello! <think><set name = "username"> <star/></set></think>,think.aiml 0,Byeee,*,*, Hi <get name = "username"/> Thanks for the conversation!,think.aiml
执行程序
打开命令提示符。转到 C > ab > 并键入以下命令 −
java -cp lib/Ab.jar Main bot = test action = chat trace = false
验证结果
你将看到以下输出 −
Human: My name is Mahesh Robot: Hello! Human: Byeee Robot: Hi Mahesh Thanks for the conversation!
广告