AIML - Balise <think>

<think> La balise est utilisée dans AIML pour stocker une variable sans avertir l'utilisateur.

Syntaxe

Stocker une valeur à l'aide de la balise <think>

<think> 
   <set name = "variable-name"> variable-value </set>
</think>

Par exemple, considérez la conversation suivante.

Human: My name is Mahesh
Robot: Hello!
Human: Byeee
Robot: Hi Mahesh Thanks for the conversation!

Exemple

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

think.aiml

<?xml version = "1.0" encoding = "UTF-8"?>
<aiml version = "1.0.1" encoding = "UTF-8"?>
   <category>
      <pattern>My name is *</pattern>
      <template>
         Hello!<think><set name = "username"> <star/></set></think>
      </template>  
   </category>  
   
   <category>
      <pattern>Byeee</pattern>
      <template>
         Hi <get name = "username"/> Thanks for the conversation!
      </template>  
   </category>  
   
</aiml>

think.aiml.csv

0,My name is *,*,*, Hello! <think><set name = "username"> <star/></set></think>,think.aiml
0,Byeee,*,*, Hi <get name = "username"/> Thanks for the conversation!,think.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: My name is Mahesh
Robot: Hello!
Human: Byeee
Robot: Hi Mahesh Thanks for the conversation!