tpmkms_4wp 9.4.5-beta.4 → 9.4.5-beta.6

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.
@@ -103,6 +103,7 @@ const template = {
103
103
  "go modifies wrap",
104
104
  "a go wrap is a sandwich",
105
105
  "chicken modifies go wrap",
106
+ // { stop: true },
106
107
  "breakfast baconator, french toast sandwich, egg muffin, chicken on french toast, pancake platter, double sausage muffin, pancakes, french toast and oatmeal are breakfast meals",
107
108
  "single, double, triple, baconator, bacon deluxe, spicy homestyle and premium cod are meals",
108
109
  "coca modifies cola",
@@ -248,16 +248,41 @@ const initializer = ({config}) => {
248
248
  return args.gp(context[key])
249
249
  }
250
250
  }
251
+ const getValue = (keyOrValue) => {
252
+ if (typeof keyOrValue == 'string' && context[keyOrValue]) {
253
+ return context[keyOrValue]
254
+ }
255
+ return keyOrValue // it's a value
256
+ }
257
+
251
258
  if (Array.isArray(interpolate)) {
252
259
  const strings = []
253
260
  let separator = ''
254
261
  for (const element of interpolate) {
255
262
  if (typeof element == 'string') {
256
263
  separator = element
264
+ } else if (element.separator && element.values) {
265
+ let ctr = 0
266
+ const values = getValue(element.values)
267
+ const vstrings = []
268
+ for (const value of values) {
269
+ if (ctr == values.length-1) {
270
+ vstrings.push(getValue(element.separator))
271
+ }
272
+ ctr += 1
273
+ vstrings.push(getValue(value))
274
+ }
275
+ strings.push(await args.gsp(vstrings))
257
276
  } else {
258
- strings.push(separator)
259
- strings.push(await args.gp(element))
260
- separator = ' '
277
+ let value = element
278
+ if (element.property) {
279
+ value = context[element.property]
280
+ }
281
+ if (value) {
282
+ strings.push(separator)
283
+ strings.push(await args.gp(value))
284
+ separator = ' '
285
+ }
261
286
  }
262
287
  }
263
288
  return strings.join('')
@@ -1,15 +1,162 @@
1
1
  {
2
2
  "configs": [
3
+ {
4
+ "apply": "({config}) => {\n config.addArgs(({config, api, isA}) => ({\n addLatinNoun: ({ id, nominative, genetive, development }) => {\n config.addOperator({ pattern: `([${id}|])`, development: development })\n config.addBridge({ id, isA: ['hierarchiable'] })\n const declensions = getDeclensions(nominative, genetive)\n for (const declension of declensions) {\n config.addWord(declension.word, { id, initial: { ...declension, development } })\n }\n }\n }))\n }"
5
+ },
6
+ {
7
+ "apply": "({addLatinNoun}) => {\n addLatinNoun({ id: 'davus_person', nominative: 'davus', development: true })\n addLatinNoun({ id: 'titus_person', nominative: 'titus', development: true })\n addLatinNoun({ id: 'pear_food', nominative: 'pirum', development: true })\n addLatinNoun({ id: 'table_latin', nominative: 'mensa', development: true })\n }"
8
+ },
3
9
  {
4
10
  "operators": [
5
11
  "((hierarchy/*) [queryMarker|ne])",
6
- "((listable/*) [listMarker|que])",
7
12
  "([hierarchiable])",
8
13
  "((hierarchiable) [hierarchy|] (hierarchiable))",
9
14
  "((hierarchiable) (hierarchiable) [hierarchy|])",
10
- "([hierarchy|] (hierarchiable) (hierarchiable))"
15
+ "([hierarchy|] (hierarchiable) (hierarchiable))",
16
+ "(x [list|et] y)",
17
+ "((listable/*) [listMarker|que])"
11
18
  ],
12
19
  "bridges": [
20
+ {
21
+ "id": "inLatin",
22
+ "words": [
23
+ "in"
24
+ ],
25
+ "before": [
26
+ "iacere"
27
+ ],
28
+ "bridge": "{ ...next(operator), declension: 'inLatin', object: object, operator: operator, interpolate: [{ property: 'operator' }, { property: 'object' }] }",
29
+ "selector": {
30
+ "ordinals": [
31
+ 1
32
+ ],
33
+ "arguments": {
34
+ "object": "(context.declension == 'accusative' || context.declension == 'ablative')"
35
+ }
36
+ }
37
+ },
38
+ {
39
+ "id": "iacere",
40
+ "level": 0,
41
+ "words": [
42
+ {
43
+ "word": "iacio",
44
+ "number": "singular",
45
+ "person": "first"
46
+ },
47
+ {
48
+ "word": "iacis",
49
+ "number": "singular",
50
+ "person": "second"
51
+ },
52
+ {
53
+ "word": "iacit",
54
+ "number": "singular",
55
+ "person": "third"
56
+ },
57
+ {
58
+ "word": "iacimus",
59
+ "number": "plural",
60
+ "person": "first"
61
+ },
62
+ {
63
+ "word": "iacitis",
64
+ "number": "plural",
65
+ "person": "second"
66
+ },
67
+ {
68
+ "word": "iaciunt",
69
+ "number": "plural",
70
+ "person": "third"
71
+ }
72
+ ],
73
+ "bridge": "{ ...next(operator), thrower: nominative?, receiver: dative?, object: object?, location: location?, interpolate: [{ property: 'thrower' }, { property: 'receiver' }, { property: 'location' }, { property: 'object' }, operator] }",
74
+ "selector": {
75
+ "arguments": {
76
+ "nominative": "(context.declension == 'nominative' && context.number == operator.number)",
77
+ "dative": "(context.declension == 'dative')",
78
+ "object": "(context.declension == 'accusative')",
79
+ "location": "(context.declension == 'inLatin')"
80
+ }
81
+ }
82
+ },
83
+ {
84
+ "id": "dare",
85
+ "level": 0,
86
+ "bridge": "{ ...next(operator), giver: nominative?, receiver: dative?, object: accusative?, interpolate: [{ property: 'giver' }, { property: 'receiver' }, { property: 'object' }, operator] }",
87
+ "selector": {
88
+ "arguments": {
89
+ "nominative": "(context.declension == 'nominative' && context.number == operator.number)",
90
+ "dative": "(context.declension == 'dative')",
91
+ "accusative": "(context.declension == 'accusative')"
92
+ }
93
+ },
94
+ "words": [
95
+ {
96
+ "word": "do",
97
+ "number": "singular",
98
+ "person": "first"
99
+ },
100
+ {
101
+ "word": "das",
102
+ "number": "singular",
103
+ "person": "second"
104
+ },
105
+ {
106
+ "word": "dat",
107
+ "number": "singular",
108
+ "person": "third"
109
+ },
110
+ {
111
+ "word": "damus",
112
+ "number": "plural",
113
+ "person": "first"
114
+ },
115
+ {
116
+ "word": "datis",
117
+ "number": "plural",
118
+ "person": "second"
119
+ },
120
+ {
121
+ "word": "dant",
122
+ "number": "plural",
123
+ "person": "third"
124
+ }
125
+ ]
126
+ },
127
+ {
128
+ "id": "list",
129
+ "level": 0,
130
+ "selector": {
131
+ "match": "same",
132
+ "left": [
133
+ {
134
+ "pattern": "($type && context.instance == variables.instance)"
135
+ }
136
+ ],
137
+ "right": [
138
+ {
139
+ "pattern": "($type && context.instance == variables.instance)"
140
+ }
141
+ ],
142
+ "passthrough": true
143
+ },
144
+ "bridge": "{ ...next(operator), listable: true, isList: true, value: append(before, after), operator: operator, interpolate: [ { separator: 'operator', values: 'value' } ] }"
145
+ },
146
+ {
147
+ "id": "list",
148
+ "level": 1,
149
+ "selector": {
150
+ "match": "same",
151
+ "left": [
152
+ {
153
+ "pattern": "($type && context.instance == variables.instance)"
154
+ }
155
+ ],
156
+ "passthrough": true
157
+ },
158
+ "bridge": "{ ...operator, value: append(before, operator.value) }"
159
+ },
13
160
  {
14
161
  "id": "queryMarker",
15
162
  "bridge": "{ ...before[0], verb: before[0], interpolate: [before[0], '', operator], question: true }",
@@ -26,7 +173,7 @@
26
173
  "listable"
27
174
  ]
28
175
  ],
29
- "bridge": "{ ...before[0], verb: before[0], interpolate: [before[0], '', operator], list: true }",
176
+ "bridge": "{ ...before[0], verb: before[0], interpolate: [before[0], '', operator], isList: true }",
30
177
  "separators": "|"
31
178
  },
32
179
  {
@@ -87,17 +234,164 @@
87
234
  }
88
235
  ],
89
236
  "resultss": [
237
+ {
238
+ "apply": "({config}) => {\n config.addArgs(({config, api, isA}) => ({\n addLatinNoun: ({ id, nominative, genetive, development }) => {\n config.addOperator({ pattern: `([${id}|])`, development: development })\n config.addBridge({ id, isA: ['hierarchiable'] })\n const declensions = getDeclensions(nominative, genetive)\n for (const declension of declensions) {\n config.addWord(declension.word, { id, initial: { ...declension, development } })\n }\n }\n }))\n }"
239
+ },
240
+ {
241
+ "apply": "({addLatinNoun}) => {\n addLatinNoun({ id: 'davus_person', nominative: 'davus', development: true })\n addLatinNoun({ id: 'titus_person', nominative: 'titus', development: true })\n addLatinNoun({ id: 'pear_food', nominative: 'pirum', development: true })\n addLatinNoun({ id: 'table_latin', nominative: 'mensa', development: true })\n }"
242
+ },
90
243
  {
91
244
  "extraConfig": true,
92
245
  "operators": [
93
246
  "((hierarchy/*) [queryMarker|ne])",
94
- "((listable/*) [listMarker|que])",
95
247
  "([hierarchiable])",
96
248
  "((hierarchiable) [hierarchy|] (hierarchiable))",
97
249
  "((hierarchiable) (hierarchiable) [hierarchy|])",
98
- "([hierarchy|] (hierarchiable) (hierarchiable))"
250
+ "([hierarchy|] (hierarchiable) (hierarchiable))",
251
+ "(x [list|et] y)",
252
+ "((listable/*) [listMarker|que])"
99
253
  ],
100
254
  "bridges": [
255
+ {
256
+ "id": "inLatin",
257
+ "words": [
258
+ "in"
259
+ ],
260
+ "before": [
261
+ "iacere"
262
+ ],
263
+ "bridge": "{ ...next(operator), declension: 'inLatin', object: object, operator: operator, interpolate: [{ property: 'operator' }, { property: 'object' }] }",
264
+ "selector": {
265
+ "ordinals": [
266
+ 1
267
+ ],
268
+ "arguments": {
269
+ "object": "(context.declension == 'accusative' || context.declension == 'ablative')"
270
+ }
271
+ }
272
+ },
273
+ {
274
+ "id": "iacere",
275
+ "level": 0,
276
+ "words": [
277
+ {
278
+ "word": "iacio",
279
+ "number": "singular",
280
+ "person": "first"
281
+ },
282
+ {
283
+ "word": "iacis",
284
+ "number": "singular",
285
+ "person": "second"
286
+ },
287
+ {
288
+ "word": "iacit",
289
+ "number": "singular",
290
+ "person": "third"
291
+ },
292
+ {
293
+ "word": "iacimus",
294
+ "number": "plural",
295
+ "person": "first"
296
+ },
297
+ {
298
+ "word": "iacitis",
299
+ "number": "plural",
300
+ "person": "second"
301
+ },
302
+ {
303
+ "word": "iaciunt",
304
+ "number": "plural",
305
+ "person": "third"
306
+ }
307
+ ],
308
+ "bridge": "{ ...next(operator), thrower: nominative?, receiver: dative?, object: object?, location: location?, interpolate: [{ property: 'thrower' }, { property: 'receiver' }, { property: 'location' }, { property: 'object' }, operator] }",
309
+ "selector": {
310
+ "arguments": {
311
+ "nominative": "(context.declension == 'nominative' && context.number == operator.number)",
312
+ "dative": "(context.declension == 'dative')",
313
+ "object": "(context.declension == 'accusative')",
314
+ "location": "(context.declension == 'inLatin')"
315
+ }
316
+ }
317
+ },
318
+ {
319
+ "id": "dare",
320
+ "level": 0,
321
+ "bridge": "{ ...next(operator), giver: nominative?, receiver: dative?, object: accusative?, interpolate: [{ property: 'giver' }, { property: 'receiver' }, { property: 'object' }, operator] }",
322
+ "selector": {
323
+ "arguments": {
324
+ "nominative": "(context.declension == 'nominative' && context.number == operator.number)",
325
+ "dative": "(context.declension == 'dative')",
326
+ "accusative": "(context.declension == 'accusative')"
327
+ }
328
+ },
329
+ "words": [
330
+ {
331
+ "word": "do",
332
+ "number": "singular",
333
+ "person": "first"
334
+ },
335
+ {
336
+ "word": "das",
337
+ "number": "singular",
338
+ "person": "second"
339
+ },
340
+ {
341
+ "word": "dat",
342
+ "number": "singular",
343
+ "person": "third"
344
+ },
345
+ {
346
+ "word": "damus",
347
+ "number": "plural",
348
+ "person": "first"
349
+ },
350
+ {
351
+ "word": "datis",
352
+ "number": "plural",
353
+ "person": "second"
354
+ },
355
+ {
356
+ "word": "dant",
357
+ "number": "plural",
358
+ "person": "third"
359
+ }
360
+ ]
361
+ },
362
+ {
363
+ "id": "list",
364
+ "level": 0,
365
+ "selector": {
366
+ "match": "same",
367
+ "left": [
368
+ {
369
+ "pattern": "($type && context.instance == variables.instance)"
370
+ }
371
+ ],
372
+ "right": [
373
+ {
374
+ "pattern": "($type && context.instance == variables.instance)"
375
+ }
376
+ ],
377
+ "passthrough": true
378
+ },
379
+ "bridge": "{ ...next(operator), listable: true, isList: true, value: append(before, after), operator: operator, interpolate: [ { separator: 'operator', values: 'value' } ] }"
380
+ },
381
+ {
382
+ "id": "list",
383
+ "level": 1,
384
+ "selector": {
385
+ "match": "same",
386
+ "left": [
387
+ {
388
+ "pattern": "($type && context.instance == variables.instance)"
389
+ }
390
+ ],
391
+ "passthrough": true
392
+ },
393
+ "bridge": "{ ...operator, value: append(before, operator.value) }"
394
+ },
101
395
  {
102
396
  "id": "queryMarker",
103
397
  "bridge": "{ ...before[0], verb: before[0], interpolate: [before[0], '', operator], question: true }",
@@ -114,7 +408,7 @@
114
408
  "listable"
115
409
  ]
116
410
  ],
117
- "bridge": "{ ...before[0], verb: before[0], interpolate: [before[0], '', operator], list: true }",
411
+ "bridge": "{ ...before[0], verb: before[0], interpolate: [before[0], '', operator], isList: true }",
118
412
  "separators": "|"
119
413
  },
120
414
  {
package/common/latin.js CHANGED
@@ -1,6 +1,7 @@
1
1
  const { knowledgeModule, where } = require('./runtime').theprogrammablemind
2
2
  const { defaultContextCheck } = require('./helpers')
3
3
  const gdefaults = require("./gdefaults")
4
+ const { conjugateVerb, getDeclensions } = require("./latin_helpers")
4
5
  const latin_tests = require('./latin.test.json')
5
6
  const latin_instance = require('./latin.instance.json')
6
7
 
@@ -11,17 +12,97 @@ const latin_instance = require('./latin.instance.json')
11
12
 
12
13
  estne
13
14
  marcus quintus iuliaque
15
+
16
+ oculi lupi in umbra lucent ut gemmae et dentes ut margaritae
17
+ oculi lupi in umbra lucent ut gemmae -> get this
18
+ dentes ut margaritae -> have these cases. reinterpret the first one uses the new cases oculi -> dentes + ut gemmae -> ut margaritae
19
+
20
+ equus et aninus leo et lupus canis et ovis bestiae sunt
21
+ aliae bestiae sunt aves aliae pisces
22
+ moribus antiquis res stat romana virisque
23
+ fossa nimis lata et vallum nimis altum est
24
+ arma germanorium tam bona sunt nostra
25
+ hiems tempus frigidus est (compound subject)
14
26
  */
15
27
  const config = {
16
28
  operators: [
17
29
  "((hierarchy/*) [queryMarker|ne])",
18
- "((listable/*) [listMarker|que])",
19
30
  "([hierarchiable])",
20
31
  "((hierarchiable) [hierarchy|] (hierarchiable))",
21
32
  "((hierarchiable) (hierarchiable) [hierarchy|])",
22
33
  "([hierarchy|] (hierarchiable) (hierarchiable))",
34
+
35
+ "(x [list|et] y)",
36
+ "((listable/*) [listMarker|que])",
37
+
38
+ // "([inLatin|in] (context.declension == 'ablative' || context.declension == 'accusative'))"
23
39
  ],
24
40
  bridges: [
41
+ {
42
+ id: 'inLatin',
43
+ words: ['in'],
44
+ before: ['iacere'],
45
+ bridge: "{ ...next(operator), declension: 'inLatin', object: object, operator: operator, interpolate: [{ property: 'operator' }, { property: 'object' }] }",
46
+ selector: {
47
+ ordinals: [1],
48
+ arguments: {
49
+ object: "(context.declension == 'accusative' || context.declension == 'ablative')",
50
+ },
51
+ },
52
+ },
53
+ {
54
+ id: "iacere",
55
+ level: 0,
56
+ words: [
57
+ ...conjugateVerb('iacere'),
58
+ ],
59
+ bridge: "{ ...next(operator), thrower: nominative?, receiver: dative?, object: object?, location: location?, interpolate: [{ property: 'thrower' }, { property: 'receiver' }, { property: 'location' }, { property: 'object' }, operator] }",
60
+ selector: {
61
+ arguments: {
62
+ nominative: "(context.declension == 'nominative' && context.number == operator.number)",
63
+ dative: "(context.declension == 'dative')",
64
+ object: "(context.declension == 'accusative')",
65
+ location: "(context.declension == 'inLatin')",
66
+ },
67
+ },
68
+ },
69
+ {
70
+ id: "dare",
71
+ level: 0,
72
+ bridge: "{ ...next(operator), giver: nominative?, receiver: dative?, object: accusative?, interpolate: [{ property: 'giver' }, { property: 'receiver' }, { property: 'object' }, operator] }",
73
+ selector: {
74
+ arguments: {
75
+ nominative: "(context.declension == 'nominative' && context.number == operator.number)",
76
+ dative: "(context.declension == 'dative')",
77
+ accusative: "(context.declension == 'accusative')",
78
+ },
79
+ },
80
+ words: [
81
+ ...conjugateVerb('dare'),
82
+ ],
83
+ },
84
+ {
85
+ id: "list",
86
+ level: 0,
87
+ selector: {
88
+ match: "same",
89
+ left: [ { pattern: '($type && context.instance == variables.instance)' } ],
90
+ right: [ { pattern: '($type && context.instance == variables.instance)' } ],
91
+ passthrough: true
92
+ },
93
+ bridge: "{ ...next(operator), listable: true, isList: true, value: append(before, after), operator: operator, interpolate: [ { separator: 'operator', values: 'value' } ] }"
94
+ },
95
+ {
96
+ id: "list",
97
+ level: 1,
98
+ selector: {
99
+ match: "same",
100
+ left: [ { pattern: '($type && context.instance == variables.instance)' } ],
101
+ passthrough: true
102
+ },
103
+ bridge: "{ ...operator, value: append(before, operator.value) }"
104
+ },
105
+
25
106
  {
26
107
  id: "queryMarker",
27
108
  bridge: "{ ...before[0], verb: before[0], interpolate: [before[0], '', operator], question: true }",
@@ -31,7 +112,7 @@ const config = {
31
112
  {
32
113
  id: "listMarker",
33
114
  localHierarchy: [['unknown', 'listable']],
34
- bridge: "{ ...before[0], verb: before[0], interpolate: [before[0], '', operator], list: true }",
115
+ bridge: "{ ...before[0], verb: before[0], interpolate: [before[0], '', operator], isList: true }",
35
116
  separators: '|',
36
117
  },
37
118
  { id: "hierarchiable" },
@@ -65,6 +146,24 @@ const config = {
65
146
 
66
147
  const template = {
67
148
  configs: [
149
+ ({config}) => {
150
+ config.addArgs(({config, api, isA}) => ({
151
+ addLatinNoun: ({ id, nominative, genetive, development }) => {
152
+ config.addOperator({ pattern: `([${id}|])`, development: development })
153
+ config.addBridge({ id, isA: ['hierarchiable'] })
154
+ const declensions = getDeclensions(nominative, genetive)
155
+ for (const declension of declensions) {
156
+ config.addWord(declension.word, { id, initial: { ...declension, development } })
157
+ }
158
+ }
159
+ }))
160
+ },
161
+ ({addLatinNoun}) => {
162
+ addLatinNoun({ id: 'davus_person', nominative: 'davus', development: true })
163
+ addLatinNoun({ id: 'titus_person', nominative: 'titus', development: true })
164
+ addLatinNoun({ id: 'pear_food', nominative: 'pirum', development: true })
165
+ addLatinNoun({ id: 'table_latin', nominative: 'mensa', development: true })
166
+ },
68
167
  config,
69
168
  ({addSuffix}) => addSuffix('que'),
70
169
  ]
@@ -72,6 +171,7 @@ const template = {
72
171
 
73
172
  knowledgeModule( {
74
173
  config: { name: 'latin' },
174
+ // initializer,
75
175
  includes: [gdefaults],
76
176
 
77
177
  module,