AIML - First Application



Let us start creating first bot which will simply greet a user with Hello User! when a user types Hello Alice.

Create the Project Structure

As in AIML Environment Setup, we've extracted content of program-ab in C > ab with the following directory structure.

S.No. Directory & Description
1

c:/ab/bots

Stores AIML bots

2

c:/ab/lib

Stores Java libraries

3

c:/ab/out

Java class file directory

4

c:/ab/run.bat

batch file for running Program AB

Now, create a directory test inside C > ab > bots and create the following directories in it.

S.No. Directory & Description
1

c:/ab/bots/test/aiml

Stores AIML files

2

c:/ab/bots/test/aimlif

Stores AIMLIF files

3

c:/ab/bots/test/config

Stores configuration files

4

c:/ab/bots/test/sets

Stores AIML Sets

5

c:/ab/bots/test/maps

Stores AIML Maps

Create Source Files

Create test.aiml inside C > ab > bots > test > aiml and test.aiml.csv inside C > ab > bots > test > aimlif directories.

test.aiml

<?xml version = "1.0" encoding = "UTF-8"?>
<aiml version="1.0.1" encoding = "UTF-8"?>
   <category>
      <pattern> HELLO ALICE </pattern>
      
      <template>
         Hello User
      </template>
      
   </category>
</aiml>

test.aiml.csv

0,HELLO ALICE,*,*,Hello User,test.aiml

Execute the Program

Open the command prompt. Go to C > ab > and type the following command −

java -cp lib/Ab.jar Main bot = test action="/?originalUrl=https%3A%2F%2Fdev.tutorialspoint.com%2Fchat%2520trace%2520%3D%2520false%253C%2Fpre">

Verify the Result

You'll see the following output −

Working Directory = C:\ab

Program AB 0.0.4.2 beta -- AI Foundation Reference AIML 2.0 implementation
bot = test
action="/?originalUrl=https%3A%2F%2Fdev.tutorialspoint.com%2Fchattrace%2520%3D%2520falsetrace%2520mode%2520%3D%2520falseName%2520%3D%2520test%2520Path%2520%3D%2520C%3A%2Fab%2Fbots%2FtestC%3A%2FabC%3A%2Fab%2FbotsC%3A%2Fab%2Fbots%2FtestC%3A%2Fab%2Fbots%2Ftest%2FaimlC%3A%2Fab%2Fbots%2Ftest%2FaimlifC%3A%2Fab%2Fbots%2Ftest%2FconfigC%3A%2Fab%2Fbots%2Ftest%2FlogsC%3A%2Fab%2Fbots%2Ftest%2FsetsC%3A%2Fab%2Fbots%2Ftest%2FmapsPreprocessor%3A%25200%2520norms%25200%2520persons%25200%2520person2Get%2520Properties%3A%2520C%3A%2Fab%2Fbots%2Ftest%2Fconfig%2Fproperties.txtaddAIMLSets%3A%2520C%3A%2Fab%2Fbots%2Ftest%2Fsets%2520does%2520not%2520exist.addCategories%3A%2520C%3A%2Fab%2Fbots%2Ftest%2Faiml%2520does%2520not%2520exist.AIML%2520modified%2520Tue%2520Apr%252007%252022%3A24%3A29%2520IST%25202015%2520AIMLIF%2520modified%2520Tue%2520Apr%252007%252022%3A26%3A53%2520IST%25202015No%2520deleted.aiml.csv%2520file%2520foundNo%2520deleted.aiml.csv%2520file%2520foundLoading%2520AIML%2520files%2520from%2520C%3A%2Fab%2Fbots%2Ftest%2FaimlifReading%2520Learnf%2520fileLoaded%25201%2520categories%2520in%25200.009%2520sec--%26gt%3B%2520Bot%2520test%25201%2520completed%25200%2520deleted%25200%2520unfinished(1%5B6%5D)--HELLO--%26gt%3B(1%5B5%5D)--ALICE--%26gt%3B(1%5B4%5D)--%26lt%3BTHAT%26gt%3B--%26gt%3B(1%5B3%5D)--*--%26gt%3B(1%5B2%5D)--%26lt%3BTOPIC%26gt%3B--%26gt%3B(1%5B1%5D)--*--%26gt%3B(0%5Bnull%2Cnull%5D)%2520Hello%2520User...7%2520nodes%25206%2520singletons%25201%2520leaves%25200%2520shortcuts%25200%2520n-ary%25206%2520branches%25200.85714287%2520averagebranchingHuman%3A%253C%2Fpre">

Type Hello Alice and see the result and then type anything else to see the changed result.

Human: hello alice
Robot: Hello User
Human: bye
Robot: I have no answer for that.
Human:
Advertisements