AI Zone Admin Forum Add your forum
how to make <pattern> can receive multiple synonym input
 
 

i have project to enable chabot receive synonim input.firstly for a word is not problem.

<category>
<pattern>apple</pattern>
<template>fruit</template>
</category>

<category>
<pattern>orange</pattern>
<template><srai>apple<srai></template>
</category>

but i have problem when there are sectence input…

<category>
<pattern>apple is sweet</pattern>
<template>fruit have many vitamins</template>
</category>

the term sweet i make synonim to sweet/lot of sugar/tasty/cool
so how i can use input synonim to get the same answer “fruit have many vitamins”“

i already try use star for sweet.


<category>
<pattern>apple is *</pattern>
<template><srai>apple is sweet</srai></template>
</category>

but this case its receive any input to respond “<srai>apple is sweet</srai>”
so how i want to manage “*” to only detect synonim term to sweet/lot of sugar/tasty/cool

plz help me..

 

 
  [ # 1 ]

You could do this by making a set of <srai>s for sweet.

<category>
<
pattern>_ TASTY</pattern>
<
template><srai><star/> sweet</srai></template>
</
category>

<
category>
<
pattern>_ SUGARY</pattern>
<
template><srai><star/> sweet</srai></template>
</
category

and so on.

Dave - This thread may be better in the AIML board.

 

 
  [ # 2 ]

Good idea, Steve. I’ve moved it. smile

I also fixed Haqa’s post (welcome to the forums, by the way!) so that the <pattern> tags were visible. I was going to answer the post as well, but I couldn’t come up with a coherent answer, and I knew that you would be along at some point with something far better than I could come up with, so I left it be for the time being. smile

 

 
  [ # 3 ]

Thanks Dave - I thought you lived in Nevada. You are up early/late. It’s just turned 8:20 am here in the UK.

Haqa - Bear in mind that you need to be careful about which words you <srai>. In your example, you gave the word “cool” to <srai> to “sweet”. This will produce unwanted results, for example:

Human: The weather is cool.
Bot: How can weather be sweet?

or

Human: These fries are tasty.
Bot: You put sugar on your fries?

 

 
  [ # 4 ]

I do live in Nevada, Steve. I’m pulling an “all-niter”, working on Program O. Liz Perreau lives in your neck of the woods, so if we’re going to meet up to get things done, one of us needs to alter their schedule, and one should never deprive a lady her sleep. raspberry

 

 
  [ # 5 ]

how to make <pattern> can receive multiple synonym input
I think you want one of

1. how can one make <pattern> receive multiple synonym input
2. how can one make <pattern> so it can receive multiple synonym input

 

 
  [ # 6 ]

How many languages do you speak, Victor? wink

 

 
  [ # 7 ]
C R Hunt - Mar 9, 2012:

How many languages do you speak, Victor? wink

I know but it doesn’t negate the fact that one should learn.

If I can only drive one type of vehicle, say a car, but someone else can drive a car and fly a airplane, if they are driving on the wrong side of the road, I’ll inform them smile

 

 
  [ # 8 ]

thanks for Steve and Dave..

actually my problem is how to ensure the receive multiple synonims words that i already declare at the begin.

<!--this is just example of synonims-->
<!--
synonims of action-->

<
category>
<
pattern>give</pattern>
<
template>given</template>
</
category>

<
category>
<
pattern>get</pattern>
<
template><srai>give</srai></template>
</
category>

<
category>
<
pattern>giving</pattern>
<
template><srai>give</srai></template>
</
category>

<!--
synonims of object-->

<
category>
<
pattern>ball</pattern>
<
template>object</template>
</
category>

<
category>
<
pattern>doll</pattern>
<
template><srai>ball</srai></template>
</
category>

<
category>
<
pattern>robot</pattern>
<
template><srai>ball</srai></template>
</
category>

<!--
synonims of condition-->

<
category>
<
pattern>must</pattern>
<
template>need</template>
</
category>

<
category>
<
pattern>should</pattern>
<
template><srai>must</srai></template>
</
category>

<
category>
<
pattern>really</pattern>
<
template><srai>must</srai></template>
</
category>

<!--
synonims of support-->

<
category>
<
pattern>always</pattern>
<
template>support</template>
</
category>

<
category>
<
pattern>should</pattern>
<
template><srai>always</srai></template>
</
category>

<
category>
<
pattern>really</pattern>
<
template><srai>always</srai></template>
</
category>

<!-- 
end of synonims-->

So my pattern in like this example:

<
category>
<
pattern>give ball must daily</pattern>
<
template>you are kind person</template>
</
category>

So how i want to manage pattern to ensure only detect sentence that come from synonims that i have already declare.

i dont want use pattern like this to get the same result..

<
category>
<
pattern>get robot should always</pattern>
<
template><srai>give ball must daily</srai></template>
</
category>

User that use my chatbot need to use word synonyms that i already declare to get same result "you are kind person" 

Can i have <pattern>* * * *</pattern> to detect the synonyms word that i have declare.

how the best way to solve my problem.I already new in AIML..
sorry for my broken spelling..

-haqa

 

 
  [ # 9 ]

Haqa, when you post AIML code (or any scripting language code, for that matter), it’s best to place the code within [ code] tags (the space there was so the tag would display for me). that way your postings won’t get mangled by the forum software.

 

 
  [ # 10 ]

thanks Dave.

So did u understand about my problem.
I’m still waiting for best solution.Should i use Javascript to integrate with AIML.

i need the solution for my final project.

plz hlp me. downer

 

 
  [ # 11 ]

Sadly, Haqa, my skills with AIML are not enough to be able to give you an answer that you might find useful. Without a doubt, Steve is the best and most qualified individual for helping you in this matter. I’m sure he’ll be along shortly. Just have a wee bit of patience. smile

 

 
  [ # 12 ]

Are you saying that everytime someone says, “robot”, you want your bot to understand this as “ball”?  I don’t understand why anyone would want to do this but if you must do something like that then you need patterns like this for each word you want to use:

<category>
<
pattern>ROBOT</pattern>
<
template><srai>ball</srai></template>
</
category>

<
category>
<
pattern>ROBOT *</pattern>
<
template><srai>ball <star index="1"/></srai></template>
</
category>

<
category>
<
pattern>_ ROBOT</pattern>
<
template><srai><star index="1"/> ball</srai></template>
</
category>

<
category>
<
pattern>_ ROBOT *</pattern>
<
template><srai><star index="1"/> ball <star index="2"/></srai></template>
</
category

However, I can’t think of a situation where this would be helpful. You will start to see nonsense such as:

Human: Are you a robot?
Bot: No I am not a ball.

Human: Do you know what a robot is?
Bot: Sure, a ball is a round thing that people kick.

Maybe if you explained what you are trying to achieve, we could guide you better.

 

 
  [ # 13 ]

Haqa,
You could use Javascript in front of your AIML interpreter to do what you want. It would be a simple search and replace. This technique is often used to validate web forms before they are submitted. But if you do that, you need to think about how the logic flows through to the interpreter.

Steve is of course the best guy to answer your question but I do see some issues with the logic of your AIML.

<category>
<pattern>ball</pattern>
<template>object</template>
</category>

<category>
<pattern>doll</pattern>
<template><srai>ball</srai></template>
</category>

<category>
<pattern>robot</pattern>
<template><srai>ball</srai></template>
</category>

Doll and robot both map to ball which then maps to “object”. It would be more efficient to map these directly to “object”.
“get” and “giving” map to “give” and always maps to “given”.
“should” and “really” map to “always” and “always” maps to “support”.

If you did the full replacements in your example:
“get robot should always”

you would end up with:
“given object support support”

You would need to check for “support support” and map that to “support”.
I suggest that all your synonyms map to the final target.

 

 
  [ # 14 ]

thanks all.

i already got my solution for my problem.

this is my solution:

<category>
<
pattern>student like eat apple</pattern>
<
template>that lot of vitamin
</template>
</
category>>

<
category>
<
pattern>* * * *</pattern>
<
template>
<
srai>
<
think><set name="a"><srai><star index="1"/></srai></set></think>
<
condition name="a">
  <
li value="actor">studentl</li>
</
condition>

<
think><set name="b"><srai><star index="2"/></srai></set></think>
<
condition name="b">
  <
li value="respond">like</li>
</
condition>

<
think><set name="c"><srai><star index="3"/></srai></set></think>
<
condition name="c">
  <
li value="action">eat</li>
</
condition>

<
think><set name="d"><srai><star index="4"/></srai></set></think>
<
condition name="d">
  <
li value="subject">apple</li>
</
condition>
</
srai>
</
template>
</
category

the [li value] is all synonims that i have declare at the begin.

 

 
  [ # 15 ]

This will only work if you have no patterns that override this (which is basically anything as the * wildcard is the lowest match of all). A much better way would be to use <srai> as I posted above.

 

 1 2 > 
1 of 2
 
  login or register to react