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

Handling multiple inputs
 
 

I would to like to analyze all the multiple sentences before choosing which to respond to based on words in the sentences. Specifically, I would like to order the keywords i find in a factset and then adjust the respond or reuse statements based on that in the control script. I tried the following script at the start of control but as I suspected it returns an empty response. I assume this is because nextinput does not just return a string but processes the input. How do I join each sentence in the input block to be searched with findtext?

$$sentence = ‘_0
$$currenttopic = %topic # get the current topic at start of volley
$$responsecount = %response
# Sentence is $$sentence

if (%more) { $$ni = next(input)
join($block $$ni)}
else { print($block)
if(findtext($block "home" 0)) {found home}
  if(findtext($block “name” 0)) {found name}
}

 

 
  [ # 1 ]

In the next release I will supply %originalinput and %originalsentence which would make it easy for you. But that may not be released for a week.

In the interim you could do something more complex.  Basically you want to run two passes over the input. In pass one $cs_token is 0. You have a single control script rule which loops like this:

You define your bot to do $cs_token = 0

u: ($!pass2)
  loop()
  {
respond(~gatherkeywords)
if (%more) {next(Input)}
    else {end(rule)}
  }
  $$pass2 = 1
  $cs_token = whatever you normally want
  ^retry(input)

u: (!%more)  $cs_token = 0
.. your normal control script

and in ~gatherkeywords
u: (_*)  go get the keywords of here

 

 
  [ # 2 ]

Thanks bruce. What does cs_token do exactly? It just seems to have flags. Is token 0 equal to DO_PARSE? Also instead of using findtext to match a string in the entire inputblock, is there any way to use a pattern to do it?

 

 
  [ # 3 ]

I dont understand what findtext has to do with it. what text would you match against it.

You could turn on tokencontrols that disable sentence separation NO_SENTENCE_END NO_HYPHEN_END NO_COLON_END NO_SEMICOLON_END
then call ^analyze($$originalinput)  then respond(~yourtopicwithpatterns)
then turn back on tokencontrols and ^reuse(INPUT) to resume normal operations

 

 
  [ # 4 ]

I just want to prioritize responding to certain strings in the whole input over others all the time. Say I have a number of topics like money, relationship, suicide, depression. A common response in all would be (I feel *) but I should prioritize which topic I respond from in the control script based on what * is, so I need to match all possible words and arrange topics based them in factlist with highest priorirty topics at top, respond from topmost first then move to the next when previous problem is solved. I dont really need to use patterns since I’m looking for specific word strings but patterns would also be use to refine the searching.


I assume the script you just gave will only work with the next release since it has the var $$originalinput which I assume can be got from %originalinput?

A critical response could be:
Things look bad. I feel like killing myself.
or
Things look bad. Death appeals to me.

I would need to switch topic from general depression to suicide on this but cannot do that in the control script after it has matched _*.

 

 
  [ # 5 ]

” What does cs_token do exactly? It just seems to have flags. Is token 0 equal to DO_PARSE?”

cs_token controls how the system handles user input, controlling tokenization, sentence splitting, parsing postagging, spellcheck etc.

DO_PARSE has a non-zero value (you can find values in dictionarysyste.h of src).

 

 
  login or register to react