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

AIML 2.0 <interval> tag
 
 

I’ve added another tag to the AIML 2.0 spec.  I may change some of the attributes for this tag, and I’d appreciate any feedback here before I cast it in stone.

The <interval> tag will be included in the next release of Program AB.  It relies on the Joda-Time library http://joda.sourceforge.net/

The <interval> tag computes a time interval between two dates.

Like other AIML 2.0 tags, the attribute values of <interval> may be specified as XML attributes or with subtags of the same name.  The attributes of <interval> are:

<style> - minuteshoursdaysweeksmonths, or years
<jformat> - the format of the dates in the interval.   (See <date/>).
<
from> - starting date
<to> - ending date 

Examples:

Compute the number of days until Christmas:

<category>
<
pattern>HOW MANY DAYS UNTIL CHRISTMAS</pattern>
<
template>
<
interval>
<
jformat>MMMMMMMMM dd</jformat>
<
style>days</style>
<
from><date jformat="MMMMMMMMM dd"/></from>
<
to>December 25</to>
</
interval>
days until Christmas.
</
template>
</
category

The following category displays the bot’s age in years, or in months if the bot is less than one year old.

<category><pattern>AGE</pattern>
<
template>
<
think>
<
set var="years">
<
interval>
<
jformat>MMMMMMMMM ddYYYY</jformat>
<
style>years</style>
<
from>October 92012</from>
<
to><date jformat="MMMMMMMMM dd, YYYY"/></to>
</
interval>
</
set>
<
set var="months">
<
interval>
<
jformat>MMMMMMMMM ddYYYY</jformat>
<
style>months</style>
<
from>October 92012</from>
<
to><date jformat="MMMMMMMMM dd, YYYY"/></to>
</
interval>
</
set>
</
think>
<
condition var="years">
<
li value="0">I am <get var="months"/> months old.</li>
<
li>I am <get var="years"/> years old.</li>
</
condition>
</
template>
</
category
 

 
  [ # 1 ]

I like it!!! This would save a lot of hassle in trying to code date functions.

This one is a keeper Rich.

 

 
  [ # 2 ]

I think so, too. It’s going to be fun to play with, but not so fun to code. smile

 

 
  [ # 3 ]

OK I’ve put up a version of Program AB that supports <interval>.

https://code.google.com/p/program-ab/downloads/list

I’m still a little unsure about the <style> attribute.  Should this be a jformat also?
Like to get a custom interval in hours, minutes and seconds, do we want something like

<style>HH:MM:SS</style

 

 

 
  [ # 4 ]

Doesn’t the <date> tag use strftime format? If so, then perhaps so should the <interval> tag, don’t you think?

 

 
  [ # 5 ]

Hello Dave,

My problem with <that> tag, I am Implementing example of online technicians .

<category>
    <
pattern>My Internet is not working</pattern>
    <
template>
Please follow steps.
Disconnect All connections first?
are you ready for next steps?
     </
template>
  </
category

First Case

<category>
    <
pattern>Yes</pattern>
<
that>
Please follow steps.
Disconnect All connections first?
are you ready for next steps?
</
that>
 <
template>
restart your routers and reconnect all connection
are you ready 
for next steps?
     </
template>
  </
category

Second Case

<category>
    <
pattern>Yes</pattern>
<
that>
restart your routers and reconnect all connection
are you ready 
for next steps?
</
that>
 <
template>
Restart your PC and Connect to router again are you ready to next steps?
     </
template>
  </
category

all above code when i used… and when end user said “YES” however only one reply i.e. first one will give to end user while there are two different statemenet in <that> tag. please suggest when to same pattern are exist in two different <that> tag what will be implementation?..... waiting for reply. hope understood what i want to said

thanks in advanced

 

 
  [ # 6 ]

This isn’t related to the <interval> tag. However, I will still help.

Instead of saying, “are you ready for the next steps” all the time, the easiest way to get it to work is for you to rephrase it slightly for each occurence. For example, “Have you done that” or “are you ready to proceed”.

The that tag only need the last sentence in it. Don’t put all your template in there.

 

 
  [ # 7 ]

It may be too late to offer feedback but I concur with Dave Morton’s suggestion to make the interval attributes similar to the date attributes. As it stands you propose a jformat=”...” attribute using different notation to the format=”...” attribute used with date.

In the interests of simplicity for new AIML users (such as myself) I would suggest to use format=”...” with both!

 

 
  [ # 8 ]

The <interval> tag is a work in progress. 

Here is a fun example using <interval> to calculate a client’s age.  The user can say “My birthdate is March 12, 1988” and the bot will tell him his age.

<category><pattern>MY BIRTHDATE IS <SET>MONTH</SET> <SET>NUMBER</SET> <SET>NUMBER</SET></pattern>
<
template>So you are <set var="age"><srai>AGE FROM <star/> <star index="2"/> <star index="3"/></srai></set>. 
<
think>
<
srai>MY AGE IS <get var="age"/></srai>
<
set name="birthdate"><star/> <star index="2"/>, <star index="3"/></set>
</
think></template>
</
category>

<
category><pattern>AGE FROM <SET>MONTH</SET> <SET>NUMBER</SET> <SET>NUMBER</SET></pattern>
<
template><think>
<
set var="from"><set var="m"><star/></set> <set var="d"><star index="2"/></set>, <set var="y"><star index="3"/></set></set>
<
set var="years">
<
interval>
<
jformat>MMMMMMMMM ddyyyy</jformat>
<
style>years</style>
<
from><get var="from"/></from>
<
to><date jformat="MMMMMMMMM dd, yyyy"/></to>
</
interval>
</
set>
<
set var="months">
<
interval>
<
jformat>MMMMMMMMM ddyyyy</jformat>
<
style>months</style>
<
from><get var="from"/></from>
<
to><date jformat="MMMMMMMMM dd, yyyy"/></to>
</
interval>
</
set>
</
think>
<
condition var="years">
<
li value="0"><get var="months"/> months old.</li>
<
li><get var="years"/> years old.</li>
</
condition></template>
</
category
 

 
  login or register to react