
- 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!
廣告