Tuesday, January 31, 2012

Why did the Catbot cross the Road?

I didn't post very much this month. Things have been busy. Well, they're always busy, but this month was different. As some of you know, I'm now at the Lake Branch. The last few weeks have been a real pleasure, getting to know the Lake staff and community. The Library is getting ready to start computer classes at Lake, and there are more good things in store. Besides this, I've been trying to learn how to use AIML conditions. I think I'm finally getting a handle on them. And there's no better way to learn than by having a bit of fun. So...

Why did the Catbot cross the Road?

We can use conditions to code our bot to respond to this question:



<category>
<pattern>CATBOTXROAD</pattern>
<template>
<think>
<set name="topic">BOTJOKE</set>
</think>
That's a secret. I bet you can't guess why the Catbot crossed the road.
</template>
</category>

<topic name="BOTJOKE">
<category>
<pattern>_</pattern>
<template>
<think>
<set name="answr"><star/></set>
<set name="message">wrong answer</set>
<condition name="answr">

<li value="WHY GUESS"><set name="message">why guess</set></li>
<li value="* WHY GUESS"><set name="message">why guess</set></li>
<li value="WHY * GUESS"><set name="message">why guess</set></li>
<li value="WHY GUESS *"><set name="message">why guess</set></li>
<li value="* WHY * GUESS"><set name="message">why guess</set></li>
<li value="WHY * GUESS *"><set name="message">why guess</set></li>
<li value="* WHY GUESS *"><set name="message">why guess</set></li>
<li value="* WHY * GUESS *"><set name="message">why guess</set></li>

<li value="OTHER SIDE"><set name="message">right answer</set></li>
<li value="* OTHER SIDE"><set name="message">right answer</set></li>
<li value="OTHER SIDE *"><set name="message">right answer</set></li>
<li value="* OTHER SIDE *"><set name="message">right answer</set></li>

<li value="GIVE UP"><set name="message">give up</set></li>
<li value="* GIVE UP"><set name="message">give up</set></li>
<li value="GIVE UP *"><set name="message">give up</set></li>
<li value="* GIVE UP *"><set name="message">give up</set></li>

<li value="WHY"><set name="message">give up</set></li>
<li value="* WHY"><set name="message">give up</set></li>
<li value="WHY *"><set name="message">give up</set></li>
<li value="* WHY *"><set name="message">give up</set></li>

</condition>
</think>

<condition name="message">
<li value="wrong answer">No. It's not <get name="answr"/>. Guess again.</li>

<li value="why guess">It's fun. Go ahead and guess or type "I give up."</li>

<li value="right answer">No, that was the chicken. It was to get to the other side. Of the Digital Divide!
That's Librarian Humor for you.
<think>
<set name="topic"></set>
</think></li>

<li value="give up">Give up? It was to get to the other side. Of the Digital Divide!
That's Librarian Humor for you.
<think>
<set name="topic"></set>
</think></li>

</condition>
</template>
</category>
</topic>




One advantage to using conditions is that it's easier to control the topic tags. Very useful. Does this have an application beyond programming the bot with awful jokes? Yes. In fact, all of the files containing library information are being rewritten, as are those files governing searches. Lots of work, but our Emma should be in good shape for Computers in Libraries 2012! Presenters get to go free, it'll be a blast!

No comments:

Post a Comment