AIML - Balise <star>

<star> La balise est utilisée pour correspondre au caractère générique * caractère (s) dans la balise <modèle>.

Syntaxe

<star index = "n"/>

n signifie la position de * dans l'entrée utilisateur dans <pattern> Tag.

Prenons l'exemple suivant -

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

Si l'utilisateur entre "Une mangue est un fruit." alors bot répondra comme "Quand une mangue n'est pas un fruit?"

Exemple

Créer star.aiml à l'intérieur C > ab > bots > test > aiml et star.aiml.csv à l'intérieur C > ab > bots > test > aimlif répertoires.

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

Exécuter le programme

Ouvrez l'invite de commande. Aller àC > ab > et tapez la commande suivante -

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

Vérifiez le résultat

Vous verrez la sortie suivante -

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" /> est souvent utilisé comme <star />