Skip to content

AIML Tutorial

Keith Sterling edited this page Aug 30, 2017 · 27 revisions

AIML XML Files

All AIML files start the same way, with an XML declaration and a root level tag

<?xml version="1.0" encoding="UTF-8"?>
<aiml version="2.0">
</aiml>

Basic Question and Answer

When you boil it down to the basics, all AIML interactions are made up of 2 parts, a question and an answer. Each interaction is called a 'category', the question is a 'pattern' and the 'answer' is a template. These take the form like

<?xml version="1.0" encoding="UTF-8"?>
<aiml version="2.0">
    <category>
        <pattern>HELLO</pattern>
        <template>Hi there!</template>
    <category>
</aiml>

AIML uses the pattern to match the incoming text you type into Y-Bot, and if it finds a match it prints out the template. Running the bot with the above grammar and enter Hello as a question will show the following response

Loading, please wait...
No bot root argument set, defaulting to [/Users/keithsterling/Documents/Development/Python/Projects/AIML/program-y/bots/y-bot]
Y-Bot version 0.0.1, initiated March 14, 2017
Hi, how can I help you today?
>>> Hello
Hi there!
>>> 

You can build a lot of simple questions and answers with this form, but it becomes unmanageable when you get to very large numbers. You end up repeating yourself and trying to guess every possible combination of a question someone might ask.

Pattern Matching

Precendence
	$	Priority
	#	0 or more
	_ 	1 or more
	word
	set
	iset		
	bot
	regex
	^	0 or more
	*	1 or more

Sets

File based

Inbuilt

Dynamic

Regex

<regex>^[a-z]$</regex>

that

    <category>
        <pattern>HELLO</pattern>
        <that>WELCOME</that>
        <template>Hi there, again!</template>
    <category>

topic

    <category>
        <pattern>HELLO</pattern>
        <topic>GREETINGS</topic>
        <template>Hi there, again!</template>
    <category>

Properties

    <bot name="someproperty" />

Variables

Global

    <set name="someproperty">somevalue</set>
    <get name="someproperty" />

Local

    <set var="somevar">somevalue</set>
    <get var="somevar" />

Information

date
interval
id
program
size
vocabulary

Conversation

input
request
response
star
topicstar
thatstar

Random

Conditions

SRAI

sr

Maps

File based
Inbuilt
Dynamic

Text Translation

lowercase
uppercase
sentence
formal

Text Manipulation

normalize
denormalize
person
person2
gender

List Processing

implode
explode
first
rest

Logging

log

Knowledge

Learning

	learn
	resetlearn
	leanrf
	resetlearnf

RDF

	triples
		add triples
		delete triple
		select
		uniq

Extensions

External Servies

SRAIX
Search
system

Out of Band

XML/HTML

Authentication

Authorisation

See here for a full list of all Pattern Tags

See here for a full list of all Template Tags

Other AIML Tutorials

Tutorials Point Pandora Bots Program-N

Clone this wiki locally