- 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:
广告