-
Notifications
You must be signed in to change notification settings - Fork 159
Expand file tree
/
Copy pathsimplecontrol.top
More file actions
91 lines (75 loc) · 2.59 KB
/
Copy pathsimplecontrol.top
File metadata and controls
91 lines (75 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# this function is executed once for every new user chatting with harry
outputmacro: stockpile() # you get stockpile by default
$cs_token = #DO_INTERJECTION_SPLITTING | #DO_SUBSTITUTE_SYSTEM | #DO_NUMBER_MERGE | #DO_DATE_MERGE | #DO_PROPERNAME_MERGE | #DO_SPELLCHECK | #DO_PARSE
$cs_token = 0
^addtopic(~introductions)
$cs_control_main = ~control
$userprompt = ^"%user: >"
$botprompt = ^"STOCKPILE: "
table: defaultbot (^name)
^createfact(^name defaultbot defaultbot)
DATA:
stockpile
topic: ~control system ()
# on startup, do introduction
u: ( %input<%userfirstline)
gambit(~introductions)
u: () # main per-sentence processing
$$currenttopic = %topic # get the current topic at start of volley
if ( %response == 0 ) {nofail(TOPIC ^rejoinder())} # try for rejoinders. might generate an answer directly from what we are looking for.
if (%length == 0 AND %response == 0 )
{
nofail(TOPIC ^gambit($$currenttopic)) # gambit current topic since no input (usually start of conversation)
}
if (%response == 0) { nofail(TOPIC ^respond($$currenttopic)) } # current topic tries to respond to his input
if (%response == 0) # see if some other topic has keywords matching his input (given we have no response yet)
{
@8 = ^keywordtopics() # get topics referred in input
loop()
{
$$topic = first(@8subject)
nofail(TOPIC ^respond($$topic))
if (%response != 0) # stop when we find something to say
{
^end(RULE) # we are done, this terminates the loop (not the rule)
}
}
}
# if we have rejoinders for what we said OR we asked a question, stop here
if (%outputrejoinder OR %lastquestion)
{
end(TOPIC)
}
if (%response == 0 AND ^marked($$currenttopic)) { nofail(TOPIC ^gambit($$currenttopic)) } # gambit current topic since keywords match current topic
if (%response == 0) # gambit from ANY matching topic
{
@8 = ^keywordtopics() # get topics referred in input
loop()
{
$$topic = first(@8subject)
nofail(TOPIC ^Gambit($$topic)) # gambit in best matching topic
if (%response != 0) # stop when we find something
{
^end(RULE)
}
}
}
if (%response == 0){ nofail(TOPIC ^gambit($$currenttopic)) } # gambit from current topic even though no keywords matched
if (%response == 0)
{
@8 = ^GambitTopics() # all topics with gambits (excluding system topics)
loop()
{
$$topic = pick(@8subject)
nofail(TOPIC ^Gambit($$topic)) # try a topic at random
if (%response != 0)
{
^end(RULE)
}
}
}
if (%response == 0)
{
^repeat()
I don't know what to say.
}