AIML - <star> Tag

<star> Tag is used to match wild card * character(s) in <pattern> Tag.


<star index = "n"/>

n signifies the position of * within the user input in <pattern> Tag.

Consider the following example −

   <pattern> A * is a *. </pattern>
      When a <star index = "1"/> is not a <star index = "2"/>?

If the user enters "A mango is a fruit." then bot will respond as "When a mango is not a fruit?"


Create star.aiml inside C > ab > bots > test > aiml and star.aiml.csv inside C > ab > bots > test > aimlif directories.


<?xml version = "1.0" encoding = "UTF-8"?>
<aiml version = "1.0.1" encoding = "UTF-8"?>
      <pattern>I LIKE *</pattern>
         I too like <star/>.
      <pattern>A * IS A *</pattern>
         How <star index = "1"/> can not be a <star index = "2"/>?


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

Execute the Program

Open the command prompt. Go to C > ab > and type the following command −

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

Verify the Result

You will see the following output −

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"/> is often used as <star />