AI Zone Admin Forum Add your forum

NEWS: Chatbots.org survey on 3000 US and UK consumers shows it is time for chatbot integration in customer service!read more..

Authentic Human Emotions in Chatbots
 
 
  [ # 46 ]

Subtraction is pretty much like addition, so that’s not all that difficult. Where things get “tricky” is when you want to multiply or divide. then you have to be creative. cheese

<category>
  <
pattern>XMULTIPLY * *</pattern>
  <
template>
    <
think><set name="multiplier"><star/></set></think>
    <
condition name="multiplier">
      <
li value="0">0</li>
      <
li value="1"><star index="2"/></li>
      <
li value="2"><srai>XMULTIPLY2 <star index="2"/></srai></li>
      <
li value="3"><srai>XMULTIPLY3 <star index="2"/></srai></li>
      <
li value="4"><srai>XMULTIPLY4 <star index="2"/></srai></li>
      <
li value="5"><srai>XMULTIPLY5 <star index="2"/></srai></li>
      <
li value="6"><srai>XMULTIPLY6 <star index="2"/></srai></li>
      <
li value="7"><srai>XMULTIPLY7 <star index="2"/></srai></li>
      <
li value="8"><srai>XMULTIPLY8 <star index="2"/></srai></li>
      <
li value="9"><srai>XMULTIPLY9 <star index="2"/></srai></li>
      <
li>ERROREntity out of range or not a number!</li>
    </
condition>
  </
template>
</
category>

<
category>
  <
pattern>XMULTIPLY2 *</pattern>
  <
template>
    <
think><set name="mult_count"><star/></set>
    <
condition name="mult_count">
      <
li value="0"><set name="mult_result">0</set></li>
      <
li value="1"><set name="mult_result">2</set></li>
      <
li value="2"><set name="mult_result">4</set></li>
. . .
      <
li value="8"><set name="mult_result">16</set></li>
      <
li value="9"><set name="mult_result">18</set></li>
      <
li><set name="mult_result">ERROREntity out of range or not a number!</set></li>
    </
think>
    <
get name="mult_result"/>
  </
template>
</
category>

. . . 

Now obviously, the example above was hard-coded with the answers, and to do even simple, single digit multiplication would result in a ~LOT~ of AIML categories, but as you can see, it’s possible. smile I’ve coded the category XMULTIPLY2 above to take advantage of <srai> tags, rather than hard-coded values, if the AIML creator so desires, but I leave implementation of that method up to the user. wink

 

 
  [ # 47 ]

Very nice Steve and Dave.  That’s the sort of information that makes chatbot forums valuable.

I’ve been trying to get away from answering math problems and suggesting that the visitor invest in cheep calculator.  I found that once you start answering that type of question, people keep throwing math problems until the bot can no longer answer.  I was getting problems with multiple operations and even algebra.  Sometimes when asked what 1 + 1 equals, my bots say something like, “Don’t expect me to do your homework for you.”  On occasion, they might respond with, “I’m a chatbot, not a mathbot, but the answer is two.”

My philosophy is if people who really want an answer to a math problem they’ll find it elsewhere, and they’ll sometimes test the limits to exhaustion.

 

 
  [ # 48 ]

Dave, if this is Program O, isn’t it possible to do calculations in PHP in a function that acts as an AIML input post-processor (so the input matching is done, and then parsed through this function before the display of output)?

 

 
  [ # 49 ]

Any modern chatbot should be able to do basic math and time operations.
If the bot master chooses not to go down that path is up to him, but the system ought to provide basic math.

 

 
  [ # 50 ]
MikeA - Jun 20, 2013:

Dave, if this is Program O, isn’t it possible to do calculations in PHP in a function that acts as an AIML input post-processor (so the input matching is done, and then parsed through this function before the display of output)?

Unless you create a custom tag (and it’s attending handler function) to handle it, or use the <system> tag, the answer is no. Program O has a function to parse a <php> tag, but right now it’s simply a “dummy” function that just passes the contents back as text, without any code execution at all. For security reasons, the function is left that way on purpose, as it could potentially pose a serious security risk under the right circumstances. The <system;> tag in Pandorabots is disabled for exactly the same reason.

Merlin - Jun 20, 2013:

Any modern chatbot should be able to do basic math and time operations.
If the bot master chooses not to go down that path is up to him, but the system ought to provide basic math.

No argument there, Merlin. smile It’s just too bad that AIML never was designed to handle such things in an easier manner.

 

 
  [ # 51 ]
Dave Morton - Jun 20, 2013:
MikeA - Jun 20, 2013:

Dave, if this is Program O, isn’t it possible to do calculations in PHP in a function that acts as an AIML input post-processor (so the input matching is done, and then parsed through this function before the display of output)?

Unless you create a custom tag (and it’s attending handler function) to handle it, or use the <system> tag, the answer is no. Program O has a function to parse a <php> tag, but right now it’s simply a “dummy” function that just passes the contents back as text, without any code execution at all. For security reasons, the function is left that way on purpose, as it could potentially pose a serious security risk under the right circumstances. The <system;> tag in Pandorabots is disabled for exactly the same reason.

Just to check, because I may not understand how Program O is working. Is the display part of the output not handled by Program O?

I was thinking not so much of any processing of AIML, but the maths processing done afterwards in PHP before the display of output.

If possible, then sending back to AIML (as if user input) to fire a new rule that does something with the calculation. This type of process is how I’ve dealt with Verbot’s <send (<srai ish) command in C# which is handled in the desktop version, but not by the development kit source coude.

 

 
  [ # 52 ]

Just like any other AIML interpreter/engine, Program O simply parses the contents of the <template> tags in a “context agnostic” way, which is a fancy term for fundamentally processing everything as text, with no regard for the actual content. Unless a special tag is used (or, if enabled, the <system> tag), the script will process “echo 5 * 3;” as simple text, even if it’s valid PHP (or whatever language is used) code. In order to do such math processing after the output is parsed, Program O (or any other engine, for that matter) would have to be “instructed” to do so, which would include setting up some way to determine if such processing was needed (e.g. a “trigger” of some sort), and how to undertake said processing. That would require creation of a plugin, which is fairly easy to do if you’re good with PHP, but even then, the AIML category would have to be altered to include whatever sort of “trigger” you intended to use. For something like this, it’s best to just use the <system> tag, or create a custom tag/function.

 

 
  [ # 53 ]

I wonder if a special AIML tag would be needed.

What if there was something like (and forgive the probably wrong AIML, I don’t remember enough and not that good with it, but I hope is enough to clarify the point):

<category>
<
pattern>what is * + *</pattern>
<
template><srai>doadd <star index="1"/> <star index="1"/></srai></template>
</
category>

<
category>
<
pattern>what is *</pattern>
<
template><srai>domultiply <star index="1"/> <star index="1"/></srai></template>
</
category>

<
category>
<
pattern>add * and *</pattern>
<
template><srai>doadd <star index="1"/> <star index="2"/></srai></template>
</
category>

<
category>
<
pattern>doadd * *</pattern>
<
template>++ <star index="1"/> <star index="2"/></template>
</
category>

<
category>
<
pattern>domultiply * *</pattern>
<
template>xx <star index="1"/> <star index="2"/></template>
</
category

And PHP would look for the ‘++’ or ‘xx’ in the reply before output, and if fiound would calculate the part after, and returns the input as another <srai> (to a predefined rule to act on the calculation).

I’m happy to give this a try if what I’m saying makes some sense with regards to how Prog O works with AIML.

Or this could be simpler with a new tag:

<category>
<
pattern>what is * + *</pattern>
<
template><add <star index="1"/> <star index="2"/> /></template>
</
category>

<
category>
<
pattern>what is *</pattern>
<
template><multiply <star index="1"/> <star index="2"/> /></template>
</
category>

<
category>
<
pattern>add * and *</pattern>
<
template><add <star index="1"/> <star index="2"/> /></template>
</
category

With PHP looking for ‘<add’ or ‘<multiply’ etc in the output, before displaying.

 

 

 
  [ # 54 ]

Ok, several things here. First off, the only characters allowed in an AIML pattern are letters, numbers, the space chatacter, the * wildcard, and the _ wildcard. Everything else is stripped out and replaced with a space, so that “what is * + *” becomes WHAT IS *  * and that’s obviously not what you want. Now, that said, a good AIML interpreter will replace the + with PLUS, the - with MINUS, the * (not x) with MULTIPLY and the / with DIVIDE (or some such), and the % character with PERCENT.

Secondly, this:

<add <star index="1"/> <star index="2"/> /> 

Isn’t even valid XML, let alone valid AIML. In order to properly utilize a tag like that, it would have to look like this:

<add><star index="1"/> AND <star index="2"/></add

The AND in there is to ensure separation of the two values, and would be discarded by the function that parses the <add;> tag.

Now please bear in mind that I’m not “throwing stones” here. I’m just trying to provide proper valid AIML code examples, so that you might gain a better understanding. smile

I’m currently rather tied up with Program O version 3 (we just got into full development mode with this version yesterday, after the release of version 2.3, so I don’t have a whole lot of time to develop new plugins, but I’ll be sure to put creation of a “math suite” of custom AIML tags into the custom tags plugin for the new version.

 

 
  [ # 55 ]
Merlin - Jun 20, 2013:

Any modern chatbot should be able to do basic math and time operations.
If the bot master chooses not to go down that path is up to him, but the system ought to provide basic math.

Chatbots ought to be able to do a lot of things.  Tell the future, for example, or make dinner.  The question is, how important is that function to the people chatting with the bot, and how much is it worth spending the time on seldom used material that’s of little value.

I think the main focus of a chatbot ought to be conversation and understanding natural language.  You can load up all the tricks you want, but if it can’t understand what the visitor is talking about, of what use are answers to math problems… or today’s horoscope, for that matter?

 

 
  [ # 56 ]

Maybe I should have said every modern “chatbot system” should be able to do basic time and math, allowing the botmaster to build the persona he wants easily.

I believe many visitors think that if they are talking to a computer based chatbot they think it should be able to do basic math/time instead of defaulting to answers like “I don’t know” or “do I look like a calculator”.

Math and time functions allow a number of actions a botmaster could find useful. It is a strength of Skynet-AI and not all the functions are appropriate to all bots.
For example:

USER:What is the date two days from now?
AIThat would be SaturdayJune 222013.
USER
:What is the date on Saturday?
AIOn SaturdaySaturdayJune 222013I am plotting your salvation.
USER:I was born in 1990.
AI
So2013-1990=23 this yearAre you as young as you feel?
USER:How long have I been on-line?
AIWe have been here for thirteen minutes.
USER:roll dice
AI
The bot rolls a 5.
USER
:roll 2d12
AI
The bot rolls 212 sided dice for a total of 3.
USER
:What is two to the power of eight?
AITwo hundred fifty six.
USER:How many legs does three horses have?
AII would guess that the number of legs would be twelveOf course each animal has 4.
USER
:1+1?
AITwo.
USER:Two plus two?
AIFour.
USER:What time is it?
AIIt is around eight forty. Do you have somewhere else to be?
USER:What is the roman numeral for twenty three?
AIXXIII is the Roman Numeral for 23. 

It also allows the botmaster to do other practical things like counting repetitive inputs, and getting angry at the user if there are more than a set number.


 

 
  [ # 57 ]

I see nothing in the above post that AIML cannot do.

 

 
  [ # 58 ]

Steve is correct that many things are possible in AIML that at first seem impossible.  Since recursion is available and there is conditional logic available math functions are possible, not easy, but doable.  In defense of AIML the system tag was meant to supply the means for further calculations.  The issue is that hosting services like to disable that feature for security reasons and that is what poses the problem. 

The reason that math functions are needed in the context of this post was to be able to implement a PAD emotional scale system for a chatbot.  In order to compare the a bot’s current PAD values to values set for emotions or for individual words or phrases we are going to need some basic math capabilities.  The goal is to better simulate emotions not necessarily to be able to better answer math problems.

I do not see any reason why a chatbot could not be programmed to answer math questions.  Most people can answer simple math questions and most people cannot answer basic algebra questions so it seems that the ability to emulate the average person’s math reasoning abilities in a chatbot should be within reach.  If the questions are beyond the chatbot’s abilities then just answer with versions of “I don’t know.” which is something like what a human would say.  The issue with most chatbots is that the basic math questions are not handled or the chatbot instantly answers questions that a human would not be able to quickly answer.

I am working on a basic math aiml file and will demo a bot using it when it is completed. 

Does anyone have any suggestions for handling negative numbers in AIML?

 

 
  [ # 59 ]

For adding and taking away values to find emotional states, you can do as Dave and I suggested above. For negative numbers in this case, I would suggest the following.

Let’s say the emotional state can be from -5 to +5, why not make it from 0 to 10? 0-4 being the negative values, 5 begin 0 and 6-10 being the positive amounts.

Mitsuku is able to do (basic) maths on whole numbers using pure AIML (not negatives). You are welcome to try it out at http://www.mitsuku.com
I was planning on adding a module to work out any maths using flash but never got round to it.

 

 
  [ # 60 ]

Dave - for multiplying small numbers, I use the following:

“What is 2 times 3” would srai to “What is 2 plus 2 plus 2” and so on. This gets a bit unwieldly for numbers above 20 and so I wrote some AIML that would handle numbers up to 9,999. As I say, if I ever win a Loebner Prize, I will happily share it on the boards.

 

‹ First  < 2 3 4 5 6 > 
4 of 6
 
  login or register to react
‹‹ My learning AI Jay Sim      Chat Bot JESSICA ››