Responding to multiple matches in Chatscript

516 Views Asked by At

I am currently trying to learn Chatscript but the documentation seems to be poor. My current issue is how to respond to a multi-statement match to input. So, if I say "Hi. Tell me about yourself" and I have a match for "hi" and "about yourself" it will respond to the first match and not the last. I'm pretty sure I need the control script to change to fix this but am not sure which commands to use. Maybe something that stores all matches in last input and can pick a specific one?

1

There are 1 best solutions below

0
On

You could create a u: response that uses ^next & refine() to move through the sentences starting with something like ~greeting. This is pseudo code:

u: ( ~greeting ) 

   ^refine()

 a: ( %more ) 

    ^next(input) 
    ^refine()

    b: ( you be ? )

       I'm good!

    b: ( %lenght==0 ) 

       Hi!

(ChatScript System Functions Manual)

^next(what label) – given what of GAMBIT or RESPONDER or REJOINDER or RULE and a rule label or tag, find the next rule of that what. Fails if none is found. REJOINDER will fail if it reaches the next top level rule. If label is “~”, it will use the last call's answer as the starting point, enabling you to walk rules in succession. There is also ^next(FACT @xxx) – see fact manual. For ^next(input) the system will read the next sentence and prep the system with it. This means that all patterns and code executing thereafter will be in the context of the next input sentence. That sentence is now used up, and will not be seen next when the current revised sentence finishes.