
- 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 - <star> 標記
<star> 標記用於在 <pattern> 標記中匹配萬用字元 * 字元。
語法
<star index = "n"/>
n 表示使用者輸入在 <pattern> 標記中的 * 位置。
請考慮以下示例:
<category> <pattern> A * is a *. </pattern> <template> When a <star index = "1"/> is not a <star index = "2"/>? </template> </category>
如果使用者輸入“A mango is a fruit.”,則機器人將響應為“When a mango is not a fruit?”
示例
在 C > ab > bots > test > aiml 目錄和 C > ab > bots > test > aimlif 中建立 star.aiml 和 star.aiml.csv。
star.aiml
<?xml version = "1.0" encoding = "UTF-8"?> <aiml version = "1.0.1" encoding = "UTF-8"?> <category> <pattern>I LIKE *</pattern> <template> I too like <star/>. </template> </category> <category> <pattern>A * IS A *</pattern> <template> How <star index = "1"/> can not be a <star index = "2"/>? </template> </category> </aiml>
star.aiml.csv
0,I LIKE *,*,*,I too like <star/>.,star.aiml 0,A * IS A *,*,*,How <star index = "1"/> can not be a <star index = "2"/>?,star.aiml
執行程式
開啟命令提示符。轉到 C > ab > 然後鍵入以下命令:
java -cp lib/Ab.jar Main bot = test action = chat trace = false
驗證結果
將看到以下輸出:
Human: I like mango Robot: I too like mango. Human: A mango is a fruit Robot: How mango can not be a fruit?
<star index = "1"/> 通常用作 <star />
廣告