AIML <star>标记

<star>标签用于匹配<pattern>标签中的通配符*字符。

语法

<star index = "n"/>

XML

n表示<pattern>标签中用户输入中*的位置。

参考以下示例 -

<category>
   <pattern> A * is a *. </pattern>

   <template>
      When a <star index = "1"/> is not a <star index = "2"/>?
   </template>

</category>

XML

如果用户输入"A mango is a fruit."。 那么机器人会回答:"When a mango is not a fruit?"

示例

D:/software/ab/bots/test/aiml目录中创建一个文件:star.aiml,并在D:/software/ab/bots/test/aimlif目录中创建一个文件: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>

XML

文件: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

Csv

执行程序

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

java -cp lib/Ab.jar Main bot = test action = chat trace = false

Shell

将看到以下输出 -

Human: I like mango
Robot: I too like mango.
Human: A mango is a fruit
Robot: How mango can not be a fruit?

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

智慧浩海

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

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

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

打赏作者

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

抵扣说明:

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

余额充值