加入收藏 | 设为首页 | 会员中心 | 我要投稿 汽车网 (https://www.0577qiche.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 教程 > 正文

AIML入门

发布时间:2023-09-19 14:34:20 所属栏目:教程 来源:
导读:在这章中,我们来学习如何创建一个机器人,当用户键入Hello Alice时,它能简单地用Hello User问候用户。

创建项目结构
与在aimL环境设置中一样,基于以下目录结构(D:/software/ab)。

序号 目录 描述说明
在这章中,我们来学习如何创建一个机器人,当用户键入Hello Alice时,它能简单地用Hello User问候用户。

创建项目结构
与在aimL环境设置中一样,基于以下目录结构(D:/software/ab)。

序号    目录    描述说明
1    D:/software/ab/bots    存储aimL机器人
2    D:/software/ab/lib    存储Java库
3    D:/software/ab/out    java类文件目录
4    D:/software/ab/run.bat    用于运行Program AB 的批处理文件

接下来,在D:/software/ab/bots中创建一个目录:test,并在test目录中创建以下子目录。

序号    目录    描述说明
1    D:/software/ab/bots/test/aiml    存储aimL文件
2    D:/software/ab/bots/test/aimlif    存储aimLIF文件
3    D:/software/ab/bots/test/config    存储配置文件
4    D:/software/ab/bots/test/sets    存储aimL设置文件
5    D:/software/ab/bots/test/maps    存储aimL映射
创建源文件
在D:/software/ab/bots/test/aiml目录中创建:test.aiml文件,以及在D:/software/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
执行程序

打开命令提示符,转到目录:D:/software/ab并键入以下命令 -

D:/software/ab> java -cp lib/Ab.jar Main bot = test action = chat trace = false
验证结果
执行上面命令后,将会看到以下输出 -

D:\software\ab>java -cp lib/Ab.jar Main bot=test action=chat trace=false
Working Directory = D:\software\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 = D:\software\ab/bots/test
D:\software\ab
D:\software\ab/bots
D:\software\ab/bots/test
D:\software\ab/bots/test/aiml
D:\software\ab/bots/test/aimlif
D:\software\ab/bots/test/config
D:\software\ab/bots/test/logs
D:\software\ab/bots/test/sets
D:\software\ab/bots/test/maps
Preprocessor: 0 norms 0 persons 0 person2
Get Properties: D:\software\ab/bots/test/config/properties.txt
Loading aimL Sets files from D:\software\ab/bots/test/sets
Loading aimL Map files from D:\software\ab/bots/test/maps
aimL modified Thu Dec 20 21:16:03 CST 2018 aimLIF modified Thu Dec 20 21:16:17 CST 2018
No deleted.aiml.csv file found
No deleted.aiml.csv file found
Loading aimL files from D:\software\ab/bots/test/aimlif
Loaded 1 categories in 0.007 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

输入Hello Alice并查看结果,然后键入其他任何内容以查看更改的结果。
Human: hello alice
Robot: Hello User
Human: bye
Robot: I have no answer for that.
 

(编辑:汽车网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章