|
|
Senior member
Total posts: 697
Joined: Aug 5, 2010
|
I’m trying to get the default AIML set imported and came across this:
<think><srai>PUSH <person>YOU <star/></person></srai></think>
Is there any purpose to a construct like this? I would image there is hardly any point, cause whatever’s inside ‘think’ isn’t printed, and an srai by itself only renders some output,right (and possibly do another think)?
|
|
|
|
|
Posted: Nov 13, 2012 |
[ # 1 ]
|
|
Administrator
Total posts: 3111
Joined: Jun 14, 2010
|
Actually, that’s not only perfectly valid, but also quite useful. What you have there is a “hidden” command (thus, the <THINK> tag) that handles some internal “housekeeping”. I forget the exact functionality of the category for PUSH *, but I can explain the rest, more or less.
The <PERSON> tag, along with it’s companion tag, <PERSON2>, handle transformations from first person (I, me, etc.) to second person (you), or to third person (he, she, they, etc.) and back. There are a great many times where you will want to run categories like this, where some parts will need to be hidden from the output. I’m short on time right now, but I’ll look up the PUSH * category, see what it does, and report back.
|
|
|
|
|
Posted: Nov 13, 2012 |
[ # 2 ]
|
|
Administrator
Total posts: 3111
Joined: Jun 14, 2010
|
Ok, I have a bit more time than I had thought. Here’s PUSH *:
<category> <pattern>PUSH *</pattern> <template> <think> <set name="last"><get name="seventh"/> </set> <set name="seventh"><get name="sixth"/> </set> <set name="sixth"><get name="fifth"/> </set> <set name="fifth"><get name="fourth"/> </set> <set name="fourth"><get name="third"/> </set> <set name="third"><get name="second"/> </set> <set name="second"><get name="top"/> </set> <set name="top"><star/> </set> </think> <star/> </template> </category>
What this category does is to create a FIFO (First In/First Out) “stack” of variable values. It has a compliment, POP *, which pulls the info back out, when called. This comes in handy when you want to keep track of previous topics, or other items that you want to keep track of, in that particular order.
|
|
|
|
|
Posted: Nov 14, 2012 |
[ # 3 ]
|
|
Senior member
Total posts: 697
Joined: Aug 5, 2010
|
Ok, I see. So basically, the srai element is being used as a function call here, to get some stuff done.
I am starting to get the impression that srai is used a bit like a swiss knife.
|
|
|
|
|
Posted: Nov 14, 2012 |
[ # 4 ]
|
|
Administrator
Total posts: 2048
Joined: Jun 25, 2010
|
Jan Bogaerts - Nov 14, 2012: I am starting to get the impression that srai is used a bit like a swiss knife.
True. As Dave says, you would put <srai>s inside think tags to not display the bot’s workings to the user. I use it to validate input such as
<category> <pattern>MY FAVORITE COLOR IS *</pattern> <template> <think> <set name="validcolor"><srai>ISACOLOR <star/></srai></set> </think> <condition name="validcolor"> <li value="YES">Nice color.</li> <li value="NO">But <star/> is not a color. What do you mean?</li> </condition> </template> </category>
<category> <pattern>ISACOLOR *</pattern> <template> <set name="checkcolor"><star/> <condition name="checkcolor"> <li value="RED">YES</li> <li value="BLUE">YES</li> <li value="YELLOW">YES</li> ... ... <li value="LILAC">YES</li> <li>NO</li> </condition> </template> </category>
You can also use it to set up variables like gender and name. If someone says something like, “I am Paul”, it can srai to other categories to find out if Paul is a name, whether it is male or female name and then set up appropriate values.
Human: I am hungry
Bot: What will you be eating? (bot srais to other categories and finds “hungry” is not a name)
Human: I am Paul
Bot: Hi Paul (bot srais to other categories and finds Paul is a name and is male)
Human: Am I male?
Bot: Well you have a male name.
|
|
|
|
|
Posted: Mar 21, 2013 |
[ # 5 ]
|
|
Member
Total posts: 7
Joined: Mar 9, 2013
|
Hello Dear All,
Here i just code as below
<category> <pattern>_ schedule appointment *</pattern> <template> Ok you have an appointment for at <star index="1"/> </template> </category>
it is giving correct output,but i want remeber time before * e.g.
current situation
Client=>Please schedule appointment Thursday 5 PM.
BOT=>Ok you have an appointment for at Thursday 5 PM.
Expected situation if client said
Client==> At Tuesday 3pm schedule appointment
how I use AIML tags for aboave sentence
Thanks in adavanced
|
|
|
|
|
Posted: Mar 21, 2013 |
[ # 6 ]
|
|
Administrator
Total posts: 2048
Joined: Jun 25, 2010
|
The _ wildcard will overwrite everything including a direct match and should be used sparingly.
I would be tempted to set up some new categories to srai to a master one:
AT * SCHEDULE APPOINTMENT
_ APPOINTMENT FOR *
SCHEDULE APPOINTMENT *
_ APPOINTMENT AT *
which can all point to the actual category which sets up the appointment.
|
|
|
|
|
Posted: Mar 21, 2013 |
[ # 7 ]
|
|
Member
Total posts: 7
Joined: Mar 9, 2013
|
Hi Steve,
Can you explain in details about srai, can you give me example of srai with star
|
|
|
|
|
Posted: Mar 21, 2013 |
[ # 8 ]
|
|
Member
Total posts: 7
Joined: Mar 9, 2013
|
Dhiraj Gautame - Mar 21, 2013: Hi Steve,
Can you explain in details what you exactly want to tell
|
|
|
|
|
Posted: Mar 21, 2013 |
[ # 9 ]
|
|
Administrator
Total posts: 2048
Joined: Jun 25, 2010
|
Well this is no longer to do with the original topic and so I would advise you to start a new thread. However, this is the basic of how srai works. It is used to stop you having to write the same responses many times for similar inputs. The best way to demonstrate it is with an example:
<category> <pattern>HELLO</pattern> <template>Hi there!</template> </category>
<category> <pattern>HI</pattern> <template><srai>hello</srai></template> </category>
<category> <pattern>HOWDY</pattern> <template><srai>hello</srai></template> </category>
<category> <pattern>GREETINGS</pattern> <template><srai>hello</srai></template> </category>
This way, the user can say Hello, Hi, Howdy or Greetings and still get the same response.
You can also use wildcards in your srais.
<category> <pattern>I HAVE AN APPOINTMENT AT *</pattern> <template>Ok, I will remind you a few minutes before <star/></template> </category>
<category> <pattern>AT * I HAVE AN APPOINTMENT</pattern> <template><srai>I have an appointment at <star/></srai></template> </category>
<category> <pattern>REMIND ME OF AN APPOINTMENT I HAVE AT *</pattern> <template><srai>I have an appointment at <star/></srai></template> </category>
|
|
|
|
|
Posted: Mar 21, 2013 |
[ # 10 ]
|
|
Member
Total posts: 7
Joined: Mar 9, 2013
|
Thank a lot Steve for your valueable guidance
|
|
|
|
|
Posted: Mar 21, 2013 |
[ # 11 ]
|
|
Administrator
Total posts: 2048
Joined: Jun 25, 2010
|
No problem. If you have any more questions about AIML, I will be happy to answer then for you.
|
|
|
|