AIML <that>標籤
AIML <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.
示例
在D:/software/ab/bots/test/aiml
目錄中創建一個文件:that.aiml
,並在D:/software/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
執行程序
打開命令提示符。 進入目錄:D:/software/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.