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

compare list
 
 

hello sorry for my bad english

i am trying to let my bot search for a word or a number to see if there is a mach in a list…..


<category>
    < pattern >is there * in my list</pattern>
    <think><set name=“x”></set></think>
    <template>give me the list….</template>
</category>

<category>
    < pattern >the list is *</pattern>
    <that>give my the list.</that>
    <template><condition name=“x”>
      <li name=“x”>yes there is </li>
      <li name=“x *”>yes there is </li>
      <li name=”* x”>yes there is </li>
      <li name=”* x *”>yes there is </li>
      <li>no there is not</li>
    </condition></template>
  </category>
[/li][/ul]


can somebody help me with the aiml file?

i started from this example

<category>
< pattern >DOES my list CONTAIN 1 *</pattern>
<template><think><set name=“compare”><star></set></think>
<condition name=“compare”>
<li value=“1”>Yes, i have found it.</li>
<li value=“1 *”>Yes,i have found it.</li>
<li value=”* 1”>Yes,i have found it.</li>
<li value=”* 1 *”>Yes,i have found it.</li>
<li>No. Your input didn’t have 1 in it.</li>
</condition></template>
</category>

this works however the bot search only for value 1 Obviously….

 

 
  [ # 1 ]

sorry I forgot a <star>  in the first category

<category>
  < pattern >is there * in my list</pattern>
  <think><set name=“x”><star></set></think>
  <template>give me the list….</template>
</category>

<category>
  < pattern >the list is *</pattern>
  <that>give my the list.</that>
  <template><condition name=“x”>
    <li name=“x”>yes there is </li>
    <li name=“x *”>yes there is </li>
    <li name=”* x”>yes there is </li>
    <li name=”* x *”>yes there is </li>
    <li>no there is not</li>
  </condition></template>
  </category>

 

 
  [ # 2 ]

Yes, we can easily do this with an AIML utility I wrote called BOTCOMPARE, available for free at: http://www.square-bear.co.uk/aiml (Botcompare.aiml)

This is used by calling BOTCOMPARE x XSPLIT y and checking the value of a variable returned called “match”, which will be YES for a match and NO for a mismatch.

The aiml file is designed for use with Pandorabots as it relies heavily on learn and eval tags which may not be supported in other interpreters.

Load botcompare.aiml into your bot. You can then use the following code to achieve your objective:

<category>
  <
pattern>IS THERE IN MY LIST</pattern>
  <
template>
    <
think><set name="checkfor"><star/></set></think>
    
Give me the list.
  </
template>
</
category>

<
category>
<
pattern>THE LIST IS *</pattern>
<
that>GIVE ME THE LIST</that>
<
template>
  <
think>
    <
set name="list"><star/></set>
    <
set name="found">NO</set>
    <
srai>CHECKLIST <get name="list"/></srai>
  </
think>
  <
condition name="found">
    <
li value="YES">Yes there is.</li>
    <
li value="NO">No there is not.</li>
  </
condition>
</
template>
</
category>

<
category>
<
pattern>CHECKLIST * *</pattern>
<
template>
  <
srai>BOTCOMPARE <star/> XSPLIT <get name="checkfor"/></srai>
  <
condition name="match">
    <
li value="YES"><set name="found">YES</set></li>
  </
condition>
  <
srai>CHECKLIST <star index="2"/></srai>
</
template>
</
category>

<
category>
<
pattern>CHECKLIST *</pattern>
<
template>
  <
srai>BOTCOMPARE <star/> XSPLIT <get name="checkfor"/></srai>
  <
condition name="match">
    <
li value="YES"><set name="found">YES</set></li>
  </
condition>
</
template>
</
category

Sample dialogue:

Human: is there red in my list
Bot: Give me the list.

Human: the list is blue green red yellow
Bot: Yes there is.

Human: is there red in my list
Bot: Give me the list.

Human: the list is green blue orange
Bot: No there is not.

Hope this helps. It will only work in its present form if the thing you are checking for is just one word. If you need help amending it to check for more than one word, let me know.

 

 
  [ # 3 ]

thanks a lot !!!!!!!!

for the moment i’ts ok

if you have time to post it i would be interested to see how the code looks

for example if I have to check a list with name and surname….....

 

 
  [ # 4 ]

Could you post some sample dialogue and I will try to code some AIML that will do this for you. Are you either using a Pandorabot server to host your bot on or using Program AB for your bot? Otherwise, it’s not going to be much use to you.

 

 
  [ # 5 ]

i have set a pandorabot

normaly i work with denise virtual assistant but the condition tag seems not to work at all…....

an example of discussion is:

HUMAN : is there bob dylan in my list
BOT   :  give me the list i will check for you

HUMAN : alicia keys, amelia lily, black eyed peas, bon jovi
BOT   : NO, there is no bob dylan in the list

obviously if he finds the name he say yes there is bob dylan in the list

I am asking myself if I it easier if I put a ” _ ” between the names


anyway the majority of the users would not like to do so

 

 

 

 

 

 
  [ # 6 ]

Well you can’t put a _ as this will be treated as a wildcard but you will need to split each item on your list or the code won’t know where one item ends and the other begins.

How about splitting them with a neutral word like SPLITTER? You could then amend the category which has:

<pattern>CHECKLIST * *</pattern

to say:

<pattern>CHECKLIST SPLITTER *</pattern

Sample dialogue:

Human: is there bob dylan in my list
Bot: Give me the list.

Human: the list is alicia keys SPLITTER amelia lily SPLITTER black eyed peas SPLITTER bon jovi
Bot: No there is not.

Human: is there bob dylan in my list
Bot: Give me the list.

Human: the list is lady gaga SPLITTER bob dylan SPLITTER elvis presley SPLITTER iron maiden
Bot: Yes there is.

Including the SPLITTER separator shows where to split each item in the list and is the reason I have to include XSPLIT in my botcompare command, as it’s doubtful anyone wants to check for the word XSPLIT and allows me to check for multi word comparisons.

Hope that makes sense.

 

 
  [ # 7 ]

The only other way I can think of if your users don’t want to put a separator is to have them enter one item at a time and append the splitter yourself, looping round until the list was complete. This would be painful if the list was too long though.

 

 
  [ # 8 ]

yes it makes sense¨!

  what if we use a sing ?

it’s faster to type….......

 

 
  [ # 9 ]

Assuming you mean sign, all punctuation is stripped out of any input before it is processed, so while it would be a great idea to use a comma like in a normal list, this wouldn’t work here. The best you could do would be to put a single letter like:

red X orange X light blue X black eyed peas

 

 
  [ # 10 ]

yes I was meaning sign smile  “lol”

  thanks a lot it was very useful….... l

 

 

 
  [ # 11 ]

No problem. Always happy to help with these types of challenges. It helps keep my old brain active! grin

 

 
  [ # 12 ]

ok i have checked the code it worked once…........  and then it stopped working…...

I have tried to copy and paste it again but nothing…...

 

 

 
  [ # 13 ]

Did you load my botcompare.aiml file into your bot?
Did you republish your bot when you copied and pasted the categories in this thread into your bot?
What separator are you using?
Could you post a sample log you had where it didn’t work?

 

 
  [ # 14 ]

I did not load the botcompare.aiml

how can I republish my bot?

at the beginning I didn’t use a separator and it worked…..

I will try those things and I let you know…...

 

 
  [ # 15 ]

If you didn’t load botcompare.aiml, it has no chance of working as this is vital to using the BOTCOMPARE x XSPLIT y command. You republish your bot by selecting it and choosing publish, the same way when you make any updates to it.

I can only only assume the one chance it worked for you was when the item wasn’t in the list, as BOTCOMPARE wouldn’t have been called and so the “found” variable would remain at “NO”.

 

 1 2 > 
1 of 2
 
  login or register to react