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

Parse message
 
 

On my system, I need to send messages to chatstsript with keywords in the beginning of the sentence. I need to separate the keywords and send the message on. Please tell me how to do it better

 

 
  [ # 1 ]

Not sure I understand. An example would help.  Maybe you mean
“Tell him that I love him”

u: (tell him _*) ‘_* 

this would output the words after the keywords but I don’t know what you want for “send the message on”

 

 
  [ # 2 ]

For example “Tell him that I love him”. I write the code

u: (_*1 _*) ^keep() ^repeat()
$KeyWord = _0   #Tell him
^input(_1)        #that I love him
^fail(SENTENCE)

I need to separate the keywords ($KeyWord = _0   #Tell him) and processing message “that I love him” in this topics.

u (that I love him) ...

if($KeyWord == Tell him)
{
....
}

 

 
  [ # 3 ]

so… _*1 does not capture “tell him”, it only captures tell.
if “tell him” is a keyword, then you can write
u: (tell him _*) ^keep() $keyword = “tell him”
^input(‘_1) ^fail(SENTENCE)

u: (that I love him) if ($keyword == “tell him”) {...}

since the 1st rule does not generate output, you don’t need ^repeat()
to keep the submitted input faithful to the original (not canonical form) you need ‘_1 and not _1.
To test the keyword you cant say tell him, which only tests one word, you need to quote the phrase.

 

 
  [ # 4 ]

I can separate key for “Tell : him : that I love him” ?

u: (_*1 : _*1 :  _*) ^keep()
$keyword = _0
$keyword2 = _1
^input(‘_3)
  ^fail(SENTENCE)

For different variables $keyword and $keyword2

u: (that I love him) if ($keyword == “tell him”) {...}

 

 
  [ # 5 ]

Yes you can do that, although you’ll have to control the input tokenization which would otherwise break into multiple sentences at the : .  If you pick a different separator character that won’t happen.

But why even do that?

your code is incorrect in that you have 3 wildcards and refer to them as _0 _1 _3 (needs to be _2).
And $keyword is set to tell but tested as tell him.

What is it that you don’t like about the code I proposed before?

 

 
  [ # 6 ]

Yes _0 _1 _2. Last version of the code is more versatile.  Сharacter ‘_1 is necessary. Not work. Maybe ‘_1 but is canonical form…

 

 
  [ # 7 ]

I can’t say I understood your meaning in this last post. So let me instead say——do you have any more questions for me or do you understand enough now?

 

 
  [ # 8 ]

thank you very much!

 

 
  login or register to react