ekms 9.7.1-beta.11 → 9.7.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.
Files changed (38) hide show
  1. package/common/actions.instance.json +11 -1
  2. package/common/actions.js +1 -1
  3. package/common/angle.instance.json +27 -0
  4. package/common/articles.js +38 -4
  5. package/common/can.instance.json +1 -1
  6. package/common/comparable.instance.json +12 -6
  7. package/common/conjunction.js +2 -2
  8. package/common/countable.js +39 -5
  9. package/common/crew.instance.json +1005 -158
  10. package/common/crew.js +3 -3
  11. package/common/dialogues.js +3 -4
  12. package/common/dimension.instance.json +136 -10
  13. package/common/dimension.js +5 -5
  14. package/common/drone.instance.json +406 -369
  15. package/common/drone.js +38 -8
  16. package/common/drone_v1.instance.json +105 -0
  17. package/common/edible.instance.json +72 -0
  18. package/common/emotions.instance.json +143 -4
  19. package/common/fastfood.instance.json +456 -313
  20. package/common/fastfood.js +7 -0
  21. package/common/gdefaults.js +12 -121
  22. package/common/hierarchy.js +0 -1
  23. package/common/length.instance.json +27 -0
  24. package/common/ordering.instance.json +2 -1
  25. package/common/ordinals.js +9 -3
  26. package/common/pipboy.instance.json +2 -2
  27. package/common/pipboy.js +3 -3
  28. package/common/pressure.instance.json +27 -0
  29. package/common/properties.instance.json +322 -37
  30. package/common/properties.js +38 -31
  31. package/common/reports.instance.json +5 -3
  32. package/common/stm.js +15 -9
  33. package/common/temperature.instance.json +27 -0
  34. package/common/time.instance.json +167 -0
  35. package/common/weight.instance.json +27 -0
  36. package/common/wp.instance.json +21 -21
  37. package/common/wp.js +62 -10
  38. package/package.json +2 -2
@@ -145,6 +145,7 @@ const template = {
145
145
  floaters: ['instance'],
146
146
  priorities: [
147
147
  // { "context": [['counting', 0], ['strawberry_smoothie', 0], ], "choose": [0] },
148
+ { "context": [['counting', 0], ['strawberry_smoothie', 0], ], "choose": [1] },
148
149
  { "context": [['cheese_potato', 0], ['broccoli_list_cheddar_potato', 0]], "choose": [1] },
149
150
  { "context": [['chicken_go_wrap', 0], ['chicken_sandwich', 0], ], "choose": [0] },
150
151
  { "context": [['strawberry_banana', 0], ['smoothie', 0], ], "choose": [0] },
@@ -442,6 +443,12 @@ const template = {
442
443
  ],
443
444
  },
444
445
  },
446
+ {
447
+ priorities: [
448
+ { context: [['list', 0], ['integer', 0], ['strawberry', 0], ['smoothie', 0]], choose: [2, 3], ordered: true },
449
+ { context: [['list', 0], ['integer', 1], ['strawberry', 1], ['smoothie', 0]], choose: [2, 3], ordered: true },
450
+ ],
451
+ },
445
452
  ],
446
453
  }
447
454
 
@@ -1,4 +1,5 @@
1
1
  const pluralize = require('pluralize')
2
+ const { interpolate } = require('./helpers/gdefaults')
2
3
  const { defaultContextCheck, getValue, isMany } = require('./helpers')
3
4
  const { debug, knowledgeModule, where, flatten } = require('./runtime').theprogrammablemind
4
5
  const tokenize = require('./tokenize.js')
