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

Control Scripts: How To Invoke Topic Before Anything Without Modifying The Natural Flow Of The Control Script
 
 

Hi all,

I have a topic called ~generic_data_extraction, which as you can guess, encapsulate some generic scripts that extract some basic information that other topics can use.

I was thinking to use the control script to invoke this topic before any other topic, I’ve tried some ways to do so but I’m afraid it interfere with the “natural flow” of the system.

I want everything to work the same as if this script were never executed. the only affect of the generic data extraction script should be to create some facts about the input.

So far, I’m using simplecontrol.top from the HARRY bot. I think the code that invoke the generic_data_extraction topic should be somewhere in this part, but I’m not sure how to implement it:

simplecontrol.top…

u: () # main per-sentence processing

 
$$currenttopic = %topic  # get the current topic at start of volley

 
if ( %response == {nofail(TOPIC ^rejoinder())# try for rejoinders. might generate an answer directly from what we are looking for.

 
if (%length == AND %response == )
 
{
  nofail
(TOPIC ^gambit($$currenttopic))  # gambit current topic since no input (usually start of conversation)
 

...

Thanks for any advice,

Sam

 

 
  [ # 1 ]

Control scripts may seem intimidating, but really it’s easy.  Your proposed topic does not generate any user output, so it will not affect control. So you can put
  $$currenttopic = %topic # get the current topic at start of volley
  respond(~generic_data_extraction)
for example. You can actually put it “anywhere”, before the getting of the currenttopic (since likely your topic doesnt use it) or after any of the ifs because you are probably gathering facts for later use, not for use this volley.
The “nofail” clause, like nofail(TOPIC respond(~generic_data_extraction))  merely would protect you against accidental use of fail(TOPIC) from within your topic. Normally one would not expect to explicitly fail a topic, but if you did, that is reflected on the caller as a failure of the rule calling, which in this case is a failing of the entire control script.

 

 
  [ # 2 ]

The code and explanation you’ve offered is excellent and it works for me.

However I’m having some difficulties with private substitutes.

It’s powerful tool, but it seems like it running the control script for every substitutes, before and after it were applied.
In most cases it make sense but in my case, it interfere with the order I’m planning for the topics.

Let say I have some input that is matching the patterns in the ~generic_data_extraction only after some substitutes.
This input is matching some other specific topics even before the substitutes were applied.
I need all the other topics to run only after the “main” topic ~generic_data_extraction, because they using the facts and vars it creates.

So, in general, I need to understand how the substitutes mechanism works for private and non private and how to control its default behavior.

Thanks again,

Sam

 

 
  [ # 3 ]

I will answer some question but it may not be what you are asking since your statements don’t fully jibe with me.
LIVEDATA contains a variety of substitutions files controlled by $token. These substitutions all happen to transform your input before it is fully analyzed by CS - it does not parse or mark concepts or canonicals until after substitutions have happened. Private substitutions you declare in script files are an extension of these you directly control and happen at the same time.  Therefore ALL patterns in ALL topics are matched after ALL substitutions have been performed.

These substitutions are fast and context insensitive. Additionally, one can write script that is as sensitive to context as you like and use ^input to revise the current input to something else. I do pronoun resolution via this rewriting or alter “if you own a dog, do you have a pet” to be more canonically “assume you own a dog.  do you have a pet”.  This can even be run before normal control happens, by assigning such a topic to $prepass in the bot configuration data.  Using ^input is a more expensive substitution mechanism since the full parse/mark pass of CS happens on the initial input, and then on the revised input.

 

 
  [ # 4 ]

You are right, I was confused by the log on “:trace all”.

I did private substitute like this:

replace:  <some_words ~someconcept

And it seems like the system divide the sentence into two:

Example input: “some words were said”

Sentence #1: ~someconcept

Sentence #2: were said.

So, the system running the script only after all substitutions have been performed, but everything is running ones for every “sentence”. I did some changes to my script to deal with it but I’ll try also your suggestion on doing contextual substitutions using the ^input function.

Thank you very much,

Sam

 

 
  [ # 5 ]

tilde words are not normal english, so in chatscript when they start a sentence they represent “interjections” and “discourse acts”. And by default the $token has #DO_INTERJECTION_SPLITTING so they are split into separate sentence so that
“Yes. I went” and “yes, I went”  are canonically the same input.  Ergo you defined a new discourse act.  You could turn off interjection splitting (which would turn it off universally which you probably dont want), remap your substitution to a non-tilde word to detect like “xxxsomeconcept” , or use ^input.

 

 
  [ # 6 ]

That is very interesting, thanks Bruce!

 

 
  login or register to react