tpmkms 8.3.0 → 8.4.0-beta.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,65 @@
1
+ const { knowledgeModule, where, Digraph } = require('./runtime').theprogrammablemind
2
+ const { defaultContextCheck } = require('./helpers')
3
+ const gdefaults = require("./gdefaults")
4
+ const tests = require('./errors.test.json')
5
+
6
+ let config = {
7
+ name: 'errors',
8
+ operators: [
9
+ { pattern: "([drop] ([dropable]))", development: true },
10
+ ],
11
+ bridges: [
12
+ {
13
+ id: "drop",
14
+ bridge: "{ ...next(operator), arg: after[0] }",
15
+ development: true
16
+ },
17
+ { id: "dropable", development: true },
18
+ ],
19
+ semantics: [
20
+ {
21
+ match: ({context}) => context.interpretation_error,
22
+ apply: async ({context, g, gp, verbatim, contexts}) => {
23
+ const argument = contexts.find( (argument) => argument.argument_id == context.interpretation_error.argument_id )
24
+ verbatim(`Did not know how to understand "${await gp(argument)}" when applying "${await g(context)}"`)
25
+ }
26
+ },
27
+ {
28
+ match: ({context}) => context.context?.interpretation_error,
29
+ apply: async ({context, g, gp, verbatim, contexts}) => {
30
+ context = context.context
31
+ const argument = contexts.find( (argument) => argument.argument_id == context.interpretation_error.argument_id )
32
+ verbatim(`Did not know how to understand "${await gp(argument)}" when applying "${await g(context)}"`)
33
+ }
34
+ },
35
+ ],
36
+ };
37
+
38
+ knowledgeModule({
39
+ config,
40
+ includes: [gdefaults],
41
+
42
+ module,
43
+ description: 'handling of surfaceable errors',
44
+ test: {
45
+ name: './errors.test.json',
46
+ contents: tests,
47
+ /*
48
+ checks: {
49
+ context: [
50
+ ...defaultContextCheck(),
51
+ {
52
+ property: 'quantity',
53
+ filter: ['marker', 'value'],
54
+ },
55
+ {
56
+ property: 'pieces',
57
+ filter: [
58
+ 'marker', 'text',
59
+ { property: 'count', filter: ['marker', 'value'] },
60
+ ]
61
+ }]
62
+ },
63
+ */
64
+ },
65
+ })
@@ -0,0 +1,206 @@
1
+ [
2
+ {
3
+ "associations": [
4
+ ],
5
+ "config": {
6
+ },
7
+ "contexts": [
8
+ {
9
+ "dead": true,
10
+ "default": true,
11
+ "interpretation_error": {
12
+ "argument_id": 1,
13
+ "expected": [
14
+ [
15
+ "dropable",
16
+ "*"
17
+ ]
18
+ ]
19
+ },
20
+ "level": 0,
21
+ "marker": "drop",
22
+ "range": {
23
+ "end": 3,
24
+ "start": 0
25
+ },
26
+ "text": "drop",
27
+ "topLevel": true,
28
+ "touchedBy": [
29
+ "errors#call2"
30
+ ],
31
+ "value": "drop",
32
+ "word": "drop"
33
+ },
34
+ {
35
+ "isResponse": true,
36
+ "marker": "verbatim",
37
+ "topLevel": true,
38
+ "verbatim": "Did not know how to understand \"y\" when applying \"drop\""
39
+ },
40
+ {
41
+ "argument_id": 1,
42
+ "dead": true,
43
+ "level": 1,
44
+ "marker": "unknown",
45
+ "range": {
46
+ "end": 5,
47
+ "start": 5
48
+ },
49
+ "text": "y",
50
+ "topLevel": true,
51
+ "unknown": true,
52
+ "value": "y",
53
+ "word": "y"
54
+ }
55
+ ],
56
+ "generatedParenthesized": [
57
+ "",
58
+ "(Did not know how to understand \"y\" when applying \"drop\")",
59
+ ""
60
+ ],
61
+ "metadata": {
62
+ "opChoices": [
63
+ {
64
+ "counter": 1,
65
+ "op": [
66
+ "unknown",
67
+ 0
68
+ ],
69
+ "ops": [
70
+ [
71
+ "drop",
72
+ 0
73
+ ],
74
+ [
75
+ "unknown",
76
+ 0
77
+ ]
78
+ ]
79
+ },
80
+ {
81
+ "counter": 2,
82
+ "op": [
83
+ "drop",
84
+ 0
85
+ ],
86
+ "ops": [
87
+ [
88
+ "drop",
89
+ 0
90
+ ]
91
+ ]
92
+ }
93
+ ]
94
+ },
95
+ "objects": {
96
+ "nameToUUID": {
97
+ "errors": "errors1",
98
+ "gdefaults": "gdefaults2",
99
+ "tokenize": "tokenize2"
100
+ },
101
+ "namespaced": {
102
+ "errors1": {
103
+ },
104
+ "gdefaults2": {
105
+ },
106
+ "tokenize2": {
107
+ }
108
+ },
109
+ "processed": [
110
+ {
111
+ "context": {
112
+ "argument_id": 1,
113
+ "dead": true,
114
+ "level": 1,
115
+ "marker": "unknown",
116
+ "range": {
117
+ "end": 5,
118
+ "start": 5
119
+ },
120
+ "text": "y",
121
+ "topLevel": true,
122
+ "unknown": true,
123
+ "value": "y",
124
+ "word": "y"
125
+ },
126
+ "generatedParenthesized": "",
127
+ "paraphrases": "y",
128
+ "paraphrasesParenthesized": "(y)",
129
+ "responses": [
130
+ "",
131
+ "Did not know how to understand \"y\" when applying \"drop\"",
132
+ ""
133
+ ]
134
+ },
135
+ {
136
+ "context": {
137
+ "isResponse": true,
138
+ "marker": "verbatim",
139
+ "topLevel": true,
140
+ "verbatim": "Did not know how to understand \"y\" when applying \"drop\""
141
+ },
142
+ "generatedParenthesized": "(Did not know how to understand \"y\" when applying \"drop\")",
143
+ "paraphrases": "Did not know how to understand \"y\" when applying \"drop\"",
144
+ "paraphrasesParenthesized": "(Did not know how to understand \"y\" when applying \"drop\")",
145
+ "responses": [
146
+ "",
147
+ "Did not know how to understand \"y\" when applying \"drop\"",
148
+ ""
149
+ ]
150
+ },
151
+ {
152
+ "context": {
153
+ "dead": true,
154
+ "default": true,
155
+ "interpretation_error": {
156
+ "argument_id": 1,
157
+ "expected": [
158
+ [
159
+ "dropable",
160
+ "*"
161
+ ]
162
+ ]
163
+ },
164
+ "level": 0,
165
+ "marker": "drop",
166
+ "range": {
167
+ "end": 3,
168
+ "start": 0
169
+ },
170
+ "text": "drop",
171
+ "topLevel": true,
172
+ "touchedBy": [
173
+ "errors#call2"
174
+ ],
175
+ "value": "drop",
176
+ "word": "drop"
177
+ },
178
+ "generatedParenthesized": "",
179
+ "paraphrases": "drop",
180
+ "paraphrasesParenthesized": "(drop)",
181
+ "responses": [
182
+ "",
183
+ "Did not know how to understand \"y\" when applying \"drop\"",
184
+ ""
185
+ ]
186
+ }
187
+ ]
188
+ },
189
+ "paraphrases": [
190
+ "drop",
191
+ "Did not know how to understand \"y\" when applying \"drop\"",
192
+ "y"
193
+ ],
194
+ "paraphrasesParenthesized": [
195
+ "(drop)",
196
+ "(Did not know how to understand \"y\" when applying \"drop\")",
197
+ "(y)"
198
+ ],
199
+ "query": "drop y",
200
+ "responses": [
201
+ "",
202
+ "Did not know how to understand \"y\" when applying \"drop\"",
203
+ ""
204
+ ]
205
+ }
206
+ ]