- AIML Tutorial
- AIML - Home
- AIML - Introduction
- AIML - Environment Setup
- AIML - First Application
- AIML - Basic Tags
- AIML - <star> Tag
- AIML - <srai> Tag
- AIML - <random> Tag
- AIML - <set>, <get> Tags
- AIML - <that> Tag
- AIML - <topic> Tag
- AIML - <think> Tag
- AIML - <condition> Tag
- AIML Useful Resources
- AIML - Quick Guide
- AIML - Useful Resources
- AIML - Discussion
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目录中创建 think.aiml ,并在C > ab > bots > test > aimlif目录中创建 think.aiml.csv。
思考目标
<?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!