5.6 Advanced Variables
Local Variables : $xxx and $$xxx are all global in scope.
$_xxx are local variables.
Indirection Variables :
Bot variables :
Assigning match variables to user variables : Match variables hold 3 pieces of data
- original word(s)
- canonical word(s)
- position, range location of the word(s)
JSON dotted notation for variables : $x = $$$obj.name.value.data.side
Fact dotted notation for variables : $$f.subject $$f.verb $$f.object
5.7 Out of band Communication
CS can neither see nor act, but it can interact with systems that do. The convention is that out-of-band information occurs at the start of input or output, and is encased in [ ] .
Eg. the input like, [ speed=10 rate: 50 ] User said this . the 2 data oob items.
Here is a sample pattern to catch oob data.
u: ( < \[ * speed _*1 * \] ) The speed is _0
u: ( < \[ * rate _*1 * \] ) The rate is _0
The stand-alone engine and the WEBINTERFACE/BETTER scripts automatically handle the following oob outputs :
5.8 System callback functions
^CSBOOT() : startup of the ChatScript system.^CS_REBOOT() : executed on every volley prior to loading user data.
^CSSHUTDOWN() :
^cs_topic_enter() :
^cs_topic_exit() :
AutoInitFile :
5.9 Advanced :build
Build warning message : Build will warn you of a number of situations which, not illegal, might be mistakes. It has several messages about words it doesn't recognize being used as keywords in patterns and concepts. You can suppress those messages by augmenting the dictionary OR just telling the system not to tell you :
:build 0 nospell
Files : :build will ignore files that end in ~ or .bak
Trace : Finding where the problem is may be hard.
:build harry trace
Reset User-defined :
:build 0 reset
Build Layers : The build system has two layers, 0 and 1.
Skipping a topic file : :quit
Block comments :
##<< first junk
some junk
##>> more junk
Renaming Variables, Sets, and Integer Constants :
Defining private Queries :
Documenting variables, functions, factsets, and match variables :
Conditional compilation :
5.10 Editing Non-topic Files
Non-topic files include the contents of DICT and LIVEDATA.
DICT files :
LIVEDATA files : The substitutions files consistof pairs of data per line. The first is what to match. Individual words are separated by underscores, and you can request sentence boundaries < and > .
Processing done by various of these files can be suppressed by setting $cs_token differently. See Control over Input.
5.11 Common Script Idioms
Selecting Specific Cases ^refine : To be efficient in rule processing, I often catch a lot of things in a rule and then refine it.
u: ( ~country ) ^refine()
a: (Turkey) I like Turkey
a: (Sweden) I like Sweden
a: (*) I've never been there
Using ^reuse :
t: HOUSE () I live in a small house
u: ( where * you * live ) ^reuse(HOUSE)