{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Augmenting the Alice chatbot\n", "\n", "ALICE is the original chatbot created with AIML. We can load it and then define additional rules on top of it. \n", "\n", "## Loading\n", "\n", "As we saw in a previous example, _Alice_ can be learned by using the appropriate magic:" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
Learning database: 'alice'
" ], "text/plain": [ "Learning database: 'alice'\n" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "Loading startup.xml... done (0.02 seconds)\n" ] }, { "data": { "text/html": [ "
Loading patterns
" ], "text/plain": [ "Loading patterns\n" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "Loading ai.aiml... done (0.07 seconds)\n", "Loading drugs.aiml... done (0.02 seconds)\n", "Loading money.aiml... done (0.04 seconds)\n", "Loading politics.aiml... done (0.00 seconds)\n", "Loading science.aiml... done (0.02 seconds)\n", "Loading emotion.aiml... done (0.06 seconds)\n", "Loading movies.aiml... done (0.01 seconds)\n", "Loading primeminister.aiml... done (0.01 seconds)\n", "Loading sex.aiml... done (0.08 seconds)\n", "Loading astrology.aiml... done (0.01 seconds)\n", "Loading food.aiml... done (0.03 seconds)\n", "Loading mp0.aiml... done (1.77 seconds)\n", "Loading primitive-math.aiml... done (0.01 seconds)\n", "Loading sports.aiml... done (0.01 seconds)\n", "Loading atomic.aiml... done (1.11 seconds)\n", "Loading geography.aiml... done (0.48 seconds)\n", "Loading mp1.aiml... done (1.52 seconds)\n", "Loading psychology.aiml... done (0.19 seconds)\n", "Loading stack.aiml... done (0.00 seconds)\n", "Loading badanswer.aiml... done (0.01 seconds)\n", "Loading gossip.aiml... done (0.03 seconds)\n", "Loading mp2.aiml... done (1.50 seconds)\n", "Loading pyschology.aiml... done (0.21 seconds)\n", "Loading stories.aiml... done (0.10 seconds)\n", "Loading biography.aiml... done (0.16 seconds)\n", "Loading history.aiml... done (0.00 seconds)\n", "Loading mp3.aiml... done (1.42 seconds)\n", "Loading reduction0.safe.aiml... done (2.40 seconds)\n", "Loading that.aiml... done (0.38 seconds)\n", "Loading bot.aiml... done (1.17 seconds)\n", "Loading humor.aiml... done (0.05 seconds)\n", "Loading mp4.aiml... done (1.27 seconds)\n", "Loading reduction1.safe.aiml... done (1.87 seconds)\n", "Loading update1.aiml... done (0.51 seconds)\n", "Loading bot_profile.aiml... done (0.03 seconds)\n", "Loading imponderables.aiml... done (0.02 seconds)\n", "Loading mp5.aiml... done (1.97 seconds)\n", "Loading reduction2.safe.aiml... done (1.02 seconds)\n", "Loading update_mccormick.aiml... done (0.02 seconds)\n", "Loading client.aiml... done (0.78 seconds)\n", "Loading inquiry.aiml... done (0.03 seconds)\n", "Loading mp6.aiml... done (0.71 seconds)\n", "Loading reduction3.safe.aiml... done (1.17 seconds)\n", "Loading wallace.aiml... done (0.29 seconds)\n", "Loading client_profile.aiml... done (0.11 seconds)\n", "Loading interjection.aiml... done (0.01 seconds)\n", "Loading music.aiml... done (0.01 seconds)\n", "Loading reduction4.safe.aiml... done (1.00 seconds)\n", "Loading xfind.aiml... done (0.02 seconds)\n", "Loading computers.aiml... done (0.06 seconds)\n", "Loading iu.aiml... done (0.01 seconds)\n", "Loading numbers.aiml... done (0.11 seconds)\n", "Loading reduction.names.aiml... done (2.75 seconds)\n", "Loading continuation.aiml... done (0.01 seconds)\n", "Loading knowledge.aiml... done (0.86 seconds)\n", "Loading personality.aiml... done (0.05 seconds)\n", "Loading reductions-update.aiml... done (0.01 seconds)\n", "Loading date.aiml... done (0.04 seconds)\n", "Loading literature.aiml... done (0.01 seconds)\n", "Loading phone.aiml... done (0.00 seconds)\n", "Loading religion.aiml... done (0.10 seconds)\n", "Loading default.aiml... done (1.28 seconds)\n", "Loading loebner10.aiml... done (0.00 seconds)\n", "Loading pickup.aiml... done (0.02 seconds)\n", "Loading salutations.aiml... done (0.02 seconds)\n" ] }, { "data": { "text/html": [ "
Loaded 98087 new patterns
" ], "text/plain": [ "Loaded 98087 new patterns\n" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "%learn alice" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Testing Alice\n", "\n", "Let's do some chit-chat" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
Hi there!
" ], "text/plain": [ "Hi there!\n" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "Hello" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
Glad to hear it. What's new?
" ], "text/plain": [ "Glad to hear it. What's new?\n" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "I'm fine" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
Are you asking about my preferred holiday spot ?
" ], "text/plain": [ "Are you asking about my preferred holiday spot ?\n" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "What's your preferred holiday spot?" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
I don't want to talk about that now.
" ], "text/plain": [ "I don't want to talk about that now.\n" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "Yes" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Adding categories to a loaded bot\n", "\n", "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" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
Record activated
" ], "text/plain": [ "Record activated\n" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "%record on" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now we define a couple of categories about holiday preferences" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
Loaded 4 new patterns
" ], "text/plain": [ "Loaded 4 new patterns\n" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "%aiml\n", "\n", "what is your preferred holiday *?\n", "holiday\n", "\n", "holiday\n", "summer or winter?\n", "\n", "summer\n", "summer or winter\n", "\n", "
  • I like to go to the beach
  • \n", "
  • I enjoy sailing
  • \n", "
    \n", "\n", "winter\n", "summer or winter\n", "I'm rather fond of cross-country skiing" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Testing\n", "\n", "Ok, now it should know about holidays. Let's ask again" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
    summer or winter?
    " ], "text/plain": [ "summer or winter?\n" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "What's your preferred holiday spot?" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
    I enjoy sailing
    " ], "text/plain": [ "I enjoy sailing\n" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "summer" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Saving\n", "\n", "It seems to work. We can now save the defined categories into the AIML file `holidays.aiml` so \n", "that it can be added to a future DB.\n", "\n", "(Of course we can also save the current full brain state, storing the loaded Alice bot + added categories \n", "into a single compiled state, also for future use)" ] }, { "cell_type": "code", "execution_count": 10, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
    Record saved to "holidays.aiml" (1 cells)
    " ], "text/plain": [ "Record saved to \"holidays.aiml\" (1 cells)\n" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "%record save holidays" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
    Version: 1.0 (2016-07-19)
    \n", "Author: Paulo Villegas
    " ] } ], "metadata": { "kernelspec": { "display_name": "AIML Chatbot", "language": "", "name": "aimlbot" }, "language_info": { "mimetype": "text/xml", "name": "Chatbot" } }, "nbformat": 4, "nbformat_minor": 0 }