Quick Links

Download

Advertisements

AIML Basics and MakeAiml Templates Tutorial

Introduction

In this tutorial you will learn how to create and use <pattern> and <template> tags in the MakeAiml language.


Using MakeAiml to simplify

Anyone can see that the examples in previous tutorials contain more markup text surrounding the input and the response than the input and the response themselves require. This is where MakeAiml comes in. MakeAiml allows a programmer to reduce the amount of work required to write an AIML file by providing a shorthand way to represent AIML tags and their contents. MakeAiml files are simply text files filled with sentences. Each sentence must start with a character (to identify the corresponding AIML tag to generate) and contain no newlines (created when a user hits the enter key).


The previous example can be re-written very simply in MakeAiml with the following:


 
   p Hello
   t Hi! How are you?
					

That's it! Two simple lines of MakeAiml text to replace six lines of AIML. Once the MakeAiml file is written, all a programmer has to do is run MakeAiml, load the MakeAiml file, and click the "Generate" button. The user interface is very simple and has absolutely no learning curve.


Blots Designs

Comments

Comments are AIML tags that humans can read and bots will ignore. Comments allow a programmer to clarify parts of an AIML file or to provide an explanation of why something is the way it is. A comment can be inserted into an AIML document by typing:


   <!-- Insert some text here -->
				   

So, to add a comment to the previous AIML example:

   <aiml>
      <category>
         <!-- A bot will not know this line is here -->
         <pattern> HELLO </pattern>
         <template> Hi! How are you? </template>
      <category>
   </aiml>
					

A comment's abbreviation in MakeAiml shorthand is an exclamation mark !. The above aiml file can now be written in MakeAiml by adding one line:

 
   ! A bot will not know this line is here
   p Hello
   t Hi! How are you?
					

Like before, a single character will designate the line as a comment and MakeAiml will generate the appropriate markup text accordingly.


Long MakeAiml Lines

As time progresses, AIML files will become very big and the responses can become very long. In order to get around this (because MakeAiml sentences are designated on a line-by-line basis) a user should use a single backslash character \ to let MakeAiml know that the next line is a continuation of the previous line. Here's an example:

   p Hello
   t Hi there! I hope you are \
     having a great day!
					

Leading and trailing spaces in the continued line are ignored by MakeAiml, so a user is able to format their MakeAiml files however they want to so it reads easily. The above MakeAiml will cause "Hi there! I hope you are having a great day!" to be generated entirely on one line between the <template> and </template> tags.


< Prev Tutorial     Next Tutorial >



About the Author

Grant Dryden works as a computer engineer. He writes software in C and C++ for embedded systems as well as firmware in VHDL. He has a Bachelor of Science in Computer Engineering.