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