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..

Program-O Version 2.4.2 SRAI Lookup
 
 
  [ # 16 ]
∞Pla•Net - Jun 14, 2014:

I was still updating my last post above… It says PHP 4, dang!

I would gladly let you run the script, but I am probably going to shutdown the server.

Before you do, if it’s a server that you have direct control over (e.g. on your own computer) I can help you upgrade your PHP to a newer version (5.3 is the oldest that will work). If you’re using one that’s part of a hosting package from a hosting provider, you should ask them to upgrade to PHP5.

 

 
  [ # 17 ]

I lookied into it a little further. It turns out PHP 4 is installed there in addition
to php 5.4 and php 5.5.  Here is the output of a new php script I just wrote:

Build: 1402028162
Current PHP version: 5.4.28
MySQL server version: 5.1.73-log
OS: Linux info 3.0 #1337 SMP Tue Jan 01 00:00:00 CEST 2000 all GNU/Linux

Your technique with phpinfo() is better, I think.  My script has to connect to MySQL.
But it gets the job done, quick and dirty.

EDIT
Yes, I have direct control over it.  I can login to it remotely from my computer
and access the command line.  I can remotely run php from the command line
to check for errors on a live Program-O system.

 

 

 
  [ # 18 ]

So now the question remains of how to instruct (I assume) Apache to use PHP5 instead of PHP4. I suspect that once you make that one change that your errors will go away. smile

 

 
  [ # 19 ]

You’re doing a great job instructing.

Just to clarify…

I originally grabbed the version from the command line: /usr/bin/php—version which was incorrect.  There are three versions of PHP installed /usr/bin/php5.4  and /usr/bin/php5.5  And the default PHP is the most stable version: Current PHP version: 5.4.28 which is what Program-O sees.

Now Program-O is working up until an SRAI is requested (I suspect).  At the moment, I do not have the $AIMLtemplate variable modified in the code.  So it may be hitting that conflict you discussed above.  Is there a new build that has that correction in the code?  I would rather test the official Program-O release, that everybody gets, rather than unofficially modify it myself.  I will if I have to.  It is just not my preference.  I prefer to have what everyone else is downloading.  Not sort of a one of a kind modified version.

(OFF TOPIC a little)

Hey Dave, while we were chatting, I just got a blast from the past running on the web—Program E with the old AIML sets.  He he…Hee!  Even if this classic ALICE robot is “living” in the past.  Nice to see it make a comeback.

: Who is Bill Clinton?
: He was the second Impeached President of the United States.

: Who is President?
: George W. Bush.

Dave, do you remember what some of the bugs reported with Program E were?


Note: No politics intended by quoting the robot’s responses about US Presidents.  That was only meant to discuss how the robot’s knowledgebase is out of date.

 

 

 

 
  [ # 20 ]

The only bug that I can remember was a “stutter” bug (inaccurate description - more like an “echo” bug) that caused the response to be randomly but frequently repeated. I never did find the cause, which was why I looked into Program O and ended up using it, joining the dev team, and ... well, you know the rest. smile

 

 
  [ # 21 ]

Seeker: Hello
Program-O: Hi there!

Seeker: How are you?
Program-O: I am functioning within normal parameters.

Seeker: My eyes are blue.
Program-O: You sound very attractive.

Seeker: My friend is Bob.
Program-O: Okay, your friend is Bob.

Seeker: My name is Earl.
—————Program-O crashes steady————————————

Same questions to Program E for comparison:

Seeker: My name is Earl.
Program-E:  Earl, nice to meet you!

Are you a man or a woman?

Seeker: My friend is Bob.
Program-E: Has he always been Bob?


Seeker: My eyes are blue.
Program-E:  You sound very attractive Tom.

Seeker: How are you?
Program-E: Everything is running smoothly.

Seeker: Hello
Program-E: Hi there!

 

 

 
  [ # 22 ]

It does not crash on no-ip.info server, but generates a blank response:

Seeker: My name is Earl.
Test-Debian:

Reference: http://dmorton.no-ip.info/debian/Program-O/gui/plain/index.php?say=My+name+is+Earl.&submit=say&convo_id=ao08sfqoa3u08c5au53ttn3f61&bot_id=1&format=html#end

What is the latest status of Program-O version 3.0 ?

 

 
  [ # 23 ]

Version 3 still has a long way to go, I’m afraid. I’ve got 2 major hurdles to get past right now. One is creating a more accurate way to score the results of the AIML categories, and the other is a complete re-design of the way the AIML gets parsed. The current parsing functions just can’t handle nested tags in an efficient enough manner, and the solution is currently eluding me. If you (or anyone, for that matter) have a suggestion for either of these, I’m all ears. cheese

 

 
  [ # 24 ]

Proposal: Nested tags may be handled with array to string conversion using recursion.

Right Dave?  In order to nest something, it has to be inside an array.

If it is not in an array, then it is not nested.  Do you agree with this?

 

 
  [ # 25 ]

It’s a bit more complicated than that, because with AIML you have to deal with both mixed content and tags with attributes. Also, the selected AIML template has to be parsed hierarchically, rather than in a linear fashion, and that makes recursion difficult (though not impossible). Take a look at this AIML category:

<category>
  <
pattern>TIMEOFDAY</pattern>
  <
template>
    <
think>
      <
set>
        <
name>TOD</name>
        <
date>
          <
format>%H</format><!-- get the hour portion of the day (00-23see the PHP manual* for details -->
        </
date>
      </
set>
    </
think>
    <
condition>
      <
name>TOD</name>
      <
li><value>00</value>Morning</li>
      <
li><value>01</value>Morning</li>
...
      <
li><value>11</value>Morning</li>
      <
li><value>12</value>Afternoon</li>
...
      <
li><value>16</value>Afternoon</li>
      <
li><value>17</value>Evening</li>
...
      <
li><value>23</value>Evening</li>
      <
li>Unknown time value</li>
    </
condition>
  </
template>
</
category

*PHP manual for strftime()

This is a “real world” example of a working AIML category that was converted to AIML 2.0 nested tags. In order to parse this, it has to be handled as a tree structure, rather than as a simple array because the <value> elements aren’t actually a part of the expected output, but instead are used to select which <li> element is to be used. Additionally, the mixed content of most of the <li> tags add an additional level of complexity (I’ll illustrate another aspect of the “mixed content problem”, next).

Now take a look at this template element, taken from another “real world” category:

<template>
  
I like
  
<random>
    <
li>red</li>
    <
li>green</li>
    <
li>blue</li>
    <
li>white</li>
  </
random>
  <
random>
    <
li>shoes</li>
    <
li>pants</li>
    <
li>turtles</li>
  </
random>, but not when they have
  
<random>
    <
li>stripes</li>
    <
li>polka-dots</li>
    <
li>buttons</li>
    <
li>some sort of disease</li>
  </
random>.
</
template


(ok, maybe not quite a “real world” example, but it’s still perfectly valid AIML, and thus makes a good example)
The problem with mixed content here is that some methods of parsing it cannot be used in PHP because they just weren’t designed to handle it, and will either throw errors, or return undesired results. For example, PHP’s SimpleXML functions will trigger an error, while some other XML parsing methods will “overwrite” elements if there are elements in the same level with the same tag name (e.g. the <random> tags in the above example).

One method that I’m looking into (though it looks somewhat convoluted) is xml_parse_into_struct. It seems promising, but I haven’t fully investigated the possibilities yet. There are other potential methods to investigate as well, and I need to determine which will give the best balance of benefit versus complexity.

 

 
  [ # 26 ]

I ran your AIML through the second half of “Example #1 xml_parse_into_struct()” on the php.net page you linked, and then copied and pasted output below your AIML listing. 

<aiml>
 <
category>
    <
pattern>ONE</pattern>
     <
template>
  
I like
  
<random>
    <
li>red</li>
    <
li>green</li>
    <
li>blue</li>
    <
li>white</li>
  </
random>
  <
random>
    <
li>shoes</li>
    <
li>pants</li>
    <
li>turtles</li>
  </
random>, but not when they have
  
<random>
    <
li>stripes</li>
    <
li>polka-dots</li>
    <
li>buttons</li>
    <
li>some sort of disease</li>
  </
random>.
</
template>  
 </
category>
</
aiml
tagAIML
type
open
level
1
value


tagCATEGORY
type
open
level
2
value


tagPATTERN
type
complete
level
3
value
ONE

tag
CATEGORY
value

typecdata
level
2

tag
TEMPLATE
type
open
level
3
value
I like

tag
RANDOM
type
open
level
4
value


tagLI
type
complete
level
5
value
red

tag
RANDOM
value

typecdata
level
4

tag
LI
type
complete
level
5
value
green

tag
RANDOM
value

typecdata
level
4

tag
LI
type
complete
level
5
value
blue

tag
RANDOM
value

typecdata
level
4

tag
LI
type
complete
level
5
value
white

tag
RANDOM
value

typecdata
level
4

tag
RANDOM
type
close
level
4

tag
TEMPLATE
value

typecdata
level
3

tag
RANDOM
type
open
level
4
value


tagLI
type
complete
level
5
value
shoes

tag
RANDOM
value

typecdata
level
4

tag
LI
type
complete
level
5
value
pants

tag
RANDOM
value

typecdata
level
4

tag
LI
type
complete
level
5
value
turtles

tag
RANDOM
value

typecdata
level
4

tag
RANDOM
type
close
level
4

tag
TEMPLATE
value
: , but not when they have
type
cdata
level
3

tag
RANDOM
type
open
level
4
value


tagLI
type
complete
level
5
value
stripes

tag
RANDOM
value

typecdata
level
4

tag
LI
type
complete
level
5
value
polka-dots

tag
RANDOM
value

typecdata
level
4

tag
LI
type
complete
level
5
value
buttons

tag
RANDOM
value

typecdata
level
4

tag
LI
type
complete
level
5
value
some sort of disease

tag
RANDOM
value

typecdata
level
4

tag
RANDOM
type
close
level
4

tag
TEMPLATE
value
: .
typecdata
level
3

tag
TEMPLATE
type
close
level
3

tag
CATEGORY
value

typecdata
level
2

tag
CATEGORY
type
close
level
2

tag
AIML
value

typecdata
level
1

tag
AIML
type
close
level

I think I see a possibility for this raw output to work, even though it is convoluted.  By second half of the function, I mean I didn’t bother with the first index array code.  I displayed the key value pair with two foreach loops instead of the print_r function.

[edit]
I enclosed the AIML code in a [ code] tag rather than [ quote ] so the <pattern> tags become visible. Otherwise you have to use &lt; to replace the < for it to show up. - Dave
[/edit]

 

 
  [ # 27 ]

Yeah, convoluted is indeed an apt description (I ran the same experiment on the same code, and saw the same results). smile One of the advantages is that it can handle mixed content without any real hiccups, but the disadvantage is that it’s very difficult to parse atomic tags that rely on stored information, such as <star> or <get>. I have come up with a solution for the “mixed content problem” for SimpleXML, simply by wrapping all text with <text> tags prior to converting the XML text into a SimpleXML object, but that has it’s own challenges, and I’m not really convinced that using SimpleXML is the way to go. Version 2 currently uses this method, and it’s not very efficient. Other options include using a DomDocument model, creating a custom pull parser, creating a function around xml_parse_into_struct, or going back to straight text parsing as was done in version 1, and nobody really wants that. cheese I’m also entertaining the notion of creating a custom class that could potentially use a “smorgasbord” of various methods, taking advantage of the strengths of each method, while (hopefully) avoiding the weaknesses.

 

 
  [ # 28 ]

By the way, you’ve only displayed the “vals” array, which only holds the contents of the various AIML tags. xml_parse_into_struct() also fills an “index” array as well, that contains important information about what is stored where. Without that array, the other is really rather useless. wink

 

 
  [ # 29 ]

Nope. The “index” array is not really useful, because the “vals” array already has those same index values… I’m just not displaying them above as keys of the outer foreach loop.  Above, you were looking at the inner foreach loop only. 

Here, see the index values now…

array (
  0 =>
  array (
  ‘tag’ => ‘AIML’,
  ‘type’ => ‘open’,
  ‘level’ => 1,
  ),
  1 =>
  array (
  ‘tag’ => ‘CATEGORY’,
  ‘type’ => ‘open’,
  ‘level’ => 2,
  ),
  2 =>
  array (
  ‘tag’ => ‘PATTERN’,
  ‘type’ => ‘complete’,
  ‘level’ => 3,
  ‘value’ => ‘ONE’,
  ),
  3 =>
  array (
  ‘tag’ => ‘TEMPLATE’,
  ‘type’ => ‘open’,
  ‘level’ => 3,
  ‘value’ => ’  I like ‘,
  ),
  4 =>
  array (
  ‘tag’ => ‘RANDOM’,
  ‘type’ => ‘open’,
  ‘level’ => 4,
  ),
  5 =>
  array (
  ‘tag’ => ‘LI’,
  ‘type’ => ‘complete’,
  ‘level’ => 5,
  ‘value’ => ‘red’,
  ),
  6 =>
  array (
  ‘tag’ => ‘LI’,
  ‘type’ => ‘complete’,
  ‘level’ => 5,
  ‘value’ => ‘green’,
  ),
  7 =>
  array (
  ‘tag’ => ‘LI’,
  ‘type’ => ‘complete’,
  ‘level’ => 5,
  ‘value’ => ‘blue’,
  ),
  8 =>
  array (
  ‘tag’ => ‘LI’,
  ‘type’ => ‘complete’,
  ‘level’ => 5,
  ‘value’ => ‘white’,
  ),
  9 =>
  array (
  ‘tag’ => ‘RANDOM’,
  ‘type’ => ‘close’,
  ‘level’ => 4,
  ),
  10 =>
  array (
  ‘tag’ => ‘RANDOM’,
  ‘type’ => ‘open’,
  ‘level’ => 4,
  ),
  11 =>
  array (
  ‘tag’ => ‘LI’,
  ‘type’ => ‘complete’,
  ‘level’ => 5,
  ‘value’ => ‘shoes’,
  ),
  12 =>
  array (
  ‘tag’ => ‘LI’,
  ‘type’ => ‘complete’,
  ‘level’ => 5,
  ‘value’ => ‘pants’,
  ),
  13 =>
  array (
  ‘tag’ => ‘LI’,
  ‘type’ => ‘complete’,
  ‘level’ => 5,
  ‘value’ => ‘turtles’,
  ),
  14 =>
  array (
  ‘tag’ => ‘RANDOM’,
  ‘type’ => ‘close’,
  ‘level’ => 4,
  ),
  15 =>
  array (
  ‘tag’ => ‘TEMPLATE’,
  ‘value’ => ‘, but not when they have ‘,
  ‘type’ => ‘cdata’,
  ‘level’ => 3,
  ),
  16 =>
  array (
  ‘tag’ => ‘RANDOM’,
  ‘type’ => ‘open’,
  ‘level’ => 4,
  ),
  17 =>
  array (
  ‘tag’ => ‘LI’,
  ‘type’ => ‘complete’,
  ‘level’ => 5,
  ‘value’ => ‘stripes’,
  ),
  18 =>
  array (
  ‘tag’ => ‘LI’,
  ‘type’ => ‘complete’,
  ‘level’ => 5,
  ‘value’ => ‘polka-dots’,
  ),
  19 =>
  array (
  ‘tag’ => ‘LI’,
  ‘type’ => ‘complete’,
  ‘level’ => 5,
  ‘value’ => ‘buttons’,
  ),
  20 =>
  array (
  ‘tag’ => ‘LI’,
  ‘type’ => ‘complete’,
  ‘level’ => 5,
  ‘value’ => ‘some sort of disease’,
  ),
  21 =>
  array (
  ‘tag’ => ‘RANDOM’,
  ‘type’ => ‘close’,
  ‘level’ => 4,
  ),
  22 =>
  array (
  ‘tag’ => ‘TEMPLATE’,
  ‘value’ => ‘.’,
  ‘type’ => ‘cdata’,
  ‘level’ => 3,
  ),
  23 =>
  array (
  ‘tag’ => ‘TEMPLATE’,
  ‘type’ => ‘close’,
  ‘level’ => 3,
  ),
  24 =>
  array (
  ‘tag’ => ‘CATEGORY’,
  ‘type’ => ‘close’,
  ‘level’ => 2,
  ),
  25 =>
  array (
  ‘tag’ => ‘AIML’,
  ‘type’ => ‘close’,
  ‘level’ => 1,
  ),
)

And I am calling the xml_parse_into_struct function without the 4th argument for index. The 4th argument is optional.

 

 
  [ # 30 ]

Of course, that’s just my opinion, Dave.  The PHP standards agree more with you grin

I just figured you might find the code applied a little differently, more interesting.

Good research Dave! That is a great suggestion: xml_parse_into_struct()

I am testing xml_parse_into_struct() with <star> or <get> tags now.

This is the sample AIML I am testing with…  Please suggest any improvements:

<?xml version="1.0" encoding="UTF-8" ?>
<aiml version="1.0">
<
topic name="HOBBY">
  <
category>
    <
pattern>*</pattern>
    <
template>
    <
some-tag> ...information...<some-other-tag/> </some-tag>
    <
set name="TEST">Test complete.</set>
    <
get name="TEST" /> 
      <
random>
        <
li>"<that/>"Why? </li>
        <
li>Why not?</li>
        <
li>Why so?</li>
      </
random>
      <
think>
        <
set name="topic">
          <
star/>
        </
set>
      </
think>
      
The topic is reset to <star/>.
    </
template>
  </
category>
</
aiml

The “some-tag” and other AIML is inspired by the tutorial here on Pandorabots.com.

 

 

 < 1 2 3 > 
2 of 3
 
  login or register to react