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

return name when set
 
 

The AIML interpreter implementation may optionally provide a mechanism that allows the AIML author to designate certain predicates as “return-name-when-set”, which means that a set operation using such a predicate will return the name of the predicate, rather than its captured value.

Is this often used and how do you specify if the name should be set or the value?

 

 
  [ # 1 ]

You got me, Jan. I’ve never run into that before. big surprise

 

 
  [ # 2 ]

Another one:

<date format="%A"/> 

I can’t find the meaning of the formatting flags, any pointers?

 

 

 
  [ # 3 ]

As a matter of fact, I do. The <DATE> tag uses the same formatting codes that the PHP function strftime() uses. You can find the meanings of those codes at http://php.net/manual/en/function.strftime.php

 

 
  [ # 4 ]

Ohh bugger. That’s a long list of formatting types. I’ll probably pick the most common and translate those.

 

 
  [ # 5 ]

As to your original post, I have never seen that used and can’t think of a use for it. You should always SET a predicate such as name, age gender and then GET its value.

 

 
  [ # 6 ]
Steve Worswick - Nov 16, 2012:

As to your original post, I have never seen that used and can’t think of a use for it. You should always SET a predicate such as name, age gender and then GET its value.

This will be it’s default behaviour.
Anyway, I’ve added the feature now, so it’s possible. Relatively strait forward:

//returns either the name of the attribute or the value (of the last  item).
               
NameOrValue(var value): var
               
{
                  
var iAttrib GetFirstOut(fAssetItemStatics.Attribute);
                  if(
#(@iAttrib).UseNameWhenSet == true)
                     
return iAttrib;
                  else
                     return 
value;
               
 

 
  [ # 7 ]

Program O returns “undefined” for any predicate that hasn’t already been <SET> first. Version 3 takes it a step farther, and gives the botmaster the option of changing the “undefined” to whatever value they wish. smile

I’m not sure what use it would be to do <get name=“foo” >, only to have it return “foo”.

 

 
  [ # 8 ]
Dave Morton - Nov 16, 2012:

Program O returns “undefined” for any predicate that hasn’t already been <SET> first. Version 3 takes it a step farther, and gives the botmaster the option of changing the “undefined” to whatever value they wish. smile

I’m not sure what use it would be to do <get name=“foo” >, only to have it return “foo”.

It’s for the set element. If someone had done:
Ah, that is your <set name=“name”>xxx

so it renders: ah, that is your name.

 

 

 
  [ # 9 ]

Ah, ok. I misunderstood. Sorry. Silly Dave! smile

 

 
  [ # 10 ]

I see what you mean now. If you set he, she or it, AIML will do that. There may be other tags that slip my mind as well.

Is <set name="it"><star/></setreally

Human: It is dark
Bot: Is it really? (Bot sets “it” to dark”)

 

 
  [ # 11 ]

Any idea how this is declared for these tags?

 

 
  [ # 12 ]

You would use it like this:

<category>
<
pattern>I LIVE IN *</pattern>
<
template>
I have never visited <set name="it"><set name="topic"><person/></set></setbefore.
</
template>
</
category

Human: I live in Japan.
Bot: I have never visited it before. (Bot sets “it” and “topic” to Japan)
Human: What is “it”?
Bot: It refers to Japan.
Human: What is the topic?
Bot: We are talking about Japan.

It is important the “it” tag goes on the outside. if you had this:

<set name="topic"><set name="it"><person/></set></set

It would have set the topic to the word “it”.

Another example:

<category>
<
pattern>MY BROTHER IS *</pattern>
<
template>
Is <set name="he"><person/></setreally?
</
template>
</
category>

<
category>
<
pattern>WHO IS HE</pattern>
<
template>
He is <get name="he"/>.
</
template>
</
category

Human: My brother is called Fred.
Bot: Is he really?
Human: Who is he?
Bot: He is called Fred.

This is a simplified example, as you would ideally check the value of “he” before displaying it to the user. Had the user asked “Who is he?” first, the bot would have replied, “He is .”

 

 
  [ # 13 ]

That’s a pretty cool way of condensing the code.
What I meant though was, how do you let the system know that ‘it’ and the likes need to return ‘it’ for the set element instead of the value. In the documentation, it says you can do this where you declare the default values for the tags. But in the aiml set that I downloaded (alice), there are only aiml files. Any idea how this is declared?

 

 
  login or register to react