- 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 - <that> 标签
<that>标签在 AIML 中用于根据上下文进行响应。
句法
<that> template </that>
例如,考虑以下对话。
Human: Hi Alice! What about movies? Robot: Do you like comedy movies? Human: No Robot: Ok! But I like comedy movies.
例子
在C > ab > bots > test > aiml目录中创建 that.aiml并在C > ab > bots > test > aimlif目录中创建 that.aiml.csv。
that.aiml
<?xml version = "1.0" encoding = "UTF-8"?> <aiml version = "1.0.1" encoding = "UTF-8"?> <category> <pattern>WHAT ABOUT MOVIES</pattern> <template>Do you like comedy movies</template> </category> <category> <pattern>YES</pattern> <that>Do you like comedy movies</that> <template>Nice, I like comedy movies too.</template> </category> <category> <pattern>NO</pattern> <that>Do you like comedy movies</that> <template>Ok! But I like comedy movies.</template> </category> </aiml>
that.aiml.csv
0,WHAT ABOUT MOVIES,*,*,Do you like comedy movies,that.aiml 0,YES,Do you like comedy movies,*,Nice! I like comedy movies too.,that.aiml 0,NO,Do you like comedy movies,*,Ok! But I like comedy movies.,that.aiml
执行程序
打开命令提示符。转到C > ab >并输入以下命令 -
java -cp lib/Ab.jar Main bot = test action = chat trace = false
验证结果
您将看到以下输出 -
Human: What about movies? Robot: Do you like comedy movies? Human: No Robot: Ok! But I like comedy movies.