condition tags

Help
hokascha
2011-11-02
2013-04-25
  • hokascha
    hokascha
    2011-11-02

    Hi,

    Although it seems like Program E does support the condition tags, i cannot get them to work. Here's my AIML:

    <category>
    <pattern>SEND AN EMAIL TO MY GIRLFRIEND</pattern>
    <template>OK,
    <condition name="u_girlfriend" exists="true"><srai>SENDE AN EMAIL TO <get name="u_girlfriend"/></srai></condition>
    <condition name="u_girlfriend" exists="false">Who is your girlfriend?</condition >
    </template>
    </category>

    The answer the bot gives is always: "OK, " So it looks like the condition statement always evaluates to false. Why?

    Thanks for any help,

    Kevin

     
  • Adeena
    Adeena
    2011-11-02

    HI Kevin,

    The problem is that "exists="true"" is not valid in the condition tag.

    the format for the condition tag is such:

    <condition name="whatevervarnameIchoose">
        <li value="somethingthatthevariablemightbesetto">Say something intelligent here</li>
        <li value="somethingelsethatthevarmightbesetto">something else here</li>
    </condition>

    there are a couple variations on this, but the bottom line is it needs the tag "value".  Tags like "exists" just don't exist!

    -Adeena

     
  • hokascha
    hokascha
    2011-11-03

    Hi Adeena,

    thanks for your answer. The AIML standard says there is an attribute like "exists", see http://www.alicebot.org/documentation/aiml-reference.html#condition

    If Program E doesn't support this, how else can I achive a conditional branch like if-then-else? I have to check if a specific variable exists (or isn't empty).

    Greetings,

    Kevin

     
  • Adeena
    Adeena
    2011-11-04

    Hi Kevin,

    Sadly… the document you're referencing isn't the "official" standard.  This is:
    http://www.alicebot.org/TR/2005/WD-aiml/

    That's not to say someone didn't/couldn't implement 'exists' … and I'm actually looking at the Program E code right now and to me it's looking like someone started to implement it, but not completely.

    Anyway, there are multiple ways to skin a cat in AIML and I've run into the same problem.
    What i've done is for each variable I need to do a "if exists" test, I create a second variable to set a boolean value for that purpose.

    So if I need "myvar", I also have "myvar_exists" which gets set to true at the same time that myvar is set.

    Make sense?

    -Adeena

     
  • hokascha
    hokascha
    2011-11-04

    Hi Adeena,

    thanks for your replay. Good idea to use this second boolean for exist-checks. But how do you initialize this _exist-variable to false? Is there a way to initialize user variables if they are not already set?

    Thanks again,

    Kevin

     
  • hokascha
    hokascha
    2011-11-04

    checking for an empty value should do the trick ;-)

     
  • hokascha
    hokascha
    2011-11-04

    but it doesnt. Program E expects to find LI-elements in that case. I changed respond.php to check for the special value "EMPTY" which checks for an empty variable now.

    Now I see the next problem: Looks like Program E doesn't respect the Topic-Tag. Here's my Code:

    <category>
    <pattern>SEND MAIL TO *</pattern>
    <template>Subject?<think>
    <set name="mail_to"><star /></set>
    <settopic>sendmail</settopic>
    </think></template>
    </category>

    <topic name="sendmail">
    <category>
    <pattern>*</pattern>
    <that>SUBJECT</that>
    <template>Now the message, please.
    <think>
    <set name="mail_betreff"><star /></set>
    </think>
    </template>
    </category>
    </topic>

    The second template is never reached, although topic is set to "sendmail". Any ideas?

    Thanks a lot, again :-)

    Kevin

     
  • Adeena
    Adeena
    2011-11-05

    1) To answer your earlier question about setting the boolean variables and how you inialize to false.  You don't need to if you only plan to act when the variable is set to true. For example:

    <category>
    <pattern>My girlfriend is *</pattern>
    Ok.
    <think>
      <set name="u_girlfriend"><star/></set>
      <set name="u_girlfriend_exists">true</set>
    </think>
    </category>
    <category>
    <pattern>SEND AN EMAIL TO MY GIRLFRIEND</pattern>
    <template>OK,
    <condition name="u_girlfriend_exists">
                                           <li value="true"><srai>SEND AN EMAIL TO <get name="u_girlfriend"/></srai></li>
                                           <li>Who is your girlfriend?</li>
                                   </condition >
    </template>
    </category>

    As for your new question… the error is in that (unless you've created your own tag) <settopic> is not a tag.  "topic" is treated like any other variable.

    Change this line:
    <settopic>sendmail</settopic>

    to
    <set name="topic">sendmail</set>

    then your next category should execute.

    -Adeena
    riotsw.com

    (ps… I do a lot of various AIML stuff with my bots on riotsw.com and post have finally gotten into starting to post status and updates of my work on twitter:  @adeena  )

     
  • hokascha
    hokascha
    2011-11-07

    Hi Adeena,

    thanks again for your great support :-) I tested your suggestion of using <set name="topic"> but it doesn't work.
    In the database, table "dstore", the topic is correctly set, but my <pattern>*</pattern> inside the sendmail-topic only matches, if the user says something, that doesn't match any other pattern outside of the sendmail-topic. So it looks like Program E isn't prioritizing the topic over others. BTW, settopic seems to be OK, too. It also sets the topic correctly.

    Greetings,

    Kevin