AIML - set get Tags وسوم الحصول والاسناد لغة نمذجة الذكاء الاصطناعي

 AIML - <set>, <get> Tags وسوم الحصول والاسناد لغة نمذجة الذكاء الاصطناعي

AIML - <set>, <get> Tags وسوم الحصول والاسناد لغة نمذجة الذكاء الاصطناعي

تُستخدم العلامات <set> و <get> للعمل مع المتغيرات في AIML. يمكن أن تكون المتغيرات متغيرات محددة مسبقًا أو متغيرات أنشأها المبرمج.

بناء الجملة

تستخدم علامة <set> لتعيين قيمة في متغير.

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

تستخدم العلامة <get> للحصول على قيمة من المتغير.

<get name = "variable-name"></get>

على سبيل المثال ، ضع في اعتبارك المحادثة التالية.

Human: I am Mahesh
Robot: Hello Mahesh!
Human: Good Night
Robot: Good Night Mahesh! Thanks for the conversation!

مثال

قم بإنشاء setget.aiml داخل C> ab> bots> test> aiml and setget.aiml.csv داخل C> ab> bots> test> أدلة aimlif .

setget.aiml

<?xml version = "1.0" encoding = "UTF-8"?>
<aiml version = "1.0.1" encoding = "UTF-8"?>
   <category>
      <pattern>I am *</pattern>
      <template>
         Hello <set name = "username"> <star/>! </set>
      </template>  
   </category>  
   
   <category>
      <pattern>Good Night</pattern>
      <template>
         Hi <get name = "username"/> Thanks for the conversation!
      </template>  
   </category>  
   
</aiml>

setget.aiml.csv

0,I am *,*,*, Hello <set name = "username"> <star/>! </set>,setget.aiml
0,Good Night,*,*, Hi <get name = "username"/> Thanks for the conversation!,setget.aiml

تنفيذ البرنامج

افتح موجه الأوامر. انتقل إلى C> ab> واكتب الأمر التالي -

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

تحقق من النتيجة

سترى الناتج التالي -

Human: I am Mahesh
Robot: Hello Mahesh!
Human: Good Night
Robot: Good Night Mahesh! Thanks for the conversation!