Skip to content

Commit 5321826

Browse files
Merge pull request #60 from solyaris/master
WIKI documentation minor corrections
2 parents 78d6c38 + dc8465d commit 5321826

File tree

5 files changed

+201
-673
lines changed

5 files changed

+201
-673
lines changed

WIKI/ChatScript-Advanced-User-Manual.md

Lines changed: 60 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
# ChatScript Advanced User's Manual
2-
3-
> © Bruce Wilcox, gowilcox@gmail.com brilligunderstanding.com
4-
5-
> Revision 1/28/2017 cs7.12
1+
# ChatScript Advanced User's Manual
2+
© Bruce Wilcox, gowilcox@gmail.com www.brilligunderstanding.com
3+
<br>Revision 1/28/2017 cs7.12
4+
<br><br>
65

76
* [Review](ChatScript-Advanced-User-Manual.md#review-overview-of-how-cs-works)
87
* [Advanced Concepts](ChatScript-Advanced-User-Manual.md#advanced-concepts)
@@ -102,14 +101,15 @@ CS just directly embeds the arguments in the string and any attempt to use
102101
the active string implicitly invokes the equivalent of sprintf.
103102

104103
User variables also come in permanent and transient forms.
105-
<br>**Permanent variables** start with a single `$` and are preserved across user interactions
106-
(are saved and restored from disk). You can see and alter their value from anywhere.
107104

108-
<br>**Transient variables** start with `$$` and completely disappear when a user interaction
109-
happens (are not saved to disk). You can see and alter their value from anywhere.
105+
- **Permanent variables**
106+
start with a single `$` and are preserved across user interactions (are saved and restored from disk). You can see and alter their value from anywhere.
110107

111-
<br>**Local variables** (described later) start with `$_` and completely disappear when a user interaction
112-
happens (are not saved to disk). You can see and alter their value only within the topic or outputmacro they are used.
108+
- **Transient variables**
109+
start with `$$` and completely disappear when a user interaction happens (are not saved to disk). You can see and alter their value from anywhere.
110+
111+
- **Local variables**
112+
(described later) start with `$_` and completely disappear when a user interaction happens (are not saved to disk). You can see and alter their value only within the topic or outputmacro they are used.
113113

114114

115115
### Facts
@@ -234,17 +234,16 @@ was this
234234
```
235235
^myfunction( $myvar 1)
236236
```
237-
then the effect of `^argument1 += 1` is as though `$myvar += 1` were done and `$myvar` would now be one
238-
higher. Of course, had you tried to do
239-
`^argument2 += 1` then that would be the illegal `1 += 1` and the assignment would fail.
237+
then the effect of `^argument1 += 1` is as though `$myvar += 1` were done and `$myvar` would now be one higher.
240238

239+
Of course, had you tried to do `^argument2 += 1` then that would be the illegal `1 += 1` and the assignment would fail.
241240

242241
```
243242
outputmacro: ^myfunction( $_argument1 $_argument2)
244243
$_argument1 += 1
245244
```
246245

247-
Use of $_ variables in the function definition is a call by value. All $_ variables are purely local and cannot
246+
Use of `$_` variables in the function definition is a call by value. All `$_` variables are purely local and cannot
248247
be seen outside of the function (or topic) they are used in. You can also mix call by reference and call by
249248
value arguments.
250249

@@ -299,7 +298,8 @@ Concepts can be built from other concepts that do not have specific words.
299298
Concept: ~myconcept (!thisword ~otherconcept)
300299
```
301300

302-
Note: the system has two kinds of concepts. Enumerated concepts are ones formed from an explicit list of members. Stuff in definitions of concept: ~xxx() are that. There are also internal concepts marked by the system. These include part of speech of a word (requires using the pos-tagger to decide from the input what part of speech it was of possibly several), grammatical roles, words from infinite sets like ~number and ~placenumber and ~weburl, and so forth.
301+
Note: the system has two kinds of concepts. Enumerated concepts are ones formed from an explicit list of members. Stuff in definitions of `concept: ~xxx()` are that.
302+
There are also internal concepts marked by the system. These include part of speech of a word (requires using the pos-tagger to decide from the input what part of speech it was of possibly several), grammatical roles, words from infinite sets like `~number` and `~placenumber` and `~weburl`, and so forth.
303303

304304
In a pattern of some kind, if you are referencing a sentence location using a match variable, you can match both kinds of concepts. But if you are not tied to a location in a sentence, you can't match internally computed ones. So something like
305305
```
@@ -323,13 +323,13 @@ When a topic is executing rules, it does not stop just because a rule matches. I
323323
executing rules until some rule generates ouput for the user or something issues an
324324
appropriate `^end` or `^fail` call. So you can do things like this:
325325
```
326-
u: (I love) $userloves = true
326+
u: ( I love ) $userloves = true
327327
328328
u: ( dog ) $animal = dog
329329
330-
u: ( love) Glad to hear it
330+
u: ( love ) Glad to hear it
331331
332-
u: ( dog) I hate dogs
332+
u: ( dog ) I hate dogs
333333
```
334334
and given _I love dogs_, the system will set $userloves and $animal and output glad to
335335
hear it.
@@ -344,27 +344,27 @@ topic: ~rust keep random [rust iron oxide]
344344
```
345345
The flags and their meanings are:
346346

347-
|flag | description |
348-
|-------------|-------------------------------------|
349-
|`Random` | search rules randomly instead of linearly
350-
|`NoRandom` | (default) search rules linearly
351-
|`Keep` | do not erase responders ever. Gambits (and rejoinders) are not affected by this
352-
|`Erase` | (default) erase responders that successfully generate output.<br>Gambits automatically erase unless you suppress them specifically.
353-
|`NoStay` | do not consider this a topic to remain in, leave it (except for rejoinders)
354-
|`Stay` | (default) make this a pending topic when it generates output
355-
|`Repeat` | allow rules to generate output which has been output recently
356-
|`NoRepeat` | (default) do not generate output if it matches output made recently
357-
|`Priority` | raise the priority of this topic when matching keywords
358-
|`Normal` | (default) give this topic normal priority when matching keywords
359-
|`Deprioritize`| lower the priority of this topic when matching keywords
360-
|`System` | this is a system topic. It is automatically `NoStay`, `Keep`.<br>`Keep` automatically applies to gambits as well. The system never looks to these topics for gambits. System topics can never be considered pending (defined shortly). They can not have themselves or their rules be enabled or disabled. Their status/data is never saved to user files.
361-
|`User` | (default) this is a normal topic
362-
|`NoBlocking` | should not perform any blocking tests on this topic in `:verify`
363-
|`NoPatterns` | should not perform any pattern tests on this topic in `:verify`
364-
|`NoSamples` | should not perform any sample tests on this topic in `:verify`
365-
|`NoKeys` | should not perform any keyword tests on this topic in `:verify`
366-
|`More` | normally if you try to redeclare a concept, you get an error. `MORE` tells CS you intend to extend the concept and allows additional keywords.
367-
|`Bot=name` | if this is given, only named bots are allowed to use this topic. See `ChatScript Multiple Bots manual`
347+
|flag | description
348+
|:----------------:|--------------
349+
|__`random`__ | search rules randomly instead of linearly
350+
|__`norandom`__ | (default) search rules linearly
351+
|__`keep`__ | do not erase responders ever. Gambits (and rejoinders) are not affected by this
352+
|__`erase`__ | (default) erase responders that successfully generate output.<br>Gambits automatically erase unless you suppress them specifically.
353+
|__`nostay`__ | do not consider this a topic to remain in, leave it (except for rejoinders)
354+
|__`stay`__ | (default) make this a pending topic when it generates output
355+
|__`repeat`__ | allow rules to generate output which has been output recently
356+
|__`norepeat`__ | (default) do not generate output if it matches output made recently
357+
|__`priority`__ | raise the priority of this topic when matching keywords
358+
|__`normal`__ | (default) give this topic normal priority when matching keywords
359+
|__`deprioritize`__| lower the priority of this topic when matching keywords
360+
|__`system`__ | this is a system topic. It is automatically `nostay`, `keep`.<br>`keep` automatically applies to gambits as well. The system never looks to these topics for gambits. System topics can never be considered pending (defined shortly). They can not have themselves or their rules be enabled or disabled. Their status/data is never saved to user files.
361+
|__`user`__ | (default) this is a normal topic
362+
|__`noblocking`__ | should not perform any blocking tests on this topic in `:verify`
363+
|__`nopatterns`__ | should not perform any pattern tests on this topic in `:verify`
364+
|__`nosamples`__ | should not perform any sample tests on this topic in `:verify`
365+
|__`nokeys`__ | should not perform any keyword tests on this topic in `:verify`
366+
|__`more`__ | normally if you try to redeclare a concept, you get an error. `more` tells CS you intend to extend the concept and allows additional keywords.
367+
|__`bot=name`__ | if this is given, only named bots are allowed to use this topic. See [ChatScript Multiple Bots](ChatScript-Multiple-Bots.md) manual.
368368

369369

370370
## Rules that erase and repeat
@@ -934,7 +934,7 @@ the `_` equivalent) is a single item, whereas ( take charge) is 4 items.
934934

935935
So the first rule will below will match faster than the second rule:
936936
```
937-
u: ( "I love you today when")
937+
u: ("I love you today when")
938938
939939
u: (I love you today when)
940940
```
@@ -1552,7 +1552,7 @@ early termination effects.
15521552
# System Functions
15531553

15541554
There are many system functions to perform specific tasks. These are enumerated in the
1555-
[ChatScript System Functions Manual](ChatScript-System-Functions-Manual.md) manual and the [ChatScript Fact Manual](ChatScript-Fact-Manual.md) manual.
1555+
[ChatScript System Functions Manual](ChatScript-System-Functions-Manual.md) and the [ChatScript Fact Manual](ChatScript-Fact-Manual.md).
15561556

15571557

15581558
## Randomized Output Revisited `[ ]`
@@ -1796,22 +1796,14 @@ and have the system automatically generate gestures during postprocessing on its
17961796
The stand-alone engine and the WEBINTERFACE/BETTER scripts automatically handle
17971797
the following oob outputs:
17981798

1799-
**Callback**: The webpage or stand-alone engine will wait for the designated milliseconds
1800-
and if the user has not begun typing will send in the oob message [callback] to CS. If user
1801-
begins typing before the timeout, the callback is cancelled.
1802-
e.g. `[callback=3000]` will wait 3 seconds.
1799+
- **Callback**
1800+
The webpage or stand-alone engine will wait for the designated milliseconds and if the user has not begun typing will send in the oob message [callback] to CS. If user begins typing before the timeout, the callback is cancelled. e.g. `[callback=3000]` will wait 3 seconds.
18031801

1804-
**Loopback**: The webpage or stand-alone engine will wait for the designated milliseconds
1805-
after every output from CS and if the user has not begun typing will send in the oob
1806-
message [loopback] to CS. If user begins typing before the timeout, the loopback is
1807-
cancelled for this output only, and will resume counting on the next output.
1808-
e.g. `[loopback=3000]` will wait 3 seconds after every output.
1802+
- **Loopback**
1803+
The webpage or stand-alone engine will wait for the designated milliseconds after every output from CS and if the user has not begun typing will send in the oob message [loopback] to CS. If user begins typing before the timeout, the loopback is cancelled for this output only, and will resume counting on the next output. e.g. `[loopback=3000]` will wait 3 seconds after every output.
18091804

1810-
**Alarm**: The webpage or stand-alone engine will wait for the designated milliseconds and
1811-
then send in the oob message [alarm] to CS. Input typing has no effect.
1812-
e.g. `[alarm=3000]` will wait 3 seconds and then send in the alarm.
1813-
CS can cancel any of these by sending an oob message with a milliseconds of 0.
1814-
e.g. `[loopback=0 callback=0 alarm=0]` cancels any pending callbacks into the future.
1805+
- **Alarm**
1806+
The webpage or stand-alone engine will wait for the designated milliseconds and then send in the oob message [alarm] to CS. Input typing has no effect. e.g. `[alarm=3000]` will wait 3 seconds and then send in the alarm. CS can cancel any of these by sending an oob message with a milliseconds of 0. e.g. `[loopback=0 callback=0 alarm=0]` cancels any pending callbacks into the future.
18151807

18161808

18171809
# System callback functions
@@ -2003,7 +1995,7 @@ $tmp = ##first
20031995

20041996
## Defining private Queries
20051997

2006-
see [ChatScript Fact Manual](ChatScript-Fact-Manual.md) manual.
1998+
see [ChatScript Fact Manual](ChatScript-Fact-Manual.md).
20071999

20082000

20092001
## Documenting variables, functions, factsets, and match variables
@@ -2091,7 +2083,7 @@ Normally lower case words would break up a title.
20912083

20922084
# Common Script Idioms
20932085

2094-
## Selecting Specific Cases ^refine
2086+
## Selecting Specific Cases `^refine`
20952087

20962088
To be efficient in rule processing, I often catch a lot of things in a rule and then refine it.
20972089
```
@@ -2144,6 +2136,7 @@ u: (where * you * live) ^reuse(HOUSE)
21442136
The rule on disabling a rule after use is that the rule that actually generates the output gets disabled.
21452137
So the default behavior (if you don't set keep on the topic or the rule) is that if the question is asked first,
21462138
it reuses HOUSE.
2139+
21472140
Since we have given the answer, we don't want to repetitiously volunteer it, HOUSE gets disabled.
21482141
But, if the user repetitiously asks the question (maybe he forgot the answer), we will answer it again because the responder
21492142
didn't get disabled, just the gambit. And disabling applies to allowing a rule to try to
@@ -2218,7 +2211,7 @@ The user prompt wants to use the user's login name so it is a format string, whi
22182211
processed and stored on the user prompt variable. The botprompt wants to force a space
22192212
at the end, so it also uses a format string to store on the bot prompt variable.
22202213

2221-
### In color.tbl is there a reason that the color grey includes both building and ~building?
2214+
___In color.tbl is there a reason that the color grey includes both building and ~building?___
22222215

22232216
Yes. Rules often want to distinguish members of sets that have supplemental data from
22242217
ones that don't. The set of ~musician has extra table data, like what they did and doesn't
@@ -2228,7 +2221,7 @@ has supplemental data available.
22282221
This is made clearer when the set is named something list `~xxxlist`.
22292222
But the system evolved and is not consistent.
22302223

2231-
### How are double-quoted strings handled?
2224+
___How are double-quoted strings handled?___
22322225

22332226
First, note that you are not allowed strings that end in punctuation followed by a space.
22342227
This string _"I love you. "_ is illegal. There is no function adding that space serves.
@@ -2269,7 +2262,7 @@ spacing and punctuation, and stripping off the double quotes.
22692262
u: (test) ^"This $var is good." # if $var is kid the result is This kid is good.
22702263
```
22712264

2272-
### What really happens on the output side of a rule?
2265+
___What really happens on the output side of a rule?___
22732266

22742267
Well, really, the system "evaluates" every token. Simple English words and punctuation
22752268
always evaluate to themselves, and the results go into the output stream. Similarly, the
@@ -2310,7 +2303,7 @@ value.
23102303
Calling a function discards any output stream generated and aside from other side
23112304
effects means did the function fail (return a fail code) or not.
23122305

2313-
### How does the system tell a function call w/o ^ from English ?
2306+
___How does the system tell a function call w/o ^ from English?___
23142307

23152308
If like is defined as an output macro and if you write:
23162309
```
@@ -2326,7 +2319,7 @@ When it is a user function, it looks to see if the
23262319
Contiguous is treated as a function call and apart is treated as English.
23272320
This is not done for built-ins because it's more likely you spaced it accidently than that you intended it to be English.
23282321

2329-
### How should I go about creating a responder?
2322+
___How should I go about creating a responder?___
23302323

23312324
First you have to decide the topic it is in and insure the topic has appropriate keywords if
23322325
needed.
@@ -2337,7 +2330,7 @@ sentence. This will tell you how the system will tokenize it and what concepts i
23372330
trigger. This will help you decide what the structure of the pattern should be and how
23382331
general you can make important keywords.
23392332

2340-
### What really happens with rule erasure?
2333+
___What really happens with rule erasure?___
23412334

23422335
The system's default behavior is to erase rules that put output into the output stream, so
23432336
they won't repeat themselves later. You can explicitly make a rule erase with `^erase()` and
@@ -2354,12 +2347,11 @@ These can never erase themselves directly, so the erasure will again rebound to
23542347

23552348
Note that a topic declared system NEVER erases its rules, neither gambits nor responders,
23562349
even if you put ^erase() on a rule.
2357-
2358-
> How can I get the original input when I have a pattern like
23592350
```
23602351
u: (~emogoodbye)
23612352
```
2362-
### How can I get the original input when I have a pattern like `u: (~emogoodbye)` ?
2353+
2354+
___How can I get the original input when I have a pattern like `u: (~emogoodbye)` ?___
23632355

23642356
To get the original input, you need to do the following:
23652357
```
@@ -2569,8 +2561,7 @@ does a "cd ChatScript" to be in the right directory, and then runs ChatScript wi
25692561
following parameters:
25702562

25712563
```
2572-
ChatScript livedata=../LIVEDATA english=LIVEDATA/ENGLISH
2573-
system=LIVEDATA/SYSTEM
2564+
ChatScript livedata=../LIVEDATA english=LIVEDATA/ENGLISH system=LIVEDATA/SYSTEM
25742565
```
25752566

25762567
Normally while you might override various substitutes files, you would not override the
@@ -2599,6 +2590,3 @@ them when you run CS.
25992590

26002591
[[Wiki home](/WIKI/README.md)] - [[Basic User Manual](ChatScript-Basic-User-Manual.md)]
26012592

2602-
---
2603-
2604-
© Bruce Wilcox, mail: gowilcox@gmail.com web: www.brilligunderstanding.com revision: 12/7/2016 cs6.91

0 commit comments

Comments
 (0)