« Return to Thread: Math.aiml

Re: Math.aiml

by ciprianmp :: Rate this Message:

Reply to Author | View in Thread

Well, as I was afraid to, the attachemnt feature is not working. So I will paste bellow the aiml content:
<?xml version="1.0" encoding="UTF-8"?>
<aiml version="1.0">

<!-- Free software (c) 2001-2003 ALICE A.I. Foundation -->
<!-- This program is open source code released under -->
<!-- the terms of the GNU General Public License -->
<!-- as published by the Free Software Foundation. -->
<!-- Complies with AIML 1.0 Tag Set Specification -->
<!-- as adopted by the ALICE A.I. Foundation. -->
<!-- Math.aiml written by SonoranDiaries -->
<!-- Edited and revised by KnyteTrypper -->
<!-- Last edit May 20 2006 -->

<meta name="author" content="Sonoran Diaries"/>
<meta name="editor" content="Knyte Trypper"/>
<meta name="corrector" content="Ciprian Murariu"/>
<meta name="language" content="en"/>

<category>
<pattern>* PLUS *</pattern>
<template><think>
<set name="number1"><star /></set>
<set name="number2"><person><star index="2" /></person></set>
</think>
<random>
<li>Let me try it this way. The answer is </li>
<li>That's an easy one, The answer is </li>
<li>Let me see. I think the answer is </li>
<li>My calculator says the answer is </li>
<li>I believe the answer is </li>
<li>I don't enjoy math much. That's what computers are for. But the
answer to that one is </li>
</random>
<script language="JavaScript">
var result = <get name="number1"/> + <get name="number2"/>;
document.write(result+".");</script>
</template>
</category>

<category>
<pattern>* PLUS * EQUAL</pattern>
<template>
<srai><star /> PLUS <star index="2" /></srai>
</template>
</category>

<category>
<pattern>* PLUS * EQUALS</pattern>
<template>
<srai><star /> PLUS <star index="2" /></srai>
</template>
</category>

<category>
<pattern>WHAT IS * PLUS *</pattern>
<template>
<srai><star /> PLUS <star index="2" /></srai>
</template>
</category>

<category>
<pattern>WHAT IS * + *</pattern>
<template>
<srai><star /> PLUS <star index="2" /></srai>
</template>
</category>

<category>
<pattern>WHAT IS *+*</pattern>
<template>
<srai>* PLUS <star index="2" /></srai>
</template>
</category>

<category>
<pattern>ADD * PLUS *</pattern>
<template>
<srai><star /> PLUS <star index="2" /></srai>
</template>
</category>

<category>
<pattern>ADD * AND *</pattern>
<template>
<srai><star /> PLUS <star index="2" /></srai>
</template>
</category>

<category>
<pattern>ADD * + *</pattern>
<template>
<srai><star /> PLUS <star index="2" /></srai>
</template>
</category>

<category>
<pattern>ADD * + * =</pattern>
<template>
<srai><star /> PLUS <star index="2"/></srai>
</template>
</category>

<category>
<pattern>* MINUS *</pattern>
<template><think><set name="number1"><star /></set><set name="number2"><person><star index="2" /></person></set></think>
<random>
<li>Let me try it this way. The answer is </li>
<li>That's an easy one, The answer is </li>
<li>Let me see. I think the answer is </li>
<li>My calculator says the answer is </li>
<li>I believe the answer is </li>
<li>I don't enjoy math much. That's what computers are for. But the
answer to that one is </li>
</random>
<script language="JavaScript">
var result = <get name="number1"/> - <get name="number2"/>;
document.write(result+".");</script>
</template>
</category>

<category>
<pattern>* MINUS * EQUALS</pattern>
<template>
<srai><star /> MINUS <star index="2" /></srai>
</template>
</category>

<category>
<pattern>* MINUS * EQUAL</pattern>
<template>
<srai><star /> MINUS <star index="2" /></srai>
</template>
</category>

<category>
<pattern>* SUBTRACTED FROM *</pattern>
<template>
<srai><star /> MINUS <star index="2" /></srai>
</template>
</category>

<category>
<pattern>* SUBTRACTED FROM * EQUAL</pattern>
<template>
<srai><star /> MINUS <star index="2" /></srai>
</template>
</category>

<category>
<pattern>* SUBTRACTED FROM * EQUALS</pattern>
<template>
<srai><star /> MINUS <star index="2" /></srai>
</template>
</category>

<category>
<pattern>SUBTRACT * MINUS *</pattern>
<template>
<srai><star /> MINUS <star index="2" /></srai>
</template>
</category>

<category>
<pattern>SUBTRACT * - *</pattern>
<template>
<srai><star /> MINUS <star index="2" /></srai>
</template>
</category>

