{"id":6151,"date":"2016-12-07T14:20:33","date_gmt":"2016-12-07T06:20:33","guid":{"rendered":"https:\/\/kyle.ai\/blog\/?p=6151"},"modified":"2016-12-07T14:57:52","modified_gmt":"2016-12-07T06:57:52","slug":"aiml-quick-guide","status":"publish","type":"post","link":"https:\/\/kyle.ai\/blog\/6151.html","title":{"rendered":"AIML &#8211; Quick Guide"},"content":{"rendered":"<h1>AIML &#8211; Basic Tags<\/h1>\n<p>In this tutorial, we&#8217;ll discuss the basic tags of AIML.<\/p>\n<ul>\n<li>&lt;aiml&gt; \u2212 defines the beginning and end of a AIML document.<\/li>\n<li>&lt;category&gt; \u2212 defines the unit of knowledge in Alicebot&#8217;s knowledge base.<\/li>\n<li>&lt;pattern&gt; \u2212 defines the pattern to match what a user may input to an Alicebot.<\/li>\n<li>&lt;template&gt; \u2212 defines the response of an Alicebot to user&#8217;s input.<\/li>\n<\/ul>\n<p>Following AIML files have been used here as reference.<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;?xml version = &quot;1.0&quot; encoding = &quot;UTF-8&quot;?&gt;\r\n&lt;aiml version = &quot;1.0.1&quot; encoding = &quot;UTF-8&quot;?&gt;\r\n &lt;category&gt;\r\n &lt;pattern&gt; HELLO ALICE &lt;\/pattern&gt;\r\n \r\n &lt;template&gt;\r\n Hello User\r\n &lt;\/template&gt;\r\n \r\n &lt;\/category&gt;\r\n&lt;\/aiml&gt;\r\n<\/pre>\n<h2>&lt;aiml&gt; tag<\/h2>\n<p>&lt;aiml&gt; tag marks the start and end of a AIML document. It contains version and encoding information under version and encoding attributes. version attribute stores the AIML version used by ALICE chatterbot Knowledge Base, KB. For example, we&#8217;ve used 1.0.1 version. This attribute is optional.<\/p>\n<p>Encoding attributes provide the character sets to be used in the document. For example, we&#8217;ve used UTF-8. As a mandatory requirement, &lt;aiml&gt; tag must contain at least one &lt;category&gt; tag. We can create multiple AIML files where each AIML file contains a single &lt;aiml&gt; tag. The purpose of each AIML file is to add at least a single knowledge unit called category to ALICE chatterbot KB.<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;aiml version = &quot;1.0.1&quot; encoding = &quot;UTF-8&quot;?&gt;\r\n ...\r\n&lt;\/aiml&gt;\r\n<\/pre>\n<h2>&lt;category&gt; tag<\/h2>\n<p>&lt;category&gt; tag is the fundamental knowledge unit of an ALICE Bot. Each category contains \u2212<\/p>\n<ul>\n<li>User input in the form of a sentence which can be an assertion, question, and exclamation etc. User input can contain wild card characters like * and _.<\/li>\n<li>Response to user input to be presented by Alicebot.<\/li>\n<li>Optional context.<\/li>\n<\/ul>\n<p>A &lt;category&gt; tag must have &lt;pattern&gt; and &lt;template&gt; tag. &lt;pattern&gt; represents the user input and template represents the bot&#8217;s response.<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;category&gt;\r\n &lt;pattern&gt; HELLO ALICE &lt;\/pattern&gt;\r\n \r\n &lt;template&gt;\r\n Hello User\r\n &lt;\/template&gt;\r\n \r\n&lt;\/category&gt;\r\n<\/pre>\n<p>Here, if the user enters Hello Alice then bot will respond back as Hello User.<\/p>\n<h2>&lt;pattern&gt; tag<\/h2>\n<p>The &lt;pattern&gt; tag represents a user&#8217;s input. It should be the first tag within the &lt;category&gt; tag. &lt;pattern&gt; tag can contain wild card to match more than one sentence as user input. For example, in our example, &lt;pattern&gt; contains HELLO ALICE.<\/p>\n<p>AIML is case-insensitive. If a user enters Hello Alice, hello alice, HELLO ALICE etc., all inputs are valid and bot will match them against HELLO ALICE.<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;category&gt;\r\n &lt;pattern&gt; HELLO ALICE &lt;\/pattern&gt;\r\n \r\n &lt;template&gt;\r\n Hello User\r\n &lt;\/template&gt;\r\n \r\n&lt;\/category&gt;\r\n<\/pre>\n<p>Here, the template is &#8220;Hello User&#8221; and represents a robot&#8217;s response to user input.<\/p>\n<h2>&lt;template&gt; tag<\/h2>\n<p>&lt;template&gt; tag represents the bot&#8217;s response to the user. It should be the second tag within the &lt;category&gt; tag. This &lt;template&gt; tag can save data, call another program, give conditional answers or delegate to other categories.<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;category&gt;\r\n &lt;pattern&gt; HELLO ALICE &lt;\/pattern&gt;\r\n \r\n &lt;template&gt;\r\n Hello User\r\n &lt;\/template&gt;\r\n \r\n&lt;\/category&gt;\r\n<\/pre>\n<p>Here, the template is &#8220;Hello User&#8221; and represents a robot&#8217;s response to the user input.<\/p>\n<h1>AIML &#8211; &lt;star&gt; Tag<\/h1>\n<p>&lt;star&gt; Tag is used to match wild card * character(s) in &lt;pattern&gt; Tag.<\/p>\n<h3>Syntax<\/h3>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;star index = &quot;n&quot;\/&gt;\r\n<\/pre>\n<p><strong>n<\/strong> signifies the position of * within the user input in &lt;pattern&gt; Tag.<\/p>\n<p>Consider the following example \u2212<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;category&gt;\r\n &lt;pattern&gt; A * is a *. &lt;\/pattern&gt;\r\n \r\n &lt;template&gt;\r\n When a &lt;star index = &quot;1&quot;\/&gt; is not a &lt;star index = &quot;2&quot;\/&gt;?\r\n &lt;\/template&gt;\r\n \r\n&lt;\/category&gt;\r\n<\/pre>\n<p>If the user enters &#8220;A mango is a fruit.&#8221; then bot will respond as &#8220;When a mango is not a fruit?&#8221;<\/p>\n<h3>Example<\/h3>\n<p>Create star.aiml inside C &gt; ab &gt; bots &gt; test &gt; aiml and star.aiml.csv inside C &gt; ab &gt; bots &gt; test &gt; aimlif directories.<\/p>\n<h3>star.aiml<\/h3>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;?xml version = &quot;1.0&quot; encoding = &quot;UTF-8&quot;?&gt;\r\n&lt;aiml version = &quot;1.0.1&quot; encoding = &quot;UTF-8&quot;?&gt;\r\n \r\n &lt;category&gt;\r\n &lt;pattern&gt;I LIKE *&lt;\/pattern&gt;\r\n &lt;template&gt;\r\n I too like &lt;star\/&gt;.\r\n &lt;\/template&gt;\r\n &lt;\/category&gt;\r\n \r\n &lt;category&gt;\r\n &lt;pattern&gt;A * IS A *&lt;\/pattern&gt;\r\n &lt;template&gt;\r\n How &lt;star index = &quot;1&quot;\/&gt; can not be a &lt;star index = &quot;2&quot;\/&gt;?\r\n &lt;\/template&gt;\r\n &lt;\/category&gt;\r\n \r\n&lt;\/aiml&gt;\r\n<\/pre>\n<h3>star.aiml.csv<\/h3>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n0,I LIKE *,*,*,I too like &lt;star\/&gt;.,star.aiml\r\n0,A * IS A *,*,*,How &lt;star index = &quot;1&quot;\/&gt; can not be a &lt;star index = &quot;2&quot;\/&gt;?,star.aiml\r\n<\/pre>\n<h3>Execute the Program<\/h3>\n<p>Open the command prompt. Go to C &gt; ab &gt; and type the following command \u2212<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\njava -cp lib\/Ab.jar Main bot = test action = chat trace = false\r\n<\/pre>\n<h3>Verify the Result<\/h3>\n<p>You will see the following output \u2212<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\nHuman: I like mango\r\nRobot: I too like mango.\r\nHuman: A mango is a fruit\r\nRobot: How mango can not be a fruit? \r\n<\/pre>\n<p>&lt;star index = &#8220;1&#8221;\/&gt; is often used as &lt;star \/&gt;<\/p>\n<h1>AIML &#8211; &lt;srai&gt; Tag<\/h1>\n<p>&lt;srai&gt; Tag is a multipurpose tag. This tag enables AIML to define the different targets for the same template.<\/p>\n<h3>Syntax<\/h3>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;srai&gt; pattern &lt;\/srai&gt;\u00a0\r\n<\/pre>\n<p>Following are the commonly used terms associated with srai \u2212<\/p>\n<ul>\n<li>Symbolic Reduction<\/li>\n<li>Divide and Conquer<\/li>\n<li>Synonyms resolution<\/li>\n<li>Keywords detection<\/li>\n<\/ul>\n<h2>Symbolic Reduction<\/h2>\n<p>The symbolic reduction technique is used to simplify patterns. It helps to reduce complex grammatical patterns with simple pattern(s).<\/p>\n<p>For example, consider the following conversation.<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\nHuman: Who was Albert Einstein?\r\nRobot: Albert Einstein was a German physicist.\r\nHuman: Who was Isaac Newton?\r\nRobot: Isaac Newton was a English physicist and mathematician.\r\n<\/pre>\n<p>Now What if questions are raised as<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\nHuman: DO YOU KNOW WHO Albert Einstein IS?\r\nHuman: DO YOU KNOW WHO Isaac Newton IS?\r\n<\/pre>\n<p>Here, &lt;srai&gt; tag works. It can take the pattern of the user as a template.<\/p>\n<p>Step 1: Create categories<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;category&gt;\r\n &lt;pattern&gt;WHO IS ALBERT EINSTEIN?&lt;\/pattern&gt;\r\n &lt;template&gt;Albert Einstein was a German physicist.&lt;\/template&gt;\r\n&lt;\/category&gt;\r\n\r\n&lt;category&gt;\r\n &lt;pattern&gt; WHO IS Isaac NEWTON? &lt;\/pattern&gt;\r\n &lt;template&gt;Isaac Newton was a English physicist and mathematician.&lt;\/template&gt;\r\n&lt;\/category&gt;\r\n<\/pre>\n<p>Step 2: Create generic category using &lt;srai&gt; tag<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;category&gt;\r\n &lt;pattern&gt;DO YOU KNOW WHO * IS?&lt;\/pattern&gt;\r\n \r\n &lt;template&gt;\r\n &lt;srai&gt;WHO IS &lt;star\/&gt;&lt;\/srai&gt;\r\n &lt;\/template&gt;\r\n \r\n&lt;\/category&gt;\r\n<\/pre>\n<h3>Example<\/h3>\n<p>Create srai.aiml inside C &gt; ab &gt; bots &gt; test &gt; aiml and srai.aiml.csv inside C &gt; ab &gt; bots &gt; test &gt; aimlif directories.<\/p>\n<h3>srai.aiml<\/h3>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;?xml version = &quot;1.0&quot; encoding = &quot;UTF-8&quot;?&gt;\r\n&lt;aiml version = &quot;1.0.1&quot; encoding = &quot;UTF-8&quot;?&gt;\r\n &lt;category&gt;\r\n &lt;pattern&gt; WHO IS ALBERT EINSTEIN &lt;\/pattern&gt;\r\n &lt;template&gt;Albert Einstein was a German physicist.&lt;\/template&gt;\r\n &lt;\/category&gt;\r\n \r\n &lt;category&gt;\r\n &lt;pattern&gt; WHO IS Isaac NEWTON &lt;\/pattern&gt;\r\n &lt;template&gt;Isaac Newton was a English physicist and mathematician.&lt;\/template&gt;\r\n &lt;\/category&gt;\r\n \r\n &lt;category&gt;\r\n &lt;pattern&gt;DO YOU KNOW WHO * IS&lt;\/pattern&gt;\r\n &lt;template&gt;\r\n &lt;srai&gt;WHO IS &lt;star\/&gt;&lt;\/srai&gt;\r\n &lt;\/template&gt;\r\n &lt;\/category&gt;\r\n&lt;\/aiml&gt;\r\n<\/pre>\n<h3>star.aiml.csv<\/h3>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n0,WHO IS ALBERT EINSTEIN,*,*,Albert Einstein was a German physicist.,srai.aiml\r\n0,WHO IS Isaac NEWTON,*,*,Isaac Newton was a English physicist and mathematician.,srai.aiml\r\n0,DO YOU KNOW WHO * IS,*,*,&lt;srai&gt;WHO IS &lt;star\/&gt;&lt;\/srai&gt;,srai.aiml\r\n<\/pre>\n<h3>Execute the Program<\/h3>\n<p>Open the command prompt. Go to C &gt; ab &gt; and type the following command \u2212<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\njava -cp lib\/Ab.jar Main bot = test action = chat trace = false\r\n<\/pre>\n<h3>Verify the Result<\/h3>\n<p>You will see the following output \u2212<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\nHuman: Do you know who Albert Einstein is\r\nRobot: Albert Einstein was a German physicist.\r\n<\/pre>\n<h2>Divide and Conquer<\/h2>\n<p>Divide and Conquer is used to reuse sub sentences in making a complete reply. It helps to reduce defining multiple categories.<\/p>\n<p>For example, consider following conversation.<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\nHuman: Bye\r\nRobot: GoodBye!\r\nHuman: Bye Alice!\r\nRobot: GoodBye!\r\n<\/pre>\n<p>Now here robot is expected to reply GoodBye! Whenever a user says Bye in the beginning of the sentence.<\/p>\n<p>Let&#8217;s put &lt;srai&gt; tag to work here.<\/p>\n<p>Step 1: Create category<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;category&gt;\r\n &lt;pattern&gt;BYE&lt;\/pattern&gt;\r\n &lt;template&gt;Good Bye!&lt;\/template&gt;\r\n&lt;\/category&gt;\r\n<\/pre>\n<p>Step 2: Create generic category using &lt;srai&gt; tag<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;category&gt;\r\n &lt;pattern&gt;BYE *&lt;\/pattern&gt;\r\n \r\n &lt;template&gt;\r\n &lt;srai&gt;BYE&lt;\/srai&gt;\r\n &lt;\/template&gt;\r\n \r\n&lt;\/category&gt;\r\n<\/pre>\n<h3>Example<\/h3>\n<p>Update srai.aiml inside C &gt; ab &gt; bots &gt; test &gt; aiml and srai.aiml.csv inside C &gt; ab &gt; bots &gt; test &gt; aimlif directories.<\/p>\n<h3>srai.aiml<\/h3>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;?xml version = &quot;1.0&quot; encoding = &quot;UTF-8&quot;?&gt;\r\n&lt;aiml version = &quot;1.0.1&quot; encoding = &quot;UTF-8&quot;?&gt;\r\n &lt;category&gt;\r\n &lt;pattern&gt; WHO IS ALBERT EINSTEIN &lt;\/pattern&gt;\r\n &lt;template&gt;Albert Einstein was a German physicist.&lt;\/template&gt;\r\n &lt;\/category&gt;\r\n \r\n &lt;category&gt;\r\n &lt;pattern&gt; WHO IS Isaac NEWTON &lt;\/pattern&gt;\r\n &lt;template&gt;Isaac Newton was a English physicist and mathematician.&lt;\/template&gt;\r\n &lt;\/category&gt;\r\n \r\n &lt;category&gt;\r\n &lt;pattern&gt;DO YOU KNOW WHO * IS&lt;\/pattern&gt;\r\n &lt;template&gt;\r\n &lt;srai&gt;WHO IS &lt;star\/&gt;&lt;\/srai&gt;\r\n &lt;\/template&gt;\r\n &lt;\/category&gt;\r\n \r\n &lt;category&gt;\r\n &lt;pattern&gt;BYE&lt;\/pattern&gt;\r\n &lt;template&gt;Good Bye!&lt;\/template&gt;\r\n &lt;\/category&gt;\r\n \r\n &lt;category&gt;\r\n &lt;pattern&gt;BYE *&lt;\/pattern&gt;\r\n &lt;template&gt;\r\n &lt;srai&gt;BYE&lt;\/srai&gt;\r\n &lt;\/template&gt;\r\n &lt;\/category&gt;\r\n \r\n&lt;\/aiml&gt;\r\n<\/pre>\n<h3>star.aiml.csv<\/h3>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n0,WHO IS ALBERT EINSTEIN,*,*,Albert Einstein was a German physicist.,srai.aiml\r\n0,WHO IS Isaac NEWTON,*,*,Isaac Newton was a English physicist and mathematician.,srai.aiml\r\n0,DO YOU KNOW WHO * IS,*,*,&lt;srai&gt;WHO IS &lt;star\/&gt;&lt;\/srai&gt;,srai.aiml\r\n0,BYE,*,*,Good Bye!,srai.aiml\r\n0,BYE *,*,*,&lt;srai&gt;BYE&lt;\/srai&gt;,srai.aiml\r\n<\/pre>\n<h3>Execute the Program<\/h3>\n<p>Open the command prompt. Go to C &gt; ab &gt; and type the following command \u2212<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\njava -cp lib\/Ab.jar Main bot = test action = chat trace = false\r\n<\/pre>\n<h3>Verify the Result<\/h3>\n<p>You will see the following output \u2212<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\nHuman: Bye\r\nRobot: GoodBye!\r\nHuman: Bye Alice!\r\nRobot: GoodBye!\r\n<\/pre>\n<h2>Synonyms Resolution<\/h2>\n<p>Synonyms are words with similar meanings. A bot should reply in the same manner for similar words.<\/p>\n<p>For example, consider the following conversation.<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\nHuman: Factory\r\nRobot: Development Center!\r\nHuman: Industry\r\nRobot: Development Center!\r\n<\/pre>\n<p>Now here robot is expected to reply Development Center! whenever a user says Factory or Industry.<\/p>\n<p>Let&#8217;s put &lt;srai&gt; tag to work here.<\/p>\n<p>Step 1: Create category<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;category&gt;\r\n &lt;pattern&gt;FACTORY&lt;\/pattern&gt;\r\n &lt;template&gt;Development Center!&lt;\/template&gt;\r\n&lt;\/category&gt;\r\n<\/pre>\n<p>Step 2: Create generic category using &lt;srai&gt; tag<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;category&gt;\r\n &lt;pattern&gt;INDUSTRY&lt;\/pattern&gt;\r\n \r\n &lt;template&gt;\r\n &lt;srai&gt;FACTORY&lt;\/srai&gt;\r\n &lt;\/template&gt;\r\n \r\n&lt;\/category&gt;\r\n<\/pre>\n<h3>Example<\/h3>\n<p>Update srai.aiml inside C &gt; ab &gt; bots &gt; test &gt; aiml and srai.aiml.csv inside C &gt; ab &gt; bots &gt; test &gt; aimlif directories.<\/p>\n<h3>srai.aiml<\/h3>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;?xml version = &quot;1.0&quot; encoding = &quot;UTF-8&quot;?&gt;\r\n&lt;aiml version = &quot;1.0.1&quot; encoding = &quot;UTF-8&quot;?&gt;\r\n &lt;category&gt;\r\n &lt;pattern&gt; WHO IS ALBERT EINSTEIN &lt;\/pattern&gt;\r\n &lt;template&gt;Albert Einstein was a German physicist.&lt;\/template&gt;\r\n &lt;\/category&gt;\r\n \r\n &lt;category&gt;\r\n &lt;pattern&gt; WHO IS Isaac NEWTON &lt;\/pattern&gt;\r\n &lt;template&gt;Isaac Newton was a English physicist and mathematician.&lt;\/template&gt;\r\n &lt;\/category&gt;\r\n \r\n &lt;category&gt;\r\n &lt;pattern&gt;DO YOU KNOW WHO * IS&lt;\/pattern&gt;\r\n &lt;template&gt;\r\n &lt;srai&gt;WHO IS &lt;star\/&gt;&lt;\/srai&gt;\r\n &lt;\/template&gt;\r\n &lt;\/category&gt;\r\n \r\n &lt;category&gt;\r\n &lt;pattern&gt;BYE&lt;\/pattern&gt;\r\n &lt;template&gt;Good Bye!&lt;\/template&gt;\r\n &lt;\/category&gt;\r\n \r\n &lt;category&gt;\r\n &lt;pattern&gt;BYE *&lt;\/pattern&gt;\r\n &lt;template&gt;\r\n &lt;srai&gt;BYE&lt;\/srai&gt;\r\n &lt;\/template&gt;\r\n &lt;\/category&gt;\r\n \r\n &lt;category&gt;\r\n &lt;pattern&gt;FACTORY&lt;\/pattern&gt;\r\n &lt;template&gt;Development Center!&lt;\/template&gt;\r\n &lt;\/category&gt;\r\n \r\n &lt;category&gt;\r\n &lt;pattern&gt;INDUSTRY&lt;\/pattern&gt;\r\n &lt;template&gt;\r\n &lt;srai&gt;FACTORY&lt;\/srai&gt;\r\n &lt;\/template&gt;\r\n &lt;\/category&gt;\r\n \r\n&lt;\/aiml&gt;\r\n<\/pre>\n<h3>star.aiml.csv<\/h3>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n0,WHO IS ALBERT EINSTEIN,*,*,Albert Einstein was a German physicist.,srai.aiml\r\n0,WHO IS Isaac NEWTON,*,*,Isaac Newton was a English physicist and mathematician.,srai.aiml\r\n0,DO YOU KNOW WHO * IS,*,*,&lt;srai&gt;WHO IS &lt;star\/&gt;&lt;\/srai&gt;,srai.aiml\r\n0,BYE,*,*,Good Bye!,srai.aiml\r\n0,BYE *,*,*,&lt;srai&gt;BYE&lt;\/srai&gt;,srai.aiml\r\n0,FACTORY,*,*,Development Center!,srai.aiml\r\n0,INDUSTRY,*,*,&lt;srai&gt;FACTORY&lt;\/srai&gt;,srai.aiml\r\n<\/pre>\n<h3>Execute the Program<\/h3>\n<p>Open the command prompt. Go to C &gt; ab &gt; and type the following command \u2212<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\njava -cp lib\/Ab.jar Main bot = test action = chat trace = false\r\n<\/pre>\n<h3>Verify the Result<\/h3>\n<p>You will see the following output \u2212<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\nHuman: Factory\r\nRobot: Development Center!\r\nHuman: Industry\r\nRobot: Development Center!\r\n<\/pre>\n<h2>Keywords Detection<\/h2>\n<p>Using srai, we can return a simple response when the user types a specific keyword, say, School, no matter where &#8220;school&#8221; is present in the sentence.<\/p>\n<p>For example, consider the following conversation.<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\nHuman: I love going to school daily.\r\nRobot: School is an important institution in a child's life.\r\nHuman: I like my school.\r\nRobot: School is an important institution in a child's life.\r\n<\/pre>\n<p>Here, the robot is expected to reply a standard message &#8216;School is an important institution in a child&#8217;s life.&#8217; whenever a user has school in the sentence.<\/p>\n<p>Let&#8217;s put &lt;srai&gt; tag to work here. We&#8217;ll use wild-cards here.<\/p>\n<p>Step 1: Create category<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;category&gt;\r\n &lt;pattern&gt;SCHOOL&lt;\/pattern&gt;\r\n &lt;template&gt;School is an important institution in a child's life.&lt;\/template&gt;\r\n&lt;\/category&gt;\r\n<\/pre>\n<p>Step 2: Create generic categories using &lt;srai&gt; tag<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;category&gt;\r\n &lt;pattern&gt;_ SCHOOL&lt;\/pattern&gt;\r\n &lt;template&gt;\r\n &lt;srai&gt;SCHOOL&lt;\/srai&gt;\r\n &lt;\/template&gt;\r\n&lt;\/category&gt;\r\n\r\n&lt;category&gt;\r\n &lt;pattern&gt;_ SCHOOL&lt;\/pattern&gt;\r\n &lt;template&gt;\r\n &lt;srai&gt;SCHOOL&lt;\/srai&gt;\r\n &lt;\/template&gt;\r\n&lt;\/category&gt;\r\n\r\n&lt;category&gt;\r\n &lt;pattern&gt;SCHOOL *&lt;\/pattern&gt;\r\n &lt;template&gt;\r\n &lt;srai&gt;SCHOOL&lt;\/srai&gt;\r\n &lt;\/template&gt;\r\n&lt;\/category&gt;\r\n\r\n&lt;category&gt;\r\n &lt;pattern&gt;_ SCHOOL *&lt;\/pattern&gt;\r\n &lt;template&gt;\r\n &lt;srai&gt;SCHOOL&lt;\/srai&gt;\r\n &lt;\/template&gt;\r\n&lt;\/category&gt;\r\n<\/pre>\n<h3>Example<\/h3>\n<p>Update srai.aiml inside C &gt; ab &gt; bots &gt; test &gt; aiml and srai.aiml.csv inside C &gt; ab &gt; bots &gt; test &gt; aimlif directories.<\/p>\n<h3>srai.aiml<\/h3>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;?xml version = &quot;1.0&quot; encoding = &quot;UTF-8&quot;?&gt;\r\n&lt;aiml version = &quot;1.0.1&quot; encoding = &quot;UTF-8&quot;?&gt;\r\n &lt;category&gt;\r\n &lt;pattern&gt; WHO IS ALBERT EINSTEIN &lt;\/pattern&gt;\r\n &lt;template&gt;Albert Einstein was a German physicist.&lt;\/template&gt;\r\n &lt;\/category&gt;\r\n \r\n &lt;category&gt;\r\n &lt;pattern&gt; WHO IS Isaac NEWTON &lt;\/pattern&gt;\r\n &lt;template&gt;Isaac Newton was a English physicist and mathematician.&lt;\/template&gt;\r\n &lt;\/category&gt;\r\n \r\n &lt;category&gt;\r\n &lt;pattern&gt;DO YOU KNOW WHO * IS&lt;\/pattern&gt;\r\n &lt;template&gt;\r\n &lt;srai&gt;WHO IS &lt;star\/&gt;&lt;\/srai&gt;\r\n &lt;\/template&gt;\r\n &lt;\/category&gt;\r\n \r\n &lt;category&gt;\r\n &lt;pattern&gt;BYE&lt;\/pattern&gt;\r\n &lt;template&gt;Good Bye!&lt;\/template&gt;\r\n &lt;\/category&gt;\r\n \r\n &lt;category&gt;\r\n &lt;pattern&gt;BYE *&lt;\/pattern&gt;\r\n &lt;template&gt;\r\n &lt;srai&gt;BYE&lt;\/srai&gt;\r\n &lt;\/template&gt;\r\n &lt;\/category&gt;\r\n \r\n &lt;category&gt;\r\n &lt;pattern&gt;FACTORY&lt;\/pattern&gt;\r\n &lt;template&gt;Development Center!&lt;\/template&gt;\r\n &lt;\/category&gt;\r\n \r\n &lt;category&gt;\r\n &lt;pattern&gt;INDUSTRY&lt;\/pattern&gt;\r\n &lt;template&gt;\r\n &lt;srai&gt;FACTORY&lt;\/srai&gt;\r\n &lt;\/template&gt;\r\n &lt;\/category&gt;\r\n \r\n &lt;category&gt;\r\n &lt;pattern&gt;SCHOOL&lt;\/pattern&gt;\r\n &lt;template&gt;School is an important institution in a child's life.&lt;\/template&gt;\r\n &lt;\/category&gt; \r\n \r\n &lt;category&gt;\r\n &lt;pattern&gt;_ SCHOOL&lt;\/pattern&gt;\r\n &lt;template&gt;\r\n &lt;srai&gt;SCHOOL&lt;\/srai&gt;\r\n &lt;\/template&gt;\r\n &lt;\/category&gt;\r\n \r\n &lt;category&gt;\r\n &lt;pattern&gt;_ SCHOOL&lt;\/pattern&gt;\r\n &lt;template&gt;\r\n &lt;srai&gt;SCHOOL&lt;\/srai&gt;\r\n &lt;\/template&gt;\r\n &lt;\/category&gt;\r\n \r\n &lt;category&gt;\r\n &lt;pattern&gt;SCHOOL *&lt;\/pattern&gt;\r\n &lt;template&gt;\r\n &lt;srai&gt;SCHOOL&lt;\/srai&gt;\r\n &lt;\/template&gt;\r\n &lt;\/category&gt;\r\n \r\n &lt;category&gt;\r\n &lt;pattern&gt;_ SCHOOL *&lt;\/pattern&gt;\r\n &lt;template&gt;\r\n &lt;srai&gt;SCHOOL&lt;\/srai&gt;\r\n &lt;\/template&gt;\r\n &lt;\/category&gt;\r\n \r\n&lt;\/aiml&gt;\r\n<\/pre>\n<h3>star.aiml.csv<\/h3>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n0,WHO IS ALBERT EINSTEIN,*,*,Albert Einstein was a German physicist.,srai.aiml\r\n0,WHO IS Isaac NEWTON,*,*,Isaac Newton was a English physicist and mathematician.,srai.aiml\r\n0,DO YOU KNOW WHO * IS,*,*,&lt;srai&gt;WHO IS &lt;star\/&gt;&lt;\/srai&gt;,srai.aiml\r\n0,BYE,*,*,Good Bye!,srai.aiml\r\n0,BYE *,*,*,&lt;srai&gt;BYE&lt;\/srai&gt;,srai.aiml\r\n0,FACTORY,*,*,Development Center!,srai.aiml\r\n0,INDUSTRY,*,*,&lt;srai&gt;FACTORY&lt;\/srai&gt;,srai.aiml\r\n0,SCHOOL,*,*,School is an important institution in a child's life.,srai.aiml\r\n0,_ SCHOOL,*,*,&lt;srai&gt;SCHOOL&lt;\/srai&gt;,srai.aiml\r\n0,SCHOOL *,*,*,&lt;srai&gt;SCHOOL&lt;\/srai&gt;,srai.aiml\r\n0,_ SCHOOL *,*,*,&lt;srai&gt;SCHOOL&lt;\/srai&gt;,srai.aiml\r\n<\/pre>\n<h3>Execute the Program<\/h3>\n<p>Open the command prompt. Go to C &gt; ab &gt; and type the following command \u2212<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\njava -cp lib\/Ab.jar Main bot = test action = chat trace = false\r\n<\/pre>\n<h3>Verify the Result<\/h3>\n<p>You will see the following output \u2212<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\nHuman: I love going to school daily.\r\nRobot: School is an important institution in a child's life.\r\nHuman: I like my school.\r\nRobot: School is an important institution in a child's life.\r\n<\/pre>\n<h1>AIML &#8211; &lt;random&gt; Tag<\/h1>\n<p>&lt;random&gt; Tag is used to get random responses. This tag enables AIML to respond differently for the same input. &lt;random&gt; tag is used along with &lt;li&gt; tags. &lt;li&gt; tags carry different responses that are to be delivered to the user on a random basis.<\/p>\n<h3>Syntax<\/h3>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;random&gt;\r\n &lt;li&gt; pattern1 &lt;\/li&gt;\r\n &lt;li&gt; pattern2 &lt;\/li&gt;\r\n ...\r\n &lt;li&gt; patternN &lt;\/li&gt;\r\n&lt;\/random&gt;\r\n<\/pre>\n<p>For example, consider the following conversation.<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\nHuman: Hi\r\nRobot: Hello!\r\nHuman: Hi\r\nRobot: Hi! Nice to meet you!\r\n<\/pre>\n<h3>Example<\/h3>\n<p>Create random.aiml inside C &gt; ab &gt; bots &gt; test &gt; aiml and random.aiml.csv inside C &gt; ab &gt; bots &gt; test &gt; aimlif directories.<\/p>\n<h3>random.aiml<\/h3>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;?xml version = &quot;1.0&quot; encoding = &quot;UTF-8&quot;?&gt;\r\n&lt;aiml version = &quot;1.0.1&quot; encoding =&quot;UTF-8&quot;?&gt;\r\n &lt;category&gt;\r\n &lt;pattern&gt;HI&lt;\/pattern&gt;\r\n \r\n &lt;template&gt;\r\n &lt;random&gt;\r\n &lt;li&gt; Hello! &lt;\/li&gt;\r\n &lt;li&gt; Hi! Nice to meet you! &lt;\/li&gt;\r\n &lt;\/random&gt;\r\n &lt;\/template&gt;\r\n \r\n &lt;category&gt; \r\n&lt;\/aiml&gt;\r\n<\/pre>\n<h3>random.aiml.csv<\/h3>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n0,HI,*,*, &lt;random&gt;&lt;li&gt; Hello! &lt;\/li&gt;&lt;li&gt; Hi! Nice to meet you! &lt;\/li&gt;&lt;\/random&gt;,random.aiml\r\n<\/pre>\n<h3>Execute the Program<\/h3>\n<p>Open the command prompt. Go to C &gt; ab &gt; and type the following command \u2212<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\njava -cp lib\/Ab.jar Main bot = test action = chat trace = false\r\n<\/pre>\n<h3>Verify the Result<\/h3>\n<p>You will see the following output \u2212<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\nHuman: Hi\r\nRobot: Hi! Nice to meet you!\r\nHuman: Hi\r\nRobot: Hello!\r\n<\/pre>\n<p>Here, the response may vary considering random responses.<\/p>\n<h1>AIML &#8211; &lt;set&gt;, &lt;get&gt; Tags<\/h1>\n<p>&lt;set&gt; and &lt;get&gt; tags are used to work with variables in AIML. Variables can be predefined variables or programmer created variables.<\/p>\n<h3>Syntax<\/h3>\n<p>&lt;set&gt; tag is used to set value in a variable.<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;set name = &quot;variable-name&quot;&gt; variable-value &lt;\/set&gt;\r\n<\/pre>\n<p>&lt;get&gt; tag is used to get value from a variable.<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;get name = &quot;variable-name&quot;&gt;&lt;\/get&gt;\r\n<\/pre>\n<p>For example, consider the following conversation.<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\nHuman: I am Mahesh\r\nRobot: Hello Mahesh!\r\nHuman: Good Night\r\nRobot: Good Night Mahesh! Thanks for the conversation!\r\n<\/pre>\n<h3>Example<\/h3>\n<p>Create setget.aiml inside C &gt; ab &gt; bots &gt; test &gt; aiml and setget.aiml.csv inside C &gt; ab &gt; bots &gt; test &gt; aimlif directories.<\/p>\n<h3>setget.aiml<\/h3>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;?xml version = &quot;1.0&quot; encoding = &quot;UTF-8&quot;?&gt;\r\n&lt;aiml version = &quot;1.0.1&quot; encoding = &quot;UTF-8&quot;?&gt;\r\n &lt;category&gt;\r\n &lt;pattern&gt;I am *&lt;\/pattern&gt;\r\n &lt;template&gt;\r\n Hello &lt;set name = &quot;username&quot;&gt; &lt;star\/&gt;! &lt;\/set&gt;\r\n &lt;\/template&gt; \r\n &lt;\/category&gt; \r\n \r\n &lt;category&gt;\r\n &lt;pattern&gt;Good Night&lt;\/pattern&gt;\r\n &lt;template&gt;\r\n Hi &lt;get name = &quot;username&quot;\/&gt; Thanks for the conversation!\r\n &lt;\/template&gt; \r\n &lt;\/category&gt; \r\n \r\n&lt;\/aiml&gt;\r\n<\/pre>\n<h3>setget.aiml.csv<\/h3>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n0,I am *,*,*, Hello &lt;set name = &quot;username&quot;&gt; &lt;star\/&gt;! &lt;\/set&gt;,setget.aiml\r\n0,Good Night,*,*, Hi &lt;get name = &quot;username&quot;\/&gt; Thanks for the conversation!,setget.aiml\r\n<\/pre>\n<h3>Execute the Program<\/h3>\n<p>Open the command prompt. Go to C &gt; ab &gt; and type the following command \u2212<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\njava -cp lib\/Ab.jar Main bot = test action = chat trace = false\r\n<\/pre>\n<h3>Verify the Result<\/h3>\n<p>You will see the following output \u2212<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\nHuman: I am Mahesh\r\nRobot: Hello Mahesh!\r\nHuman: Good Night\r\nRobot: Good Night Mahesh! Thanks for the conversation!\r\n<\/pre>\n<h1>AIML &#8211; &lt;that&gt; Tag<\/h1>\n<p>&lt;that&gt; Tag is used in AIML to respond based on the context.<\/p>\n<h3>Syntax<\/h3>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;that&gt; template &lt;\/that&gt;\r\n<\/pre>\n<p>For example, consider the following conversation.<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\nHuman: Hi Alice! What about movies?\r\nRobot: Do you like comedy movies?\r\nHuman: No\r\nRobot: Ok! But I like comedy movies.\r\n<\/pre>\n<h3>Example<\/h3>\n<p>Create that.aiml inside C &gt; ab &gt; bots &gt; test &gt; aiml and that.aiml.csv inside C &gt; ab &gt; bots &gt; test &gt; aimlif directories.<\/p>\n<h3>that.aiml<\/h3>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;?xml version = &quot;1.0&quot; encoding = &quot;UTF-8&quot;?&gt;\r\n&lt;aiml version = &quot;1.0.1&quot; encoding = &quot;UTF-8&quot;?&gt;\r\n &lt;category&gt;\r\n &lt;pattern&gt;WHAT ABOUT MOVIES&lt;\/pattern&gt;\r\n &lt;template&gt;Do you like comedy movies&lt;\/template&gt; \r\n &lt;\/category&gt;\r\n \r\n &lt;category&gt;\r\n &lt;pattern&gt;YES&lt;\/pattern&gt;\r\n &lt;that&gt;Do you like comedy movies&lt;\/that&gt;\r\n &lt;template&gt;Nice, I like comedy movies too.&lt;\/template&gt;\r\n &lt;\/category&gt;\r\n \r\n &lt;category&gt;\r\n &lt;pattern&gt;NO&lt;\/pattern&gt;\r\n &lt;that&gt;Do you like comedy movies&lt;\/that&gt;\r\n &lt;template&gt;Ok! But I like comedy movies.&lt;\/template&gt;\r\n &lt;\/category&gt; \r\n \r\n&lt;\/aiml&gt;\r\n<\/pre>\n<h3>that.aiml.csv<\/h3>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n0,WHAT ABOUT MOVIES,*,*,Do you like comedy movies,that.aiml\r\n0,YES,Do you like comedy movies,*,Nice! I like comedy movies too.,that.aiml\r\n0,NO,Do you like comedy movies,*,Ok! But I like comedy movies.,that.aiml\r\n<\/pre>\n<h3>Execute the Program<\/h3>\n<p>Open the command prompt. Go to C &gt; ab &gt; and type the following command \u2212<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\njava -cp lib\/Ab.jar Main bot = test action = chat trace = false\r\n<\/pre>\n<h3>Verify the Result<\/h3>\n<p>You will see the following output \u2212<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\nHuman: What about movies?\r\nRobot: Do you like comedy movies?\r\nHuman: No\r\nRobot: Ok! But I like comedy movies.\r\n<\/pre>\n<h1>AIML &#8211; &lt;topic&gt; Tag<\/h1>\n<p>&lt;topic&gt; Tag is used in AIML to store a context so that later conversation can be done based on that context. Usually, &lt;topic&gt; tag is used in Yes\/No type conversation. It helps AIML to search categories written within the context of the topic.<\/p>\n<h3>Syntax<\/h3>\n<p>Define a topic using &lt;set&gt; tag<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;template&gt; \r\n &lt;set name = &quot;topic&quot;&gt; topic-name &lt;\/set&gt;\r\n&lt;\/template&gt;\r\n<\/pre>\n<p>Define the category using &lt;topic&gt; tag<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;topic name = &quot;topic-name&quot;&gt;\r\n &lt;category&gt;\r\n ...\r\n &lt;\/category&gt; \r\n&lt;\/topic&gt;\r\n<\/pre>\n<p>For example, consider the following conversation.<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\nHuman: let discuss movies\r\nRobot: Yes movies\r\nHuman: Comedy movies are nice to watch\r\nRobot: Watching good movie refreshes our minds.\r\nHuman: I like watching comedy\r\nRobot: I too like watching comedy.\r\n<\/pre>\n<p>Here bot responds taking &#8220;movie&#8221; as the topic.<\/p>\n<h3>Example<\/h3>\n<p>Create topic.aiml inside C &gt; ab &gt; bots &gt; test &gt; aiml and topic.aiml.csv inside C &gt; ab &gt; bots &gt; test &gt; aimlif directories.<\/p>\n<h3>topic.aiml<\/h3>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;?xml version = &quot;1.0&quot; encoding = &quot;UTF-8&quot;?&gt;\r\n&lt;aiml version = &quot;1.0.1&quot; encoding = &quot;UTF-8&quot;?&gt;\r\n &lt;category&gt;\r\n &lt;pattern&gt;LET DISCUSS MOVIES&lt;\/pattern&gt;\r\n &lt;template&gt;Yes &lt;set name = &quot;topic&quot;&gt;movies&lt;\/set&gt;&lt;\/template&gt; \r\n &lt;\/category&gt;\r\n \r\n &lt;topic name = &quot;movies&quot;&gt;\r\n &lt;category&gt;\r\n &lt;pattern&gt; * &lt;\/pattern&gt;\r\n &lt;template&gt;Watching good movie refreshes our minds.&lt;\/template&gt;\r\n &lt;\/category&gt;\r\n \r\n &lt;category&gt;\r\n &lt;pattern&gt; I LIKE WATCHING COMEDY! &lt;\/pattern&gt;\r\n &lt;template&gt;I like comedy movies too.&lt;\/template&gt;\r\n &lt;\/category&gt;\r\n \r\n &lt;\/topic&gt;\r\n&lt;\/aiml&gt;\r\n<\/pre>\n<h3>that.aiml.csv<\/h3>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n0,LET DISCUSS MOVIES,*,*,Yes &lt;set name = &quot;topic&quot;&gt;movies&lt;\/set&gt;,topic.aiml\r\n0,*,*,movies,Watching good movie refreshes our minds.,topic.aiml\r\n0,I LIKE WATCHING COMEDY!,*,movies,I like comedy movies too.,topic.aiml\r\n<\/pre>\n<h3>Execute the Program<\/h3>\n<p>Open the command prompt. Go to C &gt; ab &gt; and type the following command \u2212<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\njava -cp lib\/Ab.jar Main bot = test action = chat trace = false\r\n<\/pre>\n<h3>Verify the Result<\/h3>\n<p>You will see the following output \u2212<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\nHuman: let discuss movies\r\nRobot: Yes movies\r\nHuman: Comedy movies are nice to watch\r\nRobot: Watching good movie refreshes our minds.\r\nHuman: I like watching comedy\r\nRobot: I too like watching comedy.\r\n<\/pre>\n<h1>AIML &#8211; &lt;think&gt; Tag<\/h1>\n<p>&lt;think&gt; Tag is used in AIML to store a variable without notifying the user.<\/p>\n<h3>Syntax<\/h3>\n<p>Store a value using &lt;think&gt; tag<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;think&gt; \r\n &lt;set name = &quot;variable-name&quot;&gt; variable-value &lt;\/set&gt;\r\n&lt;\/think&gt;\r\n<\/pre>\n<p>For example, consider the following conversation.<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\nHuman: My name is Mahesh\r\nRobot: Hello!\r\nHuman: Byeee\r\nRobot: Hi Mahesh Thanks for the conversation!\r\n<\/pre>\n<h3>Example<\/h3>\n<p>Create think.aiml inside C &gt; ab &gt; bots &gt; test &gt; aiml and think.aiml.csv inside C &gt; ab &gt; bots &gt; test &gt; aimlif directories.<\/p>\n<h3>think.aiml<\/h3>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;?xml version = &quot;1.0&quot; encoding = &quot;UTF-8&quot;?&gt;\r\n&lt;aiml version = &quot;1.0.1&quot; encoding = &quot;UTF-8&quot;?&gt;\r\n &lt;category&gt;\r\n &lt;pattern&gt;My name is *&lt;\/pattern&gt;\r\n &lt;template&gt;\r\n Hello!&lt;think&gt;&lt;set name = &quot;username&quot;&gt; &lt;star\/&gt;&lt;\/set&gt;&lt;\/think&gt;\r\n &lt;\/template&gt; \r\n &lt;\/category&gt; \r\n \r\n &lt;category&gt;\r\n &lt;pattern&gt;Byeee&lt;\/pattern&gt;\r\n &lt;template&gt;\r\n Hi &lt;get name = &quot;username&quot;\/&gt; Thanks for the conversation!\r\n &lt;\/template&gt; \r\n &lt;\/category&gt; \r\n \r\n&lt;\/aiml&gt;\r\n<\/pre>\n<h3>think.aiml.csv<\/h3>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n0,My name is *,*,*, Hello! &lt;think&gt;&lt;set name = &quot;username&quot;&gt; &lt;star\/&gt;&lt;\/set&gt;&lt;\/think&gt;,think.aiml\r\n0,Byeee,*,*, Hi &lt;get name = &quot;username&quot;\/&gt; Thanks for the conversation!,think.aiml\r\n<\/pre>\n<h3>Execute the Program<\/h3>\n<p>Open the command prompt. Go to C &gt; ab &gt; and type the following command \u2212<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\njava -cp lib\/Ab.jar Main bot = test action = chat trace = false\r\n<\/pre>\n<h3>Verify the Result<\/h3>\n<p>You will see the following output \u2212<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\nHuman: My name is Mahesh\r\nRobot: Hello!\r\nHuman: Byeee\r\nRobot: Hi Mahesh Thanks for the conversation!\r\n<\/pre>\n<h1>AIML &#8211; &lt;condition&gt; Tag<\/h1>\n<p>&lt;condition&gt; Tag is similar to switch statements in programming language. It helps ALICE to respond to the matching input.<\/p>\n<h3>Syntax<\/h3>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;condition name = &quot;variable-name&quot; value = &quot;variable-value&quot;\/&gt;\r\n<\/pre>\n<p>For example, consider the following conversation.<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\nHuman: How are you feeling today\r\nRobot: I am happy!\r\n<\/pre>\n<p>Here we&#8217;ve stored happy as the state of ALICE and that is how it responds as &#8220;I am happy!&#8221;.<\/p>\n<h3>Example<\/h3>\n<p>Create condition.aiml inside C &gt; ab &gt; bots &gt; test &gt; aiml and condition.aiml.csv inside C &gt; ab &gt; bots &gt; test &gt; aimlif directories.<\/p>\n<h3>condition.aiml<\/h3>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;?xml version = &quot;1.0&quot; encoding = &quot;UTF-8&quot;?&gt;\r\n&lt;aiml version = &quot;1.0.1&quot; encoding = &quot;UTF-8&quot;?&gt;\r\n &lt;category&gt;\r\n &lt;pattern&gt; HOW ARE YOU FEELING TODAY &lt;\/pattern&gt;\r\n \r\n &lt;template&gt;\r\n &lt;think&gt;&lt;set name = &quot;state&quot;&gt; happy&lt;\/set&gt;&lt;\/think&gt;\r\n &lt;condition name = &quot;state&quot; value = &quot;happy&quot;&gt;\r\n I am happy!\r\n &lt;\/condition&gt;\r\n \r\n &lt;condition name = &quot;state&quot; value = &quot;sad&quot;&gt;\r\n I am sad!\r\n &lt;\/condition&gt;\r\n &lt;\/template&gt;\r\n \r\n &lt;\/category&gt;\r\n&lt;\/aiml&gt;\r\n<\/pre>\n<h3>condition.aiml.csv<\/h3>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n0,HOW ARE YOU FEELING TODAY,*,*,\r\n &lt;think&gt;\r\n &lt;set name = &quot;state&quot;&gt; happy&lt;\/set&gt;\r\n &lt;\/think&gt;\r\n \r\n &lt;condition name = &quot;state&quot; value = &quot;happy&quot;&gt;I am happy!&lt;\/condition&gt;\r\n &lt;condition name = &quot;state&quot; value = &quot;sad&quot;&gt;I am sad!&lt;\/condition&gt;,condition.aiml\r\n<\/pre>\n<h3>Execute the Program<\/h3>\n<p>Open the command prompt. Go to C &gt; ab &gt; and type the following command \u2212<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\njava -cp lib\/Ab.jar Main bot = test action = chat trace = false\r\n<\/pre>\n<h3>Verify the Result<\/h3>\n<p>You will see the following output \u2212<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\nHuman: How are you feeling today\r\nRobot: I am happy!\r\n<\/pre>\n<p>\u539f\u6587\uff1ahttps:\/\/www.tutorialspoint.com\/aiml\/aiml_quick_guide.htm<\/p>\n","protected":false},"excerpt":{"rendered":"<p>AIML &#8211; Basic Tags In this tutorial, we&#8217;ll d [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-6151","post","type-post","status-publish","format-standard","hentry","category-skill"],"_links":{"self":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/6151","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/comments?post=6151"}],"version-history":[{"count":8,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/6151\/revisions"}],"predecessor-version":[{"id":6159,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/6151\/revisions\/6159"}],"wp:attachment":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/media?parent=6151"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/categories?post=6151"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/tags?post=6151"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}