AIML入门程序

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

创建项目结构

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

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

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

序号目录描述说明
1D:/software/ab/bots/test/aiml存储AIML文件
2D:/software/ab/bots/test/aimlif存储AIMLIF文件
3D:/software/ab/bots/test/config存储配置文件
4D:/software/ab/bots/test/sets存储AIML设置文件
5D:/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>

XML

文件:test.aiml.csv -

0,HELLO ALICE,*,*,Hello User,test.aiml

Csv

执行程序

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

D:/software/ab> java -cp lib/Ab.jar Main bot = test action = chat trace = false

Shell

验证结果
执行上面命令后,将会看到以下输出 -

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

Shell

输入Hello Alice并查看结果,然后键入其他任何内容以查看更改的结果。

Human: hello alice
Robot: Hello User
Human: bye
Robot: I have no answer for that.
Human:

Shell

如下图所示 -

  • 5
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

智慧浩海

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值