
- 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 - 第一個應用
讓我們開始建立第一個機器人,當用戶輸入Hello Alice時,它會簡單地用Hello User!來問候使用者。
建立專案結構
如 AIML 環境設定 中所述,我們已將 program-ab 的內容提取到C > ab中,並具有以下目錄結構。
序號 | 目錄 & 描述 |
---|---|
1 | c:/ab/bots 儲存 AIML 機器人 |
2 | c:/ab/lib 儲存 Java 庫 |
3 | c:/ab/out Java 類檔案目錄 |
4 | c:/ab/run.bat 執行 Program AB 的批處理檔案 |
現在,在C > ab > bots中建立一個名為 test 的目錄,並在其中建立以下目錄。
序號 | 目錄 & 描述 |
---|---|
1 | c:/ab/bots/test/aiml 儲存 AIML 檔案 |
2 | c:/ab/bots/test/aimlif 儲存 AIMLIF 檔案 |
3 | c:/ab/bots/test/config 儲存配置檔案 |
4 | c:/ab/bots/test/sets 儲存 AIML 集 |
5 | c:/ab/bots/test/maps 儲存 AIML 對映 |
建立原始檔
在C > ab > bots > test > aiml中建立 test.aiml,並在C > ab > bots > test > aimlif目錄中建立 test.aiml.csv。
test.aiml
<?xml version = "1.0" encoding = "UTF-8"?> <aiml version="1.0.1" encoding = "UTF-8"?> <category> <pattern> HELLO ALICE </pattern> <template> Hello User </template> </category> </aiml>
test.aiml.csv
0,HELLO ALICE,*,*,Hello User,test.aiml
執行程式
開啟命令提示符。轉到C > ab >並輸入以下命令:
java -cp lib/Ab.jar Main bot = test action = chat trace = false
驗證結果
您將看到以下輸出:
Working Directory = C:\ab Program AB 0.0.4.2 beta -- AI Foundation Reference AIML 2.0 implementation bot = test action = chat trace = false trace mode = false Name = test Path = C:\ab/bots/test C:\ab C:\ab/bots C:\ab/bots/test C:\ab/bots/test/aiml C:\ab/bots/test/aimlif C:\ab/bots/test/config C:\ab/bots/test/logs C:\ab/bots/test/sets C:\ab/bots/test/maps Preprocessor: 0 norms 0 persons 0 person2 Get Properties: C:\ab/bots/test/config/properties.txt addAIMLSets: C:\ab/bots/test/sets does not exist. addCategories: C:\ab/bots/test/aiml does not exist. AIML modified Tue Apr 07 22:24:29 IST 2015 AIMLIF modified Tue Apr 07 22:26:53 I ST 2015 No deleted.aiml.csv file found No deleted.aiml.csv file found Loading AIML files from C:\ab/bots/test/aimlif Reading Learnf file Loaded 1 categories in 0.009 sec --> Bot test 1 completed 0 deleted 0 unfinished (1[6])--HELLO-->(1[5])--ALICE-->(1[4])--<THAT>-->(1[3])--*-->(1[2])--<TOPIC>-->( 1[1])--*-->(0[null,null]) Hello User... 7 nodes 6 singletons 1 leaves 0 shortcuts 0 n-ary 6 branches 0.85714287 average branching Human:
輸入Hello Alice檢視結果,然後輸入其他任何內容以檢視更改後的結果。
Human: hello alice Robot: Hello User Human: bye Robot: I have no answer for that. Human:
廣告