简体   繁体   中英

Responding to multiple matches in Chatscript

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?

You could create au: 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM