- AIML Tutorial
 - AIML - Home
 - AIML - Introduction
 - AIML - Environment Setup
 - AIML - First Application
 - AIML - Basic Tags
 - AIML - <star> Tag
 - AIML - <srai> Tag
 - AIML - <random> Tag
 - AIML - <set>, <get> Tags
 - AIML - <that> Tag
 - AIML - <topic> Tag
 - AIML - <think> Tag
 - AIML - <condition> Tag
 
- AIML Useful Resources
 - AIML - Quick Guide
 - AIML - Useful Resources
 - AIML - Discussion
 
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>
如果用户输入“芒果是一种水果”。然后机器人会回复“当芒果不是水果时?”
例子
在C > ab > bots > test > aiml目录中创建 star.aiml ,并在C > ab > bots > test > aimlif目录中创建 star.aiml.csv。
明星目标
<?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>
星.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 />