Augmenting the Alice chatbot

ALICE is the original chatbot created with AIML. We can load it and then define additional rules on top of it.

Loading

As we saw in a previous example, Alice can be learned by using the appropriate magic:

In [1]:
%learn alice
Learning database: 'alice'
Loading startup.xml... done (0.02 seconds)
Loading patterns
Loading ai.aiml... done (0.07 seconds)
Loading drugs.aiml... done (0.02 seconds)
Loading money.aiml... done (0.04 seconds)
Loading politics.aiml... done (0.00 seconds)
Loading science.aiml... done (0.02 seconds)
Loading emotion.aiml... done (0.06 seconds)
Loading movies.aiml... done (0.01 seconds)
Loading primeminister.aiml... done (0.01 seconds)
Loading sex.aiml... done (0.08 seconds)
Loading astrology.aiml... done (0.01 seconds)
Loading food.aiml... done (0.03 seconds)
Loading mp0.aiml... done (1.77 seconds)
Loading primitive-math.aiml... done (0.01 seconds)
Loading sports.aiml... done (0.01 seconds)
Loading atomic.aiml... done (1.11 seconds)
Loading geography.aiml... done (0.48 seconds)
Loading mp1.aiml... done (1.52 seconds)
Loading psychology.aiml... done (0.19 seconds)
Loading stack.aiml... done (0.00 seconds)
Loading badanswer.aiml... done (0.01 seconds)
Loading gossip.aiml... done (0.03 seconds)
Loading mp2.aiml... done (1.50 seconds)
Loading pyschology.aiml... done (0.21 seconds)
Loading stories.aiml... done (0.10 seconds)
Loading biography.aiml... done (0.16 seconds)
Loading history.aiml... done (0.00 seconds)
Loading mp3.aiml... done (1.42 seconds)
Loading reduction0.safe.aiml... done (2.40 seconds)
Loading that.aiml... done (0.38 seconds)
Loading bot.aiml... done (1.17 seconds)
Loading humor.aiml... done (0.05 seconds)
Loading mp4.aiml... done (1.27 seconds)
Loading reduction1.safe.aiml... done (1.87 seconds)
Loading update1.aiml... done (0.51 seconds)
Loading bot_profile.aiml... done (0.03 seconds)
Loading imponderables.aiml... done (0.02 seconds)
Loading mp5.aiml... done (1.97 seconds)
Loading reduction2.safe.aiml... done (1.02 seconds)
Loading update_mccormick.aiml... done (0.02 seconds)
Loading client.aiml... done (0.78 seconds)
Loading inquiry.aiml... done (0.03 seconds)
Loading mp6.aiml... done (0.71 seconds)
Loading reduction3.safe.aiml... done (1.17 seconds)
Loading wallace.aiml... done (0.29 seconds)
Loading client_profile.aiml... done (0.11 seconds)
Loading interjection.aiml... done (0.01 seconds)
Loading music.aiml... done (0.01 seconds)
Loading reduction4.safe.aiml... done (1.00 seconds)
Loading xfind.aiml... done (0.02 seconds)
Loading computers.aiml... done (0.06 seconds)
Loading iu.aiml... done (0.01 seconds)
Loading numbers.aiml... done (0.11 seconds)
Loading reduction.names.aiml... done (2.75 seconds)
Loading continuation.aiml... done (0.01 seconds)
Loading knowledge.aiml... done (0.86 seconds)
Loading personality.aiml... done (0.05 seconds)
Loading reductions-update.aiml... done (0.01 seconds)
Loading date.aiml... done (0.04 seconds)
Loading literature.aiml... done (0.01 seconds)
Loading phone.aiml... done (0.00 seconds)
Loading religion.aiml... done (0.10 seconds)
Loading default.aiml... done (1.28 seconds)
Loading loebner10.aiml... done (0.00 seconds)
Loading pickup.aiml... done (0.02 seconds)
Loading salutations.aiml... done (0.02 seconds)
Loaded 98087 new patterns

Testing Alice

Let's do some chit-chat

In [2]:
Hello
Hi there!
In [3]:
I'm fine
Glad to hear it. What's new?
In [4]:
What's your preferred holiday spot?
Are you asking about my preferred holiday spot ?
In [5]:
Yes
I don't want to talk about that now.

Adding categories to a loaded bot

It seems our poor Alice bot has never gone on holiday. Let's put some holiday hobbies into it. But before that, let's activate AIML recording

In [6]:
%record on
Record activated

Now we define a couple of categories about holiday preferences

In [7]:
%aiml

what is your preferred holiday *?
<srai>holiday</srai>

holiday
summer or winter?

summer
<that>summer or winter
<random>
<li>I like to go to the beach</li>
<li>I enjoy sailing</li>
</random>

winter
<that>summer or winter
I'm rather fond of cross-country skiing
Loaded 4 new patterns

Testing

Ok, now it should know about holidays. Let's ask again

In [8]:
What's your preferred holiday spot?
summer or winter?
In [9]:
summer
I enjoy sailing

Saving

It seems to work. We can now save the defined categories into the AIML file holidays.aiml so that it can be added to a future DB.

(Of course we can also save the current full brain state, storing the loaded Alice bot + added categories into a single compiled state, also for future use)

In [10]:
%record save holidays
Record saved to "holidays.aiml" (1 cells)
Version: 1.0 (2016-07-19)
Author: Paulo Villegas