Skip to content

Commit 0a598c4

Browse files
Update ChatScript-Training.md
1 parent b2fb275 commit 0a598c4

File tree

1 file changed

+103
-78
lines changed

1 file changed

+103
-78
lines changed

WIKI/PAPERS/ChatScript-Training.md

Lines changed: 103 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,9 @@ u: MYRULE ( I love meat) So do I.
135135
* `u:` - responds to union of questions and statements
136136

137137
* _Gambits_ – program says when it has sente
138-
* t: Have you ever had a pet?
138+
```
139+
t: Have you ever had a pet?
140+
```
139141

140142
* _Rejoinders_ – based on what we just said to user
141143
```
@@ -174,17 +176,19 @@ a: (no) Pets are fun. You should try having one.
174176

175177
* Executed if a rule's pattern matches
176178
- Can be simple text
177-
178-
?: ( << you ~like pizza >>) I love pizza.
179-
179+
```
180+
?: ( << you ~like pizza >>) I love pizza.
181+
```
180182
- Can be random text
181-
182-
?: ( << you ~like pizza >>) [Of course][Absolutely] I [love it.][ adore it.]
183+
```
184+
?: ( << you ~like pizza >>) [Of course][Absolutely] I [love it.][ adore it.]
185+
```
183186

184187
* Text autoformats
185188
- Can be code and text intermix or code only
186-
187-
?: ( << what you age >>) I am ^compute(%year – 1989) years old.
189+
```
190+
?: ( << what you age >>) I am ^compute(%year – 1989) years old.
191+
```
188192

189193
* Rule output is discarded if code fails in a rule
190194

@@ -207,28 +211,29 @@ a: (no) Pets are fun. You should try having one.
207211

208212
* Generally done on the current sentence
209213
* Tokens are instructions to process, left to right.
210-
211-
#! what is my name
212-
?: ( what is my name) - simple pattern
214+
```
215+
#! what is my name
216+
?: ( what is my name) - simple pattern
217+
```
213218

214219
* # grab indicated letter if we have a phone number
215-
216-
u: LETTERS($$phone @_10+ _*1 ) - esoteric pattern
217-
220+
```
221+
u: LETTERS($$phone @_10+ _*1 ) - esoteric pattern
222+
```
218223
---
219224

220225
# Simple Pattern Match
221226

222227
* Match words in sentence
223-
224-
u: (I love pizza)
225-
228+
```
229+
u: (I love pizza)
230+
```
226231
match: _I love pizza_, _I will love pizza_
227232

228233
* Pattern words cased as they should be
229-
230-
u: ( I love pizza from Pizza Hut)
231-
234+
```
235+
u: ( I love pizza from Pizza Hut)
236+
```
232237
match: _i love pizza from pizza hut_, _I LOVE PIZZA FROM PIZZA HUT_, _i LOVE pizza From pizza Hut_
233238

234239
---
@@ -240,9 +245,9 @@ match: _i love pizza from pizza hut_, _I LOVE PIZZA FROM PIZZA HUT_, _i LOVE piz
240245
- eliminate case – all upper case (losing useful data)
241246
- eliminate punctuation (losing useful data)
242247
- adding wildcard * to match 1 or more words
243-
244-
I * LOVE * YOU
245-
248+
```
249+
I * LOVE * YOU
250+
```
246251
---
247252

248253
# AIML Problem
@@ -271,53 +276,57 @@ match: _i love pizza from pizza hut_, _I LOVE PIZZA FROM PIZZA HUT_, _i LOVE piz
271276
- numbers: _two_ -> _2_ _2.0_ -> _2_ _two thousand and fifty_ -> _2050_
272277
- determiners: _the_ -> _a_
273278
- personal pronouns: _my_ -> _I him_ -> _he whom_ -> _who_
274-
275-
u: (I love pizza)
276-
279+
```
280+
u: (I love pizza)
281+
```
277282
matches: _I loved pizza_, _me loves pizzas_
278283

279284
---
280285

281286
# Patterns - Canonical forms
282287

283288
* Can require original form only using `'`
284-
285-
u: ( 'I 'love 'pizza)
289+
```
290+
u: ( 'I 'love 'pizza)
291+
```
286292

287293
* Can require original form if not canonical
288-
289-
u: ( I loved pizzas)
290-
294+
```
295+
u: ( I loved pizzas)
296+
```
291297
matches: _me love pizza_, _me loved pizzas_
292298

293299
---
294300

295301
# Patterns – bags of words
296302

297303
* `[` `]` - find one
298-
299-
u: ( I love [ pizza bacon sausage hamburger])
304+
```
305+
u: ( I love [ pizza bacon sausage hamburger])
306+
```
300307

301308
* `{` `}` - maybe find one
302-
303-
u: ( I love {the my} moon )
309+
```
310+
u: ( I love {the my} moon )
311+
```
304312

305313
* `<<` `>>` - find all in any order anywhere
306-
307-
u: ( << pizza I love >> )
308314

315+
```
316+
u: ( << pizza I love >> )
317+
```
309318
Particularly important. Breaks the straight-jacket of sequence.
310319

311320
---
312321

313322
# Patterns – composed bags
314-
315-
u: ( << I [like love adore] [pizza bacon] >>) So do I.
316-
323+
```
324+
u: ( << I [like love adore] [pizza bacon] >>) So do I.
325+
```
317326
matches: _I love bacon_, <br>_Pizza is what I adore_, _I hate pizza but love rocks_
318-
319-
u: ( I love [ meat << flesh animal >> ] ) So do I.
320-
327+
```
328+
u: ( I love [ meat << flesh animal >> ] ) So do I.
329+
```
321330
matches: _I love meat_, _I love animal flesh_, _I love the flesh of an animal_
322331

323332
---
@@ -328,20 +337,23 @@ matches: _I love meat_, _I love animal flesh_, _I love the flesh of an animal_
328337

329338
* `*` - any number of words (including 0)
330339

331-
u: ( I love * pizza) - matches "I love spicy pepperoni pizza"
332-
340+
```
341+
u: ( I love * pizza) - matches "I love spicy pepperoni pizza"
342+
```
333343
but matches _I love you and hate pizza_ – still a flaw with AIML
334344

335345
* `*1` - 1 word exactly `*2`, `*3` ..
336346

337-
u: ( I love *1 pizza)
338-
347+
```
348+
u: ( I love *1 pizza)
349+
```
339350
matches _I love pepperoni pizza_
340351

341352
* `*~1` - 0 or 1 word `*~2`, `*~3` ..
342353

343-
u: ( I *~2 love *~2 pizza) ?? examples?
344-
354+
```
355+
u: ( I *~2 love *~2 pizza) ?? examples?
356+
```
345357
But _I do not love pizza_ is a problem.
346358

347359
---
@@ -359,20 +371,20 @@ But _I do not love pizza_ is a problem.
359371
# Patterns- Phrases
360372

361373
* Phrase = sequence of 1-5 words in `"` `"`
362-
363-
u: ( I * work * "International Business Machines")
364-
374+
```
375+
u: ( I * work * "International Business Machines")
376+
```
365377
How is this different from
366-
367-
u: (I * work * International Business Machines )
368-
378+
```
379+
u: (I * work * International Business Machines )
380+
```
369381
The phrase is a single idea, an entity. Your pattern should
370382
reflect that. Humans will understand your pattern better. And CS
371383
will handle it correctly against a range of tokenization options.
372384
Particularly if it involves periods and commas
373-
374-
u: (I * live * “Raleigh, North Carolina”)
375-
385+
```
386+
u: (I * live * “Raleigh, North Carolina”)
387+
```
376388
---
377389

378390
# Patterns - Concepts
@@ -410,22 +422,28 @@ _I like pizza_ -> `_0` is null, _I like pepperoni pizza_ -> `_0` is pepperoni
410422
# Patterns - comparisons
411423

412424
* Can test relationships `>` `<` `==` `!=`
425+
```
426+
u: ( _~number _0==3) # relatively pointless since u: (3) is equivalent
427+
u: ( _~number _0>0 _0<10)
428+
```
413429

414-
u: ( _~number _0==3) # relatively pointless since u: (3) is equivalent
415-
u: ( _~number _0>0 _0<10)
416-
417430
* Can test concept membership `?` `!?`
418431

419-
u: ( _~animals _0?~pets)
432+
```
433+
u: ( _~animals _0?~pets)
434+
```
420435

421436
* Can test bit patterns `&` `^`
422437

423-
u: (_~number _0&1)
438+
```
439+
u: (_~number _0&1)
440+
```
424441

425442
* Can test existence (not null)
426443

427-
u: ( I love _{pepperoni} pizza _0) – but a pointless pattern here
428-
444+
```
445+
u: ( I love _{pepperoni} pizza _0) – but a pointless pattern here
446+
```
429447
---
430448

431449
# Patterns - tag-along patterns
@@ -449,18 +467,22 @@ Be aware:
449467
* You can jump around in the sentence.
450468
* You can match partial spellings of words.
451469

452-
u: ( my sign is Sagitt* )
470+
```
471+
u: ( my sign is Sagitt* )
472+
```
453473

454474
* You can hide or add concept meanings
455475

456-
u: ( _coffee ~nutrient) ^unmark(~color _0)
457-
476+
```
477+
u: ( _coffee ~nutrient) ^unmark(~color _0)
478+
```
458479
_I like coffee ice cream_ –> coffee is not a color
459480

460481
* Force alignment to start or end of sentence
461482

462-
u: ( < ice is nice > ) ice is 1 st word of sentence, nice is last word
463-
483+
```
484+
u: ( < ice is nice > ) ice is 1 st word of sentence, nice is last word
485+
```
464486
---
465487

466488
# Agenda - Topics, Output, Data, Functions
@@ -558,16 +580,18 @@ _ pizza "My favorite pizza is pepperoni because I like pizza with mea
558580

559581
* Classic functions with arguments start with `^`
560582

561-
$$tmp = ^pick(~animals)
583+
```
584+
$$tmp = ^pick(~animals)
585+
```
562586

563587
* Call by reference
564588
* Variety of predefined functions
565589
* Can define user functions for patterns or output
566590
* Most useful are:
567-
568-
^gambit(~topic), ^respond(~topic)
569-
^refine(), ^reuse(label)
570-
591+
```
592+
^gambit(~topic), ^respond(~topic)
593+
^refine(), ^reuse(label)
594+
```
571595
---
572596

573597
# Functions vs Rules vs Topics
@@ -770,9 +794,10 @@ ChatScript manages 2 channels of data
770794
* Input and output with the application
771795

772796
* Application data (OOB) in `[``]` first.
773-
774-
[category: vet specialty: cat] Hi, I'm Rosa.
775-
[callback: 600] My name is Pearl.
797+
```
798+
[category: vet specialty: cat] Hi, I'm Rosa.
799+
[callback: 600] My name is Pearl.
800+
```
776801

777802
* Application responsible for handling `[``]` in output
778803
* Script responsible for handling `[``]` in input

0 commit comments

Comments
 (0)