tpmkms 9.5.1-beta.10 → 9.5.1-beta.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,8 +16,6 @@ const dialogues_tests = require('./dialogues.test.json')
16
16
  const { defaultObjectCheck, defaultContextCheck, indent, focus } = require('./helpers')
17
17
  const pluralize = require('pluralize')
18
18
 
19
- const api = new API()
20
-
21
19
  function warningIsANotImplemented(log, context) {
22
20
  const description = 'WARNING from Dialogues KM: For semantics in order to handle sentences of type "x is y?", set the response to what you like.'
23
21
  const match = `({context, hierarchy}) => hierarchy.isA(context.marker, 'is') && context.query && <other conditions as you like>`
@@ -56,38 +54,23 @@ const config = {
56
54
 
57
55
  "(([queryable]) [is|] ([queryable|]))",
58
56
  "([isQuery|] ([queryable]) ([queryable]))",
59
- // "(([queryable]) [is:isEdBridge|is,are] ([isEdAble|]))",
60
57
  // who is the car owned by
61
58
  "(([queryable]) [(<isEd|> ([isEdAble|]))])",
62
59
 
63
- /* TODO investigate this:
64
- {"pattern":"(([ownee])^ <owned|owned> ([by] ([owner])?))","uuid":"people1"}
65
- {"pattern":"(([isEdee])^ <isEdAble|> ([by] ([isEder])?))","uuid":"dialogues2"}
66
- */
67
60
  "(([isEdee])^ <isEdAble|> ([by] ([isEder])?))",
68
61
  "([isEdee|])",
69
62
  "([isEder|])",
70
63
 
71
- // "([nevermind])",
72
- // { pattern: "([nevermindTestSetup] (allowed))", scope: "testing" },
73
64
  "([why])",
74
65
  "([reason])",
75
- // "([thisitthat|])",
76
- // "([it])",
77
- // "([this])",
78
- // "([that])",
79
66
 
80
67
  "(<what> ([whatAble|]))",
81
68
  "([what:optional])",
82
- // "(<the|> ([theAble|]))",
83
- // "(<a|a,an> ([theAble|]))",
84
- // "([unknown])",
85
69
 
86
70
  "([be] ([briefOrWordy|]))",
87
71
 
88
72
  "([([canBeQuestion])])",
89
73
  "(([canBeQuestion/1,2]) <questionMark|>)",
90
- // "(([is/2]) <questionMark|>)",
91
74
 
92
75
  "(([what]) [(<does|> ([doesAble|]))])",
93
76
  "([canBeDoQuestion])",
@@ -101,46 +84,29 @@ const config = {
101
84
 
102
85
  "([to] ([toAble|]))",
103
86
  ],
104
- associations: {
105
- positive: [
106
- { context: [['unknown', 0], ['isEdAble', 0]], choose: 1 },
107
- { context: [['isQuery', 0], ['a', 0], ['unknown', 0], ['a', 0], ['unknown', 0]], choose: { index: 0, increment: true } },
108
-
109
- { context: [["unknown",0],["isEd",0],["isEdAble",0],["by",0],["unknown",0]], choose: { index: 0, increment: true } },
110
- { context: [["unknown",0],["isEd",0],["isEdAble",0],["by",1]], choose: { index: 0, increment: true } },
111
- { context: [["unknown",0],["isEd",0],["isEdAble",0]], choose: { index: 0, increment: true } },
112
-
113
-
114
- // ...listorama('unknown'),
115
- // ...listorama('queryable'),
116
- { context: [['unknown', 0], ['list', 0], ['unknown', 0]], choose: 0 },
117
- { context: [['unknown', 0], ['list', 0], ['unknown', 1]], choose: 0 },
118
- { context: [['unknown', 1], ['list', 0], ['unknown', 0]], choose: 0 },
119
- { context: [['unknown', 1], ['list', 0], ['unknown', 1]], choose: 0 },
120
-
121
- { context: [['queryable', 0], ['list', 0], ['unknown', 0]], choose: 1 },
122
- { context: [['queryable', 0], ['list', 0], ['unknown', 1]], choose: 1 },
123
- { context: [['queryable', 1], ['list', 0], ['unknown', 0]], choose: 1 },
124
- { context: [['queryable', 1], ['list', 0], ['unknown', 1]], choose: 1 },
125
-
126
- { context: [['unknown', 0], ['list', 0], ['queryable', 0]], choose: 2 },
127
- { context: [['unknown', 0], ['list', 0], ['queryable', 1]], choose: 2 },
128
- { context: [['unknown', 1], ['list', 0], ['queryable', 0]], choose: 2 },
129
- { context: [['unknown', 1], ['list', 0], ['queryable', 1]], choose: 2 },
130
-
131
- { context: [['queryable', 0], ['list', 0], ['queryable', 0]], choose: 0 },
132
- { context: [['queryable', 0], ['list', 0], ['queryable', 1]], choose: 0 },
133
- { context: [['queryable', 1], ['list', 0], ['queryable', 0]], choose: 0 },
134
- { context: [['queryable', 1], ['list', 0], ['queryable', 1]], choose: 0 },
135
- ]
136
- },
137
87
  bridges: [
138
88
  {
139
89
  id: 'thatVerb',
140
90
  before: ['verb'],
141
- // bridge: "{ ...after[0], verb: after[0], that: operator, generate: ['that', 'verb'], localPriorities: { before: [\"verb\"] }, bridge_override: { operator: after[0].marker, bridge: '{ ...bridge.subject, postModifiers: [\"conditions\"], generate: append(before[0].generate, concatm(\"thatClause.\", operator.generate)), thatClause: bridge, conditions: append(after[0].conditions, [bridge]) }' } }",
142
- // bridge: "{ ...after[0], verb: after[0], that: operator, generate: ['that', 'verb'], localPriorities: { before: [\"verb\"] }, bridge_override: { operator: after[0].marker, bridge: '{ ...bridge.subject, postModifiers: [\"conditions\"], generate: concatm(\"thatClause.\", bridge.generate), thatClause: bridge, conditions: append(bridge.subject.conditions, [bridge]) }' } }",
143
- bridge: "{ ...after[0], verb: after[0], that: operator, generate: ['that', 'verb'], localPriorities: { actLike: [\"subordinatedVerb\", 0] }, bridge_override: { operator: after[0].marker, bridge: '{ ...bridge.subject, postModifiers: [\"conditions\"], modifiers: [], generate: concatm(\"thatClause.\", bridge.generate), thatClause: bridge, conditions: append(bridge.subject.conditions, [bridge]) }' } }",
91
+ bridge: `
92
+ {
93
+ ...after[0],
94
+ verb: after[0],
95
+ that: operator,
96
+ generate: ['that', 'verb'],
97
+ localPriorities: { actLike: ["subordinatedVerb", 0] },
98
+ bridge_override: {
99
+ operator: after[0].marker,
100
+ bridge: '{
101
+ ...bridge.subject,
102
+ postModifiers: ["conditions"],
103
+ modifiers: [],
104
+ generate: concatm("thatClause.", bridge.generate),
105
+ thatClause: bridge,
106
+ conditions: append(bridge.subject.conditions, [bridge])
107
+ }'
108
+ }
109
+ }`,
144
110
  },
145
111
 
146
112
  {
@@ -203,7 +169,16 @@ const config = {
203
169
  },
204
170
  { id: "toAble" },
205
171
 
206
- { id: "be", level: 0, bridge: "{ ...next(operator), type: after[0] }" },
172
+ {
173
+ id: "be",
174
+ level: 0,
175
+ bridge: `{
176
+ ...next(operator),
177
+ form: 'infinitive',
178
+ type: after[0]
179
+ }`
180
+ },
181
+
207
182
  { id: "briefOrWordy" },
208
183
 
209
184
  { id: "yesno" },
@@ -245,40 +220,7 @@ const config = {
245
220
  { id: "canBeDoQuestion", level: 2, bridge: "{ ...next(operator) }" },
246
221
  { id: "doesAble", level: 0, bridge: "{ ...next(operator) }" },
247
222
  { id: "doesAble", level: 1, bridge: "{ ...next(operator), before: before[0] }" },
248
- // { id: "does", level: 0, bridge: "{ query: true, wantsTruthValue: true, what: operator.marker, ...context, number: operator.number, object.number: operator.number }*" },
249
223
  { id: "does", level: 0, bridge: "{ query: true, what: operator.marker, ...context, number: operator.number, object.number: operator.number }*" },
250
-
251
- /*
252
- {
253
- id: 'the',
254
- level: 0,
255
- bridge: '{ ...after[0], focusableForPhrase: true, pullFromContext: true, concept: true, wantsValue: true, determiner: "the", modifiers: append(["determiner"], after[0].modifiers)}'
256
- },
257
- {
258
- id: "a",
259
- level: 0,
260
- // bridge: "{ ...after[0], pullFromContext: false, instance: true, concept: true, number: 'one', wantsValue: true, determiner: operator, modifiers: append(['determiner'], after[0].modifiers) }"
261
- bridge: "{ ...after[0], pullFromContext: false, concept: true, number: 'one', wantsValue: true, determiner: operator, modifiers: append(['determiner'], after[0].modifiers) }"
262
- },
263
- */
264
- /*
265
- {
266
- id: "theAble",
267
- children: ['noun'],
268
- bridge: "{ ...next(operator) }"
269
- },
270
- */
271
-
272
- // TODO make this hierarchy thing work
273
- /*
274
- {
275
- id: "thisitthat",
276
- level: 0,
277
- isA: ['queryable'],
278
- before: ['verby'],
279
- bridge: "{ ...next(operator) }"
280
- },
281
- */
282
224
  {
283
225
  id: "why",
284
226
  level: 0,
@@ -288,31 +230,10 @@ const config = {
288
230
  id: "reason",
289
231
  isA: ['theAble', 'queryable'],
290
232
  },
291
- /*
292
- {
293
- id: "it",
294
- level: 0,
295
- isA: ['thisitthat'],
296
- bridge: "{ ...next(operator), pullFromContext: true, unknown: true, determined: true }"
297
- },
298
- {
299
- id: "this",
300
- level: 0,
301
- isA: ['thisitthat'],
302
- bridge: "{ ...next(operator), unknown: true, pullFromContext: true }"
303
- },
304
- {
305
- id: "that",
306
- level: 0,
307
- isA: ['thisitthat'],
308
- bridge: "{ ...next(operator), unknown: true, pullFromContext: true }"
309
- },
310
- */
311
233
  ],
312
234
  words: {
313
235
  "literals": {
314
236
  "?": [{"id": "questionMark", "initial": "{}" }],
315
- // "the": [{"id": "the", "initial": "{ modifiers: [] }" }],
316
237
  "who": [{"id": "what", "initial": "{ modifiers: [], query: true }" }],
317
238
  "yes": [{"id": "yesno", "initial": "{ value: true }" }],
318
239
  "no": [{"id": "yesno", "initial": "{ value: false }" }],
@@ -321,6 +242,7 @@ const config = {
321
242
  "does": [{"id": "does", "initial": "{ number: 'one' }" }],
322
243
  "do": [{"id": "does", "initial": "{ number: 'many' }" }],
323
244
  "is": [
245
+ {"id": "be", "initial": "{ form: 'infinitive' }" },
324
246
  {"id": "is", "initial": "{ number: 'one' }" },
325
247
  {"id": "isQuery", "initial": "{ number: 'one' }" },
326
248
  {"id": "isEd", "initial": "{ number: 'one' }" }
@@ -348,12 +270,9 @@ const config = {
348
270
  ['it', 'pronoun'],
349
271
  ['this', 'pronoun'],
350
272
  ['questionMark', 'punctuation'],
351
- // ['questionMark', 'isEd'],
352
273
  ['a', 'article'],
353
274
  ['the', 'article'],
354
- // ['unknown', 'theAble'],
355
275
  ['theAble', 'queryable'],
356
- // ['unknown', 'queryable'],
357
276
  ['it', 'queryable'],
358
277
  ['what', 'queryable'],
359
278
  ['whatAble', 'queryable'],
@@ -557,7 +476,7 @@ const config = {
557
476
  } else {
558
477
  // TODO fix this using the assumed and that whole mess. change isResponse to useValue
559
478
  if (context.isResponse) {
560
- return `${await gp(context.one, { responding: true })} ${isMany(context.one) || isMany(context.two) || isMany(context) ? "are" : "is"} ${await g(context.two)}`
479
+ return `${await gp(context.one, { assumed: { responding: true } })} ${isMany(context.one) || isMany(context.two) || isMany(context) ? "are" : "is"} ${await g(context.two)}`
561
480
  } else {
562
481
  return `${await gp(context.one)} ${isMany(context.one) || isMany(context.two) || isMany(context) ? "are" : "is"} ${await gr(context.two)}`
563
482
  }
@@ -1,6 +1,9 @@
1
1
  {
2
2
  "configs": [
3
3
  "dimension and unit are concepts",
4
+ {
5
+ "apply": "({apis}) => {\n apis('properties').addHierarchyWatcher({\n match: ({parentId}) => parentId == 'unit',\n apply: ({config, childId, parent}) => {\n config.updateBridge(childId, ({ bridge }) => {\n // console.log(JSON.stringify(childId, null, 2))\n // console.log(JSON.stringify(parentId, null, 2))\n // debugger\n // if (!bridge) {\n // debugger\n // return\n // }\n if (!bridge.init) {\n bridge.init = {}\n }\n // bridge.init['dimension'] = parent.object.marker\n bridge.init['dimension'] = parent.object.value\n })\n }\n })\n }"
6
+ },
4
7
  {
5
8
  "name": "dimension",
6
9
  "operators": [
@@ -47,10 +50,9 @@
47
50
  ],
48
51
  "bridges": [
49
52
  {
50
- "where": "/home/dev/code/theprogrammablemind/kms/common/dimension.js:84",
53
+ "where": "/home/dev/code/theprogrammablemind/kms/common/dimension.js:82",
51
54
  "id": "dimension",
52
55
  "bridge": "{ ...next(operator) }",
53
- "isA": [],
54
56
  "generatorpr": {}
55
57
  },
56
58
  {
@@ -65,7 +67,7 @@
65
67
  "id": "amount"
66
68
  },
67
69
  {
68
- "where": "/home/dev/code/theprogrammablemind/kms/common/dimension.js:110",
70
+ "where": "/home/dev/code/theprogrammablemind/kms/common/dimension.js:107",
69
71
  "id": "degree",
70
72
  "words": [
71
73
  {
@@ -82,10 +84,10 @@
82
84
  {
83
85
  "id": "amountOfDimension",
84
86
  "convolution": true,
85
- "bridge": "{ marker: operator('dimension'), unit: after[0], value: before[0].value, amount: before[0] }"
87
+ "bridge": "{ marker: next(catch(operator(after[0].dimension), operator('dimension'))), dead: true, unit: after[0], value: before[0].value, amount: before[0] }"
86
88
  },
87
89
  {
88
- "where": "/home/dev/code/theprogrammablemind/kms/common/dimension.js:123",
90
+ "where": "/home/dev/code/theprogrammablemind/kms/common/dimension.js:121",
89
91
  "id": "convertToUnits",
90
92
  "bridge": "{ ...next(operator), from: before[0], to: after[0] }",
91
93
  "isA": [
@@ -1546,6 +1548,9 @@
1546
1548
  "query": "dimension and unit are concepts"
1547
1549
  }
1548
1550
  },
1551
+ {
1552
+ "apply": "({apis}) => {\n apis('properties').addHierarchyWatcher({\n match: ({parentId}) => parentId == 'unit',\n apply: ({config, childId, parent}) => {\n config.updateBridge(childId, ({ bridge }) => {\n // console.log(JSON.stringify(childId, null, 2))\n // console.log(JSON.stringify(parentId, null, 2))\n // debugger\n // if (!bridge) {\n // debugger\n // return\n // }\n if (!bridge.init) {\n bridge.init = {}\n }\n // bridge.init['dimension'] = parent.object.marker\n bridge.init['dimension'] = parent.object.value\n })\n }\n })\n }"
1553
+ },
1549
1554
  {
1550
1555
  "extraConfig": true,
1551
1556
  "name": "dimension",
@@ -1587,15 +1592,14 @@
1587
1592
  ],
1588
1593
  "generators": [
1589
1594
  {
1590
- "where": "/home/dev/code/theprogrammablemind/kms/common/dimension.js:77"
1595
+ "where": "/home/dev/code/theprogrammablemind/kms/common/dimension.js:75"
1591
1596
  }
1592
1597
  ],
1593
1598
  "bridges": [
1594
1599
  {
1595
- "where": "/home/dev/code/theprogrammablemind/kms/common/dimension.js:84",
1600
+ "where": "/home/dev/code/theprogrammablemind/kms/common/dimension.js:82",
1596
1601
  "id": "dimension",
1597
1602
  "bridge": "{ ...next(operator) }",
1598
- "isA": [],
1599
1603
  "generatorpr": {}
1600
1604
  },
1601
1605
  {
@@ -1610,7 +1614,7 @@
1610
1614
  "id": "amount"
1611
1615
  },
1612
1616
  {
1613
- "where": "/home/dev/code/theprogrammablemind/kms/common/dimension.js:110",
1617
+ "where": "/home/dev/code/theprogrammablemind/kms/common/dimension.js:107",
1614
1618
  "id": "degree",
1615
1619
  "words": [
1616
1620
  {
@@ -1626,10 +1630,10 @@
1626
1630
  {
1627
1631
  "id": "amountOfDimension",
1628
1632
  "convolution": true,
1629
- "bridge": "{ marker: operator('dimension'), unit: after[0], value: before[0].value, amount: before[0] }"
1633
+ "bridge": "{ marker: next(catch(operator(after[0].dimension), operator('dimension'))), dead: true, unit: after[0], value: before[0].value, amount: before[0] }"
1630
1634
  },
1631
1635
  {
1632
- "where": "/home/dev/code/theprogrammablemind/kms/common/dimension.js:123",
1636
+ "where": "/home/dev/code/theprogrammablemind/kms/common/dimension.js:121",
1633
1637
  "id": "convertToUnits",
1634
1638
  "bridge": "{ ...next(operator), from: before[0], to: after[0] }",
1635
1639
  "isA": [
@@ -50,8 +50,6 @@ class API {
50
50
  }
51
51
  }
52
52
 
53
- const api = new API()
54
-
55
53
  const config = {
56
54
  name: 'dimension',
57
55
  operators: [
@@ -84,7 +82,6 @@ const config = {
84
82
  where: where(),
85
83
  id: "dimension",
86
84
  bridge: "{ ...next(operator) }",
87
- isA: [],
88
85
  generatorpr: {
89
86
  match: ({context}) => context.amount,
90
87
  apply: async ({context, gp, gr}) => `${await gr(context.amount)} ${await gp(context.unit)}`,
@@ -117,7 +114,8 @@ const config = {
117
114
  {
118
115
  id: "amountOfDimension",
119
116
  convolution: true,
120
- bridge: "{ marker: operator('dimension'), unit: after[0], value: before[0].value, amount: before[0] }"
117
+ bridge: "{ marker: next(catch(operator(after[0].dimension), operator('dimension'))), dead: true, unit: after[0], value: before[0].value, amount: before[0] }"
118
+ // bridge: "{ marker: operator('dimension'), unit: after[0], value: before[0].value, amount: before[0] }"
121
119
  },
122
120
  {
123
121
  where: where(),
@@ -180,6 +178,27 @@ const config = {
180
178
  const template = {
181
179
  configs: [
182
180
  "dimension and unit are concepts",
181
+ ({apis}) => {
182
+ apis('properties').addHierarchyWatcher({
183
+ match: ({parentId}) => parentId == 'unit',
184
+ apply: ({config, childId, parent}) => {
185
+ config.updateBridge(childId, ({ bridge }) => {
186
+ // console.log(JSON.stringify(childId, null, 2))
187
+ // console.log(JSON.stringify(parentId, null, 2))
188
+ // debugger
189
+ // if (!bridge) {
190
+ // debugger
191
+ // return
192
+ // }
193
+ if (!bridge.init) {
194
+ bridge.init = {}
195
+ }
196
+ // bridge.init['dimension'] = parent.object.marker
197
+ bridge.init['dimension'] = parent.object.value
198
+ })
199
+ }
200
+ })
201
+ },
183
202
  config,
184
203
  ],
185
204
  }