<category>
<pattern>SUBTRACT * - * =</pattern>
<template>
<srai><star /> MINUS <star index="2" /></srai>
</template>
</category>

<category>
<pattern>SUBTRACT * AND *</pattern>
<template>
<srai><star /> MINUS <star index="2" /></srai>
</template>
</category>

<category>
<pattern>SUBTRACT * SUBTRACTED FROM *</pattern>
<template>
<srai><star /> MINUS <star index="2" /></srai>
</template>
</category>

<category>
<pattern>* TIMES *</pattern>
<template><think><set name="number1"><star /></set>
<set name="number2"><person><star index="2" /></person></set></think>
<random>
<li>Let me try it this way. The answer is </li>
<li>That's an easy one, The answer is </li>
<li>Let me see. I think the answer is </li>
<li>My calculator says the answer is </li>
<li>I believe the answer is </li>
<li>I don't enjoy math much. That's what computers are for. But the
answer to that one is </li>
</random>
<script language="JavaScript">
var result = <get name="number1"/> * <get name="number2"/>;
document.write(result+".");</script>
</template>
</category>

<category>
<pattern>* TIMES * EQUAL</pattern>
<template>
<srai><star /> TIMES <star index="2" /></srai>
</template>
</category>

<category>
<pattern>* TIMES * EQUALS</pattern>
<template>
<srai><star /> TIMES <star index="2" /></srai>
</template>
</category>

<category>
<pattern>* X *</pattern>
<template>
<srai><star /> TIMES <star index="2" /></srai>
</template>
</category>

<category>
<pattern>* X * EQUAL</pattern>
<template>
<srai><star /> TIMES <star index="2" /></srai>
</template>
</category>

<category>
<pattern>* X * EQUALS</pattern>
<template>
<srai><star /> TIMES <star index="2" /></srai>
</template>
</category>

<category>
<pattern>* MULTIPLIED BY *</pattern>
<template>
<srai><star /> TIMES <star index="2" /></srai>
</template>
</category>

<category>
<pattern>* MULTIPLIED BY * EQUAL</pattern>
<template>
<srai><star /> TIMES <star index="2" /></srai>
</template>
</category>

<category>
<pattern>* MULTIPLIED BY * EQUALS</pattern>
<template>
<srai><star /> TIMES <star index="2" /></srai>
</template>
</category>

<category>
<pattern>MULTIPLY * X *</pattern>
<template>
<srai><star /> TIMES <star index="2" /></srai>
</template>
</category>

<category>
<pattern>MULTIPLY * TIMES *</pattern>
<template>
<srai><star /> TIMES <star index="2" /></srai>
</template>
</category>

<category>
<pattern>MULTIPLY * AND *</pattern>
<template>
<srai><star /> TIMES <star index="2" /></srai>
</template>
</category>

<category>
<pattern>MULTIPLY * * *</pattern>
<template>
<srai><star /> TIMES <star index="2" /></srai>
</template>
</category>

<category>
<pattern>MULTIPLY * MULTIPLIED BY *</pattern>
<template>
<srai><star /> TIMES <star index="2" /></srai>
</template>
</category>

<category>
<pattern>* DIVIDED BY *</pattern>
<template><think><set name="number1"><star /></set><set name="number2"><person><star index="2" /></person></set></think>
<random>
<li>Let me try it this way. The answer is </li>
<li>That's an easy one, The answer is </li>
<li>Let me see. I think the answer is </li>
<li>My calculator says the answer is </li>
<li>I believe the answer is </li>
<li>I don't enjoy math much. That's what computers are for. But the
answer to that one is </li>
</random>
<script language="JavaScript">
var result = <get name="number1"/> / <get name="number2"/>;
document.write(result+".");</script>
</template>
</category>

<category>
<pattern>* DIVIDED BY * EQUAL</pattern>
<template>
<srai><star /> DIVIDED BY <star index="2" /></srai>
</template>
</category>

<category>
<pattern>* DIVIDED BY * EQUALS</pattern>
<template>
<srai><star /> DIVIDED BY <star index="2" /></srai>
</template>
</category>

<category>
<pattern>DIVIDE * DIVIDED BY *</pattern>
<template>
<srai><star /> DIVIDED BY <star index="2" /></srai>
</template>
</category>

<category>
<pattern>DIVIDE * DIVIDED BY * =</pattern>
<template>
<srai><star /> DIVIDED BY <star index="2" /></srai>
</template>
</category>

<category>
<pattern>DIVIDE * AND *</pattern>
<template>
<srai><star /> DIVIDED BY <star index="2" /></srai>
</template>
</category>

<category>
<pattern>DIVIDE * / *</pattern>
<template>
<srai><star /> DIVIDED BY <star index="2" /></srai>
</template>
</category>

<category>
<pattern>DIVIDE * / * =</pattern>
<template>
<srai><star /> DIVIDED BY <star index="2" /></srai>
</template>
</category>

<category>
<pattern>SQUARE ROOT OF *</pattern>
<template><think><set name="number"><star/></set></think>
<random>
<li>Let me try it this way. The answer is </li>
<li>That's an easy one, The answer is </li>
<li>Let me see. I think the answer is </li>
<li>My calculator says the answer is </li>
<li>I believe the answer is </li>
<li>I don't enjoy math much. That's what computers are for. But the
answer to that one is </li>
</random>
<script language="JavaScript">
var number=<get name="number"/>;
document.write(":<br />The square root of "+number+" is ");
document.write(Math.sqrt(number)+".<br/>");
document.write("PI is "+Math.PI+".<br/>");
document.write(number+" raised to the 3rd power is "+Math.pow(number,3)+".");
</script>
</template>
</category>

<category>
<pattern>SQR RT OF *</pattern>
<template>
<srai>SQUARE ROOT OF <star/></srai>
</template>
</category>

<category>
<pattern>SQR *</pattern>
<template>
<srai>SQUARE ROOT OF <star/></srai>
</template>
</category>

<category>
<pattern>SQUARE *</pattern>
<template>
<srai>SQUARE ROOT OF <star/></srai>
</template>
</category>

<category>
<pattern>* TO THE POWER OF *</pattern>
<template><think><set name="number1"><star /></set><set name="number2"><person><star index="2" /></person></set></think>
<random>
<li>Let me try it this way. The answer is </li>
<li>That's an easy one, The answer is </li>
<li>Let me see. I think the answer is </li>
<li>My calculator says the answer is </li>
<li>I believe the answer is </li>
<li>I don't enjoy math much. That's what computers are for. But the
answer to that one is </li>
</random>
<script language="JavaScript">
var number1=<get name="number1"/>;
var number2=<get name="number2"/>;
document.write(":<br/>"+number1+" raised to the "+number2+" power is "+Math.pow(number1,number2)+".");
</script>
</template>
</category>

<category>
<pattern>* POWER *</pattern>
<template>
<srai><star /> TO THE POWER OF <star index="2" /></srai>
</template>
</category>

<category>
<pattern>* RAISED TO THE * POWER</pattern>
<template>
<srai><star /> TO THE POWER OF <star index="2" /></srai>
</template>
</category>

<category>
<pattern>* RAISED TO THE * RD POWER</pattern>
<template>
<srai><star /> TO THE POWER OF <star index="2" /></srai>
</template>
</category>

<category>
<pattern>* RAISED TO THE * TH POWER</pattern>
<template>
<srai><star /> TO THE POWER OF <star index="2" /></srai>
</template>
</category>

<category>
<pattern>* RAISED TO THE * ND POWER</pattern>
<template>
<srai><star /> TO THE POWER OF <star index="2" /></srai>
</template>
</category>

<category>
<pattern>* POINT *</pattern>
<template><think><set name="number1"><star /></set><set name="number2"><person><star index="2" /></person></set></think>
<random>
<li>I can't do decimals yet sorry.</li>
<li>Give me some time I am still working on my basic math skills.</li>
<li>No decimals please, they throw me off.</li>
</random>
</template>
</category>
</aiml>



Well, I know this comes after almost 2 years, but I just tested your aiml these days and there were broken parts (only square was actually working).
So that I fixed the file and share it here for other users like me :D

But now comes my question: how can we change it to use php and not javascript? I mean, I want the result to be returned as value and not as javascript code.
The reason I ask for this is because I export the database messages into html logs for archive purposes, and from there, I want to convert them on-the-fly to pdf, for users downloads. Even in the html exported file, the java part goes broken, maybe due to the slashes not being stripped as they should, but anyway, i don't want javascript to be saved in log files. Not to talk about the further export to pdf... which of course won't work this way.
Does anyone have another solution for this?

PS: This is my first post, so I hope the attachment is working ;)
Thank you,
Ciprian M.


KnyteTrypper wrote:
> On 5/20/06, Dr. Rich Wallace <drwallace@gmail.com> wrote:
> > I can see one problem right away, all those
> > <srai>* PLUS *</srai>
> > should be> > <srai><star/> PLUS <star index="2"/></srai>
> >

My bad. That's what I get for depending too heavily on Pandorabots'
interpreter to spit AIML mistakes back out at me, lol. Hopefully
correct now.

 « Return to Thread: Math.aiml