@@ -35,8 +36,9 @@ const config = {
35
36
  where: where(),
36
37
  // match: ({context}) => context.paraphrase && context.interpolate,
37
38
  match: ({context}) => context.interpolate,
38
- apply: async ({interpolate, context}) => {
39
- return interpolate(context.interpolate, context)
39
+ apply: async (args) => {
40
+ const {debug, context} = args
41
+ return interpolate(args)(context.interpolate, context)
40
42
  }
41
43
  },
42
44
  {
@@ -112,13 +114,16 @@ const config = {
112
114
  if (index == context.postModifiers.length - 1) {
113
115
  const fn = Array.isArray(context[modifier]) ? gs: g;
114
116
  if (Array.isArray(context[modifier])) {
115
- text.push(await gs(context[modifier].map((c) => { return {...c , number} })))
117
+ debug.breakAt('fastfood#call7')
118
+ text.push(await gs(context[modifier].map((c) => { return {...c , number} }), { isModifier: true }))
116
119
  } else {
117
- text.push(await g({...context[modifier], number}))
120
+ debug.breakAt('fastfood#call7')
121
+ text.push(await g({...context[modifier], number}, { isModifier: true }))
118
122
  }
119
123
  } else {
120
124
  const fn = Array.isArray(context[modifier]) ? gs: g;
121
- text.push(await fn(context[modifier]))
125
+ debug.breakAt('fastfood#call7')
126
+ text.push(await fn({ ...context[modifier], isModifier: true }))
122
127
  }
123
128
  }
124
129
  return text.join(' ')
@@ -214,7 +219,7 @@ const config = {
214
219
 
215
220
  {
216
221
  where: where(),
217
- match: ({context}) => context.paraphrase && context.word && (context.number == 'many' || context.number > 1),
222
+ match: ({context}) => context.paraphrase && context.word && (context.number == 'many' || context.number > 1) && !context.isModifier,
218
223
  apply: ({context}) => {
219
224
  // TODO make the sentence that the plural celcius is celcius work
220
225
  if (["fahrenheit", "celcius"].includes(context.word)) {
@@ -307,121 +312,7 @@ function initializer({config}) {
307
312
  },
308
313
  verbatim,
309
314
  say: verbatim,
310
- interpolate: async (interpolate, context) => {
311
- async function evaluator(key) {
312
- if (Array.isArray(context[key])) {
313
- return args.gsp(context[key])
314
- } else {
315
- return args.gp(context[key])
316
- }
317
- }
318
- function getValue(keyOrValue) {
319
- if (typeof keyOrValue == 'string' && context[keyOrValue]) {
320
- return context[keyOrValue]
321
- }
322
- return keyOrValue // it's a value
323
- }
324
-
325
- if (Array.isArray(interpolate)) {
326
- const strings = []
327
- let separator = ''
328
- const byPosition = []
329
- for (const element of interpolate) {
330
- // { "word": { "marker": "canPassive" } ie { word: <selectionCriteria> }
331
- if (element.word) {
332
- const word = args.getWordFromDictionary(element.word)
333
- if (word) {
334
- strings.push(separator)
335
- strings.push(await args.gp(word))
336
- separator = ' '
337
- }
338
- } else if (typeof element == 'string') {
339
- separator = element
340
- } else if (element.separator && element.values) {
341
- let ctr = 0
342
- const values = getValue(element.values)
343
- const vstrings = []
344
- for (const value of values) {
345
- if (ctr == values.length-1) {
346
- vstrings.push(getValue(element.separator))
347
- }
348
- ctr += 1
349
- vstrings.push(getValue(value))
350
- }
351
- strings.push(await args.gsp(vstrings))
352
- } else if (element.semantic) {
353
- const wordContext = {}
354
- for (const term of element.semantic) {
355
- if (term.property) {
356
- Object.assign(wordContext, context[term.property])
357
- } else if (term.overrides) {
358
- Object.assign(wordContext, term.overrides)
359
- }
360
- }
361
- const value = await args.gp(wordContext) //, { options: { debug: { apply: true } } })
362
- if (value) {
363
- strings.push(separator)
364
- strings.push(await args.gp(value))
365
- separator = ' '
366
- }
367
- } else if (element.property) {
368
- value = context[element.property]
369
- if (value) {
370
- if (element.context) {
371
- value = { ...value, ...element.context }
372
- }
373
- async function handleProperty(value) {
374
- strings.push(separator)
375
- if (Array.isArray(value)) {
376
- strings.push(await args.gsp(value))
377
- } else {
378
- strings.push(await args.gp(value))
379
- }
380
- separator = ' '
381
- }
382
- if (element.byPosition) {
383
- const element = { start: value.range.start, insert: ((value) => () => handleProperty(value))(value) }
384
- if (byPosition.length == 0) {
385
- byPosition.push(element)
386
- } else {
387
- const index = byPosition.findIndex((element) => element.start < value.range.start)
388
- if (index == -1) {
389
- byPosition.unshift(element)
390
- } else {
391
- byPosition.splice(index+1, 0, element)
392
- }
393
- }
394
- } else {
395
- await handleProperty(value)
396
- }
397
- }
398
- } else if (element.context) {
399
- let value = element.context
400
- if (element.property) {
401
- value = context[element.property]
402
- if (element.context) {
403
- Object.assign(value, element.context)
404
- }
405
- }
406
- // if (!value?.number && element.number) {
407
- if (value?.form !== 'infinitive' && element.number) {
408
- value.number = isMany(context[element.number]) ? "many": "one"
409
- }
410
- if (value) {
411
- strings.push(separator)
412
- strings.push(await args.gp(value))
413
- separator = ' '
414
- }
415
- }
416
- }
417
- for (const { insert } of byPosition) {
418
- await insert()
419
- }
420
- return strings.join('')
421
- } else {
422
- return await helpers.processTemplateString(interpolate, evaluator)
423
- }
424
- }
315
+ interpolate: interpolate(args),
425
316
  }
426
317
  })
427
318
  }
@@ -258,7 +258,6 @@ const config = {
258
258
  const twoConcepts = asList(context.same);
259
259
  for (const oneConcept of oneConcepts.value) {
260
260
  for (const twoConcept of twoConcepts.value) {
261
- // debug.counter('greg23', { breakAt: 39 })
262
261
  oneConceptId = await api.makeObject({...args, context: oneConcept})
263
262
  twoConceptId = await api.makeObject({...args, context: twoConcept})
264
263
  api.rememberIsA(oneConceptId, twoConceptId)
@@ -4747,6 +4747,33 @@
4747
4747
  "unit"
4748
4748
  ],
4749
4749
  "propertyOf": true,
4750
+ "interpolate": [
4751
+ {
4752
+ "property": "property"
4753
+ },
4754
+ {
4755
+ "word": "of"
4756
+ },
4757
+ {
4758
+ "property": "object"
4759
+ }
4760
+ ],
4761
+ "property": {
4762
+ "value": "unit",
4763
+ "number": "many",
4764
+ "text": "units",
4765
+ "marker": "unit",
4766
+ "dead": true,
4767
+ "word": "units",
4768
+ "range": {
4769
+ "start": 51,
4770
+ "end": 55
4771
+ },
4772
+ "types": [
4773
+ "unit"
4774
+ ],
4775
+ "level": 0
4776
+ },
4750
4777
  "object": {
4751
4778
  "marker": "length",
4752
4779
  "value": "length",
@@ -676,7 +676,8 @@
676
676
  "unknown"
677
677
  ],
678
678
  "level": 0,
679
- "concept": true
679
+ "concept": true,
680
+ "evaluate": false
680
681
  },
681
682
  "two": {
682
683
  "marker": "xfx",
@@ -17,7 +17,7 @@ const config = {
17
17
  id: "ordinal",
18
18
  isA: ["listable"],
19
19
  bridge: "{ instance: false, ordinal: true, ...next(operator) }",
20
- init: { 'notConjunctableWith':['quantity'] },
20
+ initial: { 'notConjunctableWith':['quantity', 'number'] },
21
21
  },
22
22
  {
23
23
  id: "orderable",
@@ -28,8 +28,14 @@ const config = {
28
28
  id: "ordinalOnOrdered",
29
29
  isA: ['adjective'],
30
30
  convolution: true,
31
- // bridge: "{ ...after[0], ordinal: before[0], modifiers: append(['ordinal'], after[0].modifiers), generate: append(['ordinal'], or(after[0].generate, after)) }"
32
- bridge: "{ ...after[0], ordinal: before[0], modifiers: append(['ordinal'], after[0].modifiers) }"
31
+ // bridge: "{ ...after[0], ordinal: before[0], modifiers: append(['ordinal'], after[0].modifiers), interpolate: append(['ordinal'], or(after[0].interpolate, after)) }"
32
+ bridge: `{
33
+ ...after[0],
34
+ ordinal: before[0],
35
+ ordinalObject: after[0],
36
+ interpolate: [{ property: 'ordinal' }, { property: 'ordinalObject' }],
37
+ modifiers: append(['ordinal'], after[0].modifiers)
38
+ }`
33
39
  },
34
40
  ],
35
41
  semantics: [
@@ -17,7 +17,7 @@
17
17
  "medicine and stimpaks are takeable",
18
18
  "item modifies property",
19
19
  {
20
- "apply": "({config}) => {\n config.updateBridge('item_property', ({ bridge }) => {\n if (!bridge.init) {\n bridge.init = {}\n }\n bridge.init['typeIsSingular'] = true\n })\n }"
20
+ "apply": "({config}) => {\n config.updateBridge('item_property', ({ bridge }) => {\n if (!bridge.initial) {\n bridge.initial = {}\n }\n bridge.initial['typeIsSingular'] = true\n })\n }"
21
21
  },
22
22
  "damage luck hp rads value ap charisma range and accuracy are item properties",
23
23
  {
@@ -35896,7 +35896,7 @@
35896
35896
  }
35897
35897
  },
35898
35898
  {
35899
- "apply": "({config}) => {\n config.updateBridge('item_property', ({ bridge }) => {\n if (!bridge.init) {\n bridge.init = {}\n }\n bridge.init['typeIsSingular'] = true\n })\n }"
35899
+ "apply": "({config}) => {\n config.updateBridge('item_property', ({ bridge }) => {\n if (!bridge.initial) {\n bridge.initial = {}\n }\n bridge.initial['typeIsSingular'] = true\n })\n }"
35900
35900
  },
35901
35901
  {
35902
35902
  "hierarchy": [
package/common/pipboy.js CHANGED
@@ -489,10 +489,10 @@ const template = {
489
489
  "item modifies property",
490
490
  ({config}) => {
491
491
  config.updateBridge('item_property', ({ bridge }) => {
492
- if (!bridge.init) {
493
- bridge.init = {}
492
+ if (!bridge.initial) {
493
+ bridge.initial = {}
494
494
  }
495
- bridge.init['typeIsSingular'] = true
495
+ bridge.initial['typeIsSingular'] = true
496
496
  })
497
497
  },
498
498
  "damage luck hp rads value ap charisma range and accuracy are item properties",
@@ -4420,6 +4420,33 @@
4420
4420
  "unit"
4421
4421
  ],
4422
4422
  "propertyOf": true,
4423
+ "interpolate": [
4424
+ {
4425
+ "property": "property"
4426
+ },
4427
+ {
4428
+ "word": "of"
4429
+ },
4430
+ {
4431
+ "property": "object"
4432
+ }
4433
+ ],
4434
+ "property": {
4435
+ "value": "unit",
4436
+ "number": "many",
4437
+ "text": "units",
4438
+ "marker": "unit",
4439
+ "dead": true,
4440
+ "word": "units",
4441
+ "range": {
4442
+ "start": 28,
4443
+ "end": 32
4444
+ },
4445
+ "types": [
4446
+ "unit"
4447
+ ],
4448
+ "level": 0
4449
+ },
4423
4450
  "object": {
4424
4451
  "value": "pressure",
4425
4452
  "number": "one",