ekms 9.8.0-beta.8 → 9.9.0

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 (65) hide show
  1. package/common/actions.instance.json +4 -4
  2. package/common/actions.js +9 -9
  3. package/common/askfor.instance.json +12 -184
  4. package/common/askfor.js +19 -11
  5. package/common/asking.js +13 -5
  6. package/common/can.instance.json +2 -18
  7. package/common/can.js +2 -2
  8. package/common/comparable.instance.json +6 -12
  9. package/common/concept.instance.json +8 -4
  10. package/common/concept.js +2 -0
  11. package/common/conjunction.js +6 -4
  12. package/common/control.js +5 -5
  13. package/common/countable.js +1 -0
  14. package/common/dateTimeSelectors.instance.json +1 -1
  15. package/common/dateTimeSelectors.js +1 -1
  16. package/common/dates.instance.json +11 -1
  17. package/common/dates.js +6 -1
  18. package/common/debug.instance.json +5 -1
  19. package/common/debug.js +2 -0
  20. package/common/dialogues.js +37 -35
  21. package/common/dimension.instance.json +144 -446
  22. package/common/dimension.js +14 -8
  23. package/common/drone.instance.json +43 -19
  24. package/common/drone.js +29 -35
  25. package/common/drone_v1.instance.json +13 -3
  26. package/common/drone_v1.js +14 -9
  27. package/common/evaluate.js +2 -2
  28. package/common/fastfood.instance.json +12 -4
  29. package/common/fastfood.js +27 -12
  30. package/common/formulas.instance.json +138 -12
  31. package/common/formulas.js +15 -6
  32. package/common/gdefaults.js +2 -71
  33. package/common/helpers/dialogues.js +1 -10
  34. package/common/helpers/properties.js +6 -10
  35. package/common/helpers.js +5 -2
  36. package/common/hierarchy.js +11 -7
  37. package/common/math.instance.json +141 -4
  38. package/common/math.js +18 -5
  39. package/common/menus.instance.json +6 -2
  40. package/common/menus.js +5 -2
  41. package/common/meta.js +12 -12
  42. package/common/nameable.js +6 -2
  43. package/common/ordering.instance.json +1 -2
  44. package/common/percentages.js +4 -2
  45. package/common/pipboy.instance.json +38 -27
  46. package/common/pipboy.js +21 -14
  47. package/common/properties.instance.json +2319 -560
  48. package/common/properties.js +146 -37
  49. package/common/punctuation.js +1 -0
  50. package/common/rates.instance.json +1 -1
  51. package/common/rates.js +2 -2
  52. package/common/reminders.instance.json +16 -0
  53. package/common/reminders.js +23 -19
  54. package/common/reports.instance.json +4 -6
  55. package/common/reports.js +12 -12
  56. package/common/sdefaults.js +11 -9
  57. package/common/stm.js +11 -14
  58. package/common/testing.js +2 -2
  59. package/common/time.instance.json +42 -15
  60. package/common/time.js +7 -6
  61. package/common/ui.js +5 -5
  62. package/common/words.js +106 -1
  63. package/common/wp.instance.json +10 -3
  64. package/common/wp.js +5 -1
  65. package/package.json +2 -2
package/common/reports.js CHANGED
@@ -194,7 +194,7 @@ const config = {
194
194
 
195
195
  generatorp: async ({context, gp}) => `move ${await gp(context.from)} ${await gp(context.to)}`,
196
196
  semantic: async ({context, e, objects, kms, insert}) => {
197
- const report = await e(context.on)
197
+ const report = await e(context.on, where())
198
198
  const id = report.value.value
199
199
  const listing = objects.listings[id]
200
200
 
@@ -222,7 +222,7 @@ const config = {
222
222
  bridge: "{ ...next(operator), on: { marker: 'report', pullFromContext: true }, removee: after[0] }",
223
223
  generatorp: async ({context, gp}) => `remove ${await gp(context.removee)}`,
224
224
  semantic: async ({context, e, kms, insert, objects}) => {
225
- const report = await e(context.on)
225
+ const report = await e(context.on, where())
226
226
  const id = report.value.value
227
227
  const listing = objects.listings[id]
228
228
  const column = context.removee.index.value
@@ -337,7 +337,7 @@ const config = {
337
337
  return `call ${await g(context.namee)} ${await gs(context.name)}`
338
338
  },
339
339
  semantic: async ({context, objects, e, config, km}) => {
340
- const namee = (await e(context.namee)).evalue
340
+ const namee = (await e(context.namee, where())).evalue
341
341
  const id = namee.value
342
342
  const listing = objects.listings[id]
343
343
  // const name = context.name.text
@@ -410,7 +410,7 @@ const config = {
410
410
  if (context.report) {
411
411
  return `show ${await gp(context.report)}`
412
412
  } else {
413
- const report = await e(context.on)
413
+ const report = await e(context.on, where())
414
414
  const id = report.value.value
415
415
  const listing = objects.listings[id]
416
416
  return `the properties being shown are ${await gs(listing.columns, ', ', ' and ')}`
@@ -462,8 +462,8 @@ const config = {
462
462
  kms.stm.api.setVariable('price', { marker: 'price', value: 23 })
463
463
  kms.stm.api.setVariable('quantity', { marker: 'quantity', value: 3 })
464
464
  const c1 = { marker: 'worth', value: 'worth' }
465
- r1 = toEValue(await e(c1));
466
- r2 = await e({ marker: 'supplier', value: 'supplier' })
465
+ r1 = toEValue(await e(c1, where()));
466
+ r2 = await e({ marker: 'supplier', value: 'supplier' }, where())
467
467
  }
468
468
  const data = []
469
469
  for (const product of products) {
@@ -472,7 +472,7 @@ const config = {
472
472
  kms.stm.api.setVariable(p, { marker: p, value: product[p] })
473
473
  }
474
474
  for (const property of columns) {
475
- const value = toFinalValue(await e({ marker: property, value: property }));
475
+ const value = toFinalValue(await e({ marker: property, value: property }, where()));
476
476
  row.push(value)
477
477
  }
478
478
  data.push(row)
@@ -504,7 +504,7 @@ const config = {
504
504
  const responses = []
505
505
  for (let value of values) {
506
506
  if (!value.value || value.pullFromContext) {
507
- value = await e(value)
507
+ value = await e(value, where())
508
508
  }
509
509
  let id = value.value
510
510
  if (value.evalue) {
@@ -527,7 +527,7 @@ const config = {
527
527
  }
528
528
  context.isResponse = true
529
529
  } else {
530
- const report = await e(context.on)
530
+ const report = await e(context.on, where())
531
531
  const id = report.value.value
532
532
  const listing = objects.listings[id]
533
533
  const values = propertyToArray(context.properties)
@@ -554,7 +554,7 @@ const config = {
554
554
  //const name = '***current***'
555
555
  if (context.api) {
556
556
  // id = newReport({km, objects})
557
- const report = await e({ marker: 'report', pullFromContext: true })
557
+ const report = await e({ marker: 'report', pullFromContext: true }, where())
558
558
  const id = report.value.value
559
559
  const listing = objects.listings[id]
560
560
  listing.api = context.api
@@ -562,7 +562,7 @@ const config = {
562
562
  context.id = id
563
563
  context.listing = apis[listing.api].getAllProducts(listing)
564
564
  } else {
565
- const report = await e({ marker: 'report', pullFromContext: true })
565
+ const report = await e({ marker: 'report', pullFromContext: true }, where())
566
566
  const id = report.evalue.value
567
567
  const listing = objects.listings[id]
568
568
  const api = apis[listing.api]
@@ -575,7 +575,7 @@ const config = {
575
575
  {
576
576
  match: ({context}) => context.marker == 'answer',
577
577
  apply: async ({e, context, objects, kms, insert}) => {
578
- const report = await e({ marker: 'report', pullFromContext: true })
578
+ const report = await e({ marker: 'report', pullFromContext: true }, where())
579
579
  const id = report.value.value
580
580
  const listing = objects.listings[id]
581
581
  listing.type = context.type
@@ -1,5 +1,5 @@
1
1
  const { knowledgeModule, where, debug } = require('./runtime').theprogrammablemind
2
- const { defaultContextCheck, concats, toEValue, toFinalValue } = require('./helpers')
2
+ const { isMany, defaultContextCheck, concats, toEValue, toFinalValue } = require('./helpers')
3
3
  const control = require('./control')
4
4
  const sdefaults_tests = require('./sdefaults.test.json')
5
5
 
@@ -26,16 +26,17 @@ const config = {
26
26
  priority: -1,
27
27
  // match: ({context}) => context.flatten || context.listable && context.value[0].flatten,
28
28
  // match: (args) => okay(args, ({context}) => (context.flatten || context.listable && context.value.some((value) => value.flatten))),
29
- match: (args) => args.callOnce(args, 'sdefaults.1', ({context}) => (context.flatten || context.listable && context.value.some((value) => value.flatten))),
29
+ match: async (args) => await args.callOnce(args, 'sdefaults.1', ({context}) => (context.flatten || context.listable && context.value.some((value) => value.flatten))),
30
30
  // match: ({context}) => context.flatten || context.listable || (Array.isArray(context.value) && context.value.some((value) => value.flatten)),
31
- apply: async ({config, km, context, s, _continue, flatten}) => {
31
+ apply: async ({config, km, context, e, _continue, flatten}) => {
32
32
  const flats = flatten(['list'], context)
33
33
  const evalues = []
34
34
  for (const flat of flats) {
35
35
  if (!flat.control) {
36
36
  flat.control = context.control
37
37
  }
38
- const result = await s(flat)
38
+ flat.topLevel = context.topLevel
39
+ const result = await e(flat, where())
39
40
  if (result.evalue) {
40
41
  evalues.push(result.evalue)
41
42
  }
@@ -52,14 +53,14 @@ const config = {
52
53
  where: where(),
53
54
  priority: -1,
54
55
  // sdefault.1 tag is the same as above on purpose
55
- match: (args) => args.callOnce(args, 'sdefaults.1', ({context}) => (context.flatten && context.relation)),
56
- apply: async ({flatten, config, km, context, s}) => {
56
+ match: async (args) => await args.callOnce(args, 'sdefaults.1', ({context}) => (context.flatten && context.relation)),
57
+ apply: async ({flatten, config, km, context, e}) => {
57
58
  const flats = flatten(['list'], context)
58
59
  for (const flat of flats) {
59
60
  if (!flat.control) {
60
61
  flat.control = context.control
61
62
  }
62
- await s(flat)
63
+ await e(flat, where())
63
64
  }
64
65
  }
65
66
  },
@@ -69,7 +70,7 @@ const config = {
69
70
  priority: -1,
70
71
  match: ({context}) => context.semanticIsEvaluate,
71
72
  apply: async ({context, e}) => {
72
- context.evalue = await e({ ...context, semanticIsEvaluate: false })
73
+ context.evalue = await e({ ...context, semanticIsEvaluate: false }, where())
73
74
  context.isResponse = true
74
75
  }
75
76
  },
@@ -103,11 +104,12 @@ function initializer({objects, config, isModule}) {
103
104
  config.addArgs(({e}) => ({
104
105
  toFinalValue,
105
106
  toEValue,
107
+ isMany,
106
108
  unify: async (term1, term2) => {
107
109
  const unification = await e({
108
110
  marker: 'unify',
109
111
  terms: [term1, term2],
110
- })
112
+ }, where())
111
113
  return unification?.evalue
112
114
  },
113
115
  }))
package/common/stm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  const { knowledgeModule, where, debug } = require('./runtime').theprogrammablemind
2
- const { defaultContextCheckProperties, defaultContextCheck } = require('./helpers')
2
+ const { defaultContextCheckProperties, defaultContextCheck, toFinalValue } = require('./helpers')
3
3
  const helpers = require('./helpers')
4
4
  const helpers_conjunction = require('./helpers/conjunction')
5
5
  const articles = require('./articles')
@@ -55,8 +55,6 @@ class API {
55
55
  return
56
56
  }
57
57
 
58
- concept.evaluate = false
59
-
60
58
  if (!frameOfReference) {
61
59
  frameOfReference = this._objects
62
60
  }
@@ -266,6 +264,7 @@ const config = {
266
264
  },
267
265
  {
268
266
  id: 'delete',
267
+ where: where(),
269
268
  isA: ['verb'],
270
269
  bridge: "{ ...next(operator), deletable: after[0], operator: operator, interpolate: [{ property: 'operator' }, { property: 'deletable' }] }",
271
270
  semantic: async ({context, recall}) => {
@@ -286,6 +285,7 @@ const config = {
286
285
  },
287
286
  {
288
287
  id: 'recall',
288
+ where: where(),
289
289
  bridge: "{ ...next(operator), postModifiers: ['recallee'], recallee: after[0] }",
290
290
  isA: ['verb'],
291
291
  semantic: async ({context, recall, resolveEvaluate, e}) => {
@@ -295,10 +295,11 @@ const config = {
295
295
  },
296
296
  {
297
297
  id: 'remember',
298
+ where: where(),
298
299
  bridge: "{ ...next(operator), postModifiers: ['rememberee'], rememberee: after[0] }",
299
300
  isA: ['verb'],
300
301
  semantic: async ({context, api, e}) => {
301
- let value = (await e(context.rememberee)).evalue
302
+ let value = toFinalValue((await e(context.rememberee, where())))
302
303
  if (value == context.rememberee.value) {
303
304
  value = context.rememberee
304
305
  }
@@ -370,15 +371,11 @@ const config = {
370
371
  return
371
372
  }
372
373
 
373
- if (context.evaluate) {
374
- const instance = await e(context.value)
375
- if (instance.evalue && !instance.edefault) {
376
- context.value = instance.evalue
377
- }
378
- context.evalue = context.value
379
- } else {
380
- await s(context.value)
374
+ const instance = await e(context.value, where())
375
+ if (instance.evalue && !instance.edefault) {
376
+ context.value = instance.evalue
381
377
  }
378
+ context.evalue = context.value
382
379
  },
383
380
  },
384
381
  ],
@@ -420,13 +417,13 @@ function initializer({config}) {
420
417
 
421
418
  recall: async (args) => {
422
419
  if (args.frameOfReference?.nameable_named) {
423
- const result = await e(args.frameOfReference)
420
+ const result = await e(args.frameOfReference, where())
424
421
  if (result.evalue) {
425
422
  args.frameOfReference = result.evalue
426
423
  }
427
424
  }
428
425
 
429
- const result = await e({ marker: 'mentions', args })
426
+ const result = await e({ marker: 'mentions', args }, where())
430
427
  // evalue will return the argument if there is no evalue. dont want that for this case
431
428
  if (!result.evalue) {
432
429
  return
package/common/testing.js CHANGED
@@ -14,7 +14,7 @@ const config = {
14
14
  id: 'testingEvaluate',
15
15
  generatorp: async ({context, g}) => `${context.word} ${await g(context.value)}`,
16
16
  semantic: async ({context, e}) => {
17
- context.evalue = await e(context.value)
17
+ context.evalue = await e(context.value, where())
18
18
  context.isResponse = true
19
19
  },
20
20
  bridge: "{ ...next(operator), value: after[0] }",
@@ -22,7 +22,7 @@ const config = {
22
22
  {
23
23
  where: where(),
24
24
  id: 'testingValue',
25
- evaluator: ({context}) => {
25
+ semantic: ({context}) => {
26
26
  context.evalue = 'evaluated testingValue'
27
27
  }
28
28
  },
@@ -143,7 +143,22 @@
143
143
  "isA": [
144
144
  "preposition"
145
145
  ],
146
- "bridge": "{ ...next(operator), time: after[0], operator: operator, interpolate: '${operator} ${time}' }"
146
+ "bridge": "{ ...next(operator), time: after[0], operator: operator, interpolate: '${operator} ${time}' }",
147
+ "check": [
148
+ "marker",
149
+ "text",
150
+ "verbatim",
151
+ "value",
152
+ "evalue",
153
+ "isResponse",
154
+ {
155
+ "properties": "modifiers"
156
+ },
157
+ {
158
+ "properties": "postModifiers"
159
+ },
160
+ "time"
161
+ ]
147
162
  },
148
163
  {
149
164
  "id": "ampm",
@@ -199,8 +214,8 @@
199
214
  ],
200
215
  "semantics": [
201
216
  {
202
- "match": "(args) => args.callOnce(args, 'time.1', ({context}) => context.repeats) && args.context.repeats?.repeats",
203
- "apply": "async ({context, e, s, handlerStack}) => {\n const v = (await e(context.repeats.repeats)).evalue\n for (let i = 0; i < v; ++i) {\n if (context.action) {\n await s(context.action)\n } else {\n const repeats = context.repeats\n context.repeats = undefined\n await s(context)\n context.repeats = repeats\n }\n }\n }"
217
+ "match": "async (args) => await args.callOnce(args, 'time.1', ({context}) => context.repeats) && args.context.repeats?.repeats",
218
+ "apply": "async ({context, e, handlerStack, toFinalValue}) => {\n const v = toFinalValue((await e(context.repeats.repeats, where())))\n for (let i = 0; i < v; ++i) {\n if (context.action) {\n await e(context.action, where())\n } else {\n const repeats = context.repeats\n context.repeats = undefined\n await e(context, where())\n context.repeats = repeats\n }\n }\n }"
204
219
  },
205
220
  {
206
221
  "match": "({objects, context, api}) => context.marker == 'timePoint' && !context.isInstance",
@@ -351,10 +366,7 @@
351
366
  "dead": true,
352
367
  "level": 2,
353
368
  "context_index": 1,
354
- "topLevel": true,
355
- "touchedBy": [
356
- "time#call2"
357
- ]
369
+ "topLevel": true
358
370
  }
359
371
  ],
360
372
  "generated": [
@@ -10958,7 +10970,22 @@
10958
10970
  "isA": [
10959
10971
  "preposition"
10960
10972
  ],
10961
- "bridge": "{ ...next(operator), time: after[0], operator: operator, interpolate: '${operator} ${time}' }"
10973
+ "bridge": "{ ...next(operator), time: after[0], operator: operator, interpolate: '${operator} ${time}' }",
10974
+ "check": [
10975
+ "marker",
10976
+ "text",
10977
+ "verbatim",
10978
+ "value",
10979
+ "evalue",
10980
+ "isResponse",
10981
+ {
10982
+ "properties": "modifiers"
10983
+ },
10984
+ {
10985
+ "properties": "postModifiers"
10986
+ },
10987
+ "time"
10988
+ ]
10962
10989
  },
10963
10990
  {
10964
10991
  "id": "ampm",
@@ -11000,31 +11027,31 @@
11000
11027
  },
11001
11028
  "generators": [
11002
11029
  {
11003
- "where": "/home/dev/code/theprogrammablemind/kms/common/time.js:172"
11030
+ "where": "/home/dev/code/theprogrammablemind/kms/common/time.js:173"
11004
11031
  },
11005
11032
  {
11006
- "where": "/home/dev/code/theprogrammablemind/kms/common/time.js:187"
11033
+ "where": "/home/dev/code/theprogrammablemind/kms/common/time.js:188"
11007
11034
  },
11008
11035
  {
11009
- "where": "/home/dev/code/theprogrammablemind/kms/common/time.js:200"
11036
+ "where": "/home/dev/code/theprogrammablemind/kms/common/time.js:201"
11010
11037
  }
11011
11038
  ],
11012
11039
  "semantics": [
11013
11040
  {
11014
- "where": "/home/dev/code/theprogrammablemind/kms/common/time.js:208",
11041
+ "where": "/home/dev/code/theprogrammablemind/kms/common/time.js:209",
11015
11042
  "priority": -1
11016
11043
  },
11017
11044
  {
11018
11045
  "notes": "evaluate time",
11019
- "where": "/home/dev/code/theprogrammablemind/kms/common/time.js:227"
11046
+ "where": "/home/dev/code/theprogrammablemind/kms/common/time.js:228"
11020
11047
  },
11021
11048
  {
11022
11049
  "notes": "use time format working case",
11023
- "where": "/home/dev/code/theprogrammablemind/kms/common/time.js:236"
11050
+ "where": "/home/dev/code/theprogrammablemind/kms/common/time.js:237"
11024
11051
  },
11025
11052
  {
11026
11053
  "notes": "use time format error case",
11027
- "where": "/home/dev/code/theprogrammablemind/kms/common/time.js:244"
11054
+ "where": "/home/dev/code/theprogrammablemind/kms/common/time.js:245"
11028
11055
  }
11029
11056
  ]
11030
11057
  }
package/common/time.js CHANGED
@@ -140,7 +140,8 @@ const template = {
140
140
  id: "atTime",
141
141
  words: ['@'],
142
142
  isA: ['preposition'],
143
- bridge: "{ ...next(operator), time: after[0], operator: operator, interpolate: '${operator} ${time}' }"
143
+ bridge: "{ ...next(operator), time: after[0], operator: operator, interpolate: '${operator} ${time}' }",
144
+ check: defaultContextCheckProperties(['time']),
144
145
  },
145
146
  {
146
147
  id: "ampm",
@@ -207,16 +208,16 @@ const template = {
207
208
  {
208
209
  where: where(),
209
210
  priority: -1,
210
- match: (args) => args.callOnce(args, 'time.1', ({context}) => context.repeats) && args.context.repeats?.repeats,
211
- apply: async ({context, e, s, handlerStack}) => {
212
- const v = (await e(context.repeats.repeats)).evalue
211
+ match: async (args) => await args.callOnce(args, 'time.1', ({context}) => context.repeats) && args.context.repeats?.repeats,
212
+ apply: async ({context, e, handlerStack, toFinalValue}) => {
213
+ const v = toFinalValue((await e(context.repeats.repeats, where())))
213
214
  for (let i = 0; i < v; ++i) {
214
215
  if (context.action) {
215
- await s(context.action)
216
+ await e(context.action, where())
216
217
  } else {
217
218
  const repeats = context.repeats
218
219
  context.repeats = undefined
219
- await s(context)
220
+ await e(context, where())
220
221
  context.repeats = repeats
221
222
  }
222
223
  }
package/common/ui.js CHANGED
@@ -62,9 +62,9 @@ const config = {
62
62
  {
63
63
  where: where(),
64
64
  match: ({context, isA}) => isA(context, 'direction'),
65
- apply: async ({context, insert, s, fragments}) => {
65
+ apply: async ({context, insert, e, fragments}) => {
66
66
  const instantiation = await fragments("move direction", { direction: context })
67
- await s(instantiation)
67
+ await e(instantiation, where())
68
68
  }
69
69
  },
70
70
  ],
@@ -124,12 +124,12 @@ const config = {
124
124
  1: "{ marker: 'moveable', pullFromContext: true, default: true, skipDefault: true }"
125
125
  },
126
126
  bridge: "{ ...next(operator), operator: operator, moveable: after[0], direction: after[1], generate: ['operator', 'moveable', 'direction' ] }",
127
- semantic: async ({api, context, e}) => {
127
+ semantic: async ({api, context, toFinalValue, e}) => {
128
128
  if (context.direction?.steps?.quantity) {
129
129
  api.move(context.direction.value, context.direction.steps.quantity.value, context.direction.steps.marker)
130
130
  } else {
131
- const steps = await e(context.direction.steps)
132
- api.move(context.direction.value, steps?.evalue || 1)
131
+ const steps = toFinalValue(await e(context.direction.steps, where()))
132
+ api.move(context.direction.value, steps || 1)
133
133
  // api.move(context.direction.value, context.direction.steps ? context.direction.steps.value : 1)
134
134
  }
135
135
  }
package/common/words.js CHANGED
@@ -1,11 +1,29 @@
1
+ const pluralize = require('pluralize')
1
2
  const { knowledgeModule, where } = require('./runtime').theprogrammablemind
2
3
  const { defaultContextCheck } = require('./helpers')
3
4
  const words_tests = require('./words.test.json')
4
5
  const instance = require('./words.instance.json')
5
6
  const tokenize = require('./tokenize')
7
+ const englishHelpers = require('./english_helpers.js')
8
+
9
+ class API {
10
+ initialize({ objects }) {
11
+ this._objects = objects
12
+ }
13
+
14
+ toPlural(context) {
15
+ return this._objects.plural[context.word] || pluralize.plural(context.word)
16
+ }
17
+ }
6
18
 
7
19
  function initializer({objects, config, isModule}) {
8
20
  objects.words = []
21
+ objects.singular = {}
22
+ objects.plural = {
23
+ 'who': 'who',
24
+ 'fahrenheit': 'fahrenheit',
25
+ 'celcius': 'celcius',
26
+ }
9
27
  config.addArgs((args) => ({
10
28
  getWordFromDictionary: (partial) => {
11
29
  for (const word of objects.words) {
@@ -23,6 +41,14 @@ function initializer({objects, config, isModule}) {
23
41
  }
24
42
  }
25
43
  },
44
+
45
+ // number/gender/person etc
46
+
47
+ gw: (context, { number: numberContext } = {}) => {
48
+ const number = numberContext ? args.number(numberContext) : context.number;
49
+ return args.gp( { ...context, evaluateWord: true, number } )
50
+ },
51
+
26
52
  addWordToDictionary: (context) => {
27
53
  if (context.word) {
28
54
  const word = { ...context }
@@ -34,15 +60,94 @@ function initializer({objects, config, isModule}) {
34
60
  }))
35
61
  }
36
62
 
63
+ const config = {
64
+ name: 'words',
65
+ operators: [
66
+ "([plural])",
67
+ "([singular])",
68
+ ],
69
+ bridges: [
70
+ { id: 'plural' },
71
+ { id: 'singular' },
72
+ ],
73
+ generators: [
74
+ {
75
+ where: where(),
76
+ priority: -1,
77
+ match: ({context}) => context.marker == 'modifies' && context.evaluateWord && context.paraphrase && context.number == 'one',
78
+ apply: ({context}) => 'modifies'
79
+ },
80
+
81
+ {
82
+ where: where(),
83
+ priority: -1,
84
+ match: ({context}) => context.marker == 'modifies' && context.evaluateWord && context.paraphrase && (context.number == 'many' || context.number > 1),
85
+ apply: ({context}) => 'modify'
86
+ },
87
+
88
+ {
89
+ where: where(),
90
+ priority: -1,
91
+ match: ({context}) => context.evaluateWord && context.isVerb && context.paraphrase && context.word && !context.imperative && !context.interpolate,
92
+ apply: ({context}) => {
93
+ const infinitive = englishHelpers.getInfinitive(context.word)
94
+ if (context.form == 'infinitive') {
95
+ const cases = englishHelpers.conjugateVerb(infinitive)
96
+ const def = cases.find((def) => def.form == context.form)
97
+ return def.word
98
+ } else if (context.tense) {
99
+ const cases = englishHelpers.conjugateVerb(infinitive)
100
+ const def = cases.find((def) => def.tense == context.tense)
101
+ return def.word
102
+ } else {
103
+ return pluralize.plural(context.word)
104
+ }
105
+ },
106
+ },
107
+
108
+ {
109
+ where: where(),
110
+ priority: -1,
111
+ match: ({context}) => context.evaluateWord && context.paraphrase && context.word && (context.number == 'many' || context.number > 1) && !context.interpolate,
112
+ apply: ({context, objects}) => {
113
+ const override = objects.plural[context.word]
114
+ return override || pluralize.plural(context.word)
115
+ },
116
+ },
117
+
118
+ {
119
+ where: where(),
120
+ priority: -1,
121
+ match: ({context}) => context.evaluateWord && context.isVerb && context.paraphrase && context.word && context.number == 'one' && !context.imperative && !context.interpolate,
122
+ apply: ({context}) => {
123
+ const infinitive = englishHelpers.getInfinitive(context.word)
124
+ const cases = englishHelpers.conjugateVerb(infinitive)
125
+ return pluralize.plural(context.word)
126
+ },
127
+ },
128
+
129
+ {
130
+ where: where(),
131
+ priority: -1,
132
+ match: ({context}) => context.evaluateWord && context.paraphrase && context.word && context.number == 'one' && !context.interpolate,
133
+ apply: ({context, objects}) => {
134
+ const override = objects.singular[context.word]
135
+ return override || pluralize.singular(context.word)
136
+ },
137
+ },
138
+ ],
139
+ }
140
+
37
141
  const template = {
38
142
  configs: [],
39
143
  fragments: [],
40
144
  }
41
145
 
42
146
  knowledgeModule( {
43
- config: { name: 'words' },
147
+ config,
44
148
  includes: [tokenize],
45
149
  initializer,
150
+ api: () => new API(),
46
151
 
47
152
  module,
48
153
  description: 'talking about words',
@@ -829,6 +829,7 @@
829
829
  },
830
830
  {
831
831
  "id": "statefulElementInContext_wp",
832
+ "where": "/home/dev/code/theprogrammablemind/kms/common/wp.js:320",
832
833
  "parents": [
833
834
  "preposition"
834
835
  ],
@@ -840,6 +841,7 @@
840
841
  },
841
842
  {
842
843
  "id": "applyStyle_wp",
844
+ "where": "/home/dev/code/theprogrammablemind/kms/common/wp.js:346",
843
845
  "parents": [
844
846
  "verb"
845
847
  ],
@@ -930,6 +932,7 @@
930
932
  },
931
933
  {
932
934
  "id": "changeState_wp",
935
+ "where": "/home/dev/code/theprogrammablemind/kms/common/wp.js:431",
933
936
  "parents": [
934
937
  "verb"
935
938
  ],
@@ -956,7 +959,7 @@
956
959
  ],
957
960
  "semantics": [
958
961
  {
959
- "match": "({context, isA}) => isA(context, 'style_wp') && !context.same && !context.isResponse",
962
+ "match": "({context, isA, debug}) => isA(context, 'style_wp') && !context.same && !context.isResponse",
960
963
  "apply": "({context, api, isA, toArray}) => {\n const update = { scope: 'selection' }\n setUpdate(isA, update, toArray(context))\n api.changeState(update)\n }"
961
964
  },
962
965
  {
@@ -11826,6 +11829,7 @@
11826
11829
  },
11827
11830
  {
11828
11831
  "id": "statefulElementInContext_wp",
11832
+ "where": "/home/dev/code/theprogrammablemind/kms/common/wp.js:320",
11829
11833
  "parents": [
11830
11834
  "preposition"
11831
11835
  ],
@@ -11836,6 +11840,7 @@
11836
11840
  },
11837
11841
  {
11838
11842
  "id": "applyStyle_wp",
11843
+ "where": "/home/dev/code/theprogrammablemind/kms/common/wp.js:346",
11839
11844
  "parents": [
11840
11845
  "verb"
11841
11846
  ],
@@ -11925,6 +11930,7 @@
11925
11930
  },
11926
11931
  {
11927
11932
  "id": "changeState_wp",
11933
+ "where": "/home/dev/code/theprogrammablemind/kms/common/wp.js:431",
11928
11934
  "parents": [
11929
11935
  "verb"
11930
11936
  ],
@@ -11950,10 +11956,11 @@
11950
11956
  ],
11951
11957
  "semantics": [
11952
11958
  {
11953
- "where": "/home/dev/code/theprogrammablemind/kms/common/wp.js:452"
11959
+ "where": "/home/dev/code/theprogrammablemind/kms/common/wp.js:455",
11960
+ "priority": -1
11954
11961
  },
11955
11962
  {
11956
- "where": "/home/dev/code/theprogrammablemind/kms/common/wp.js:461"
11963
+ "where": "/home/dev/code/theprogrammablemind/kms/common/wp.js:465"
11957
11964
  }
11958
11965
  ],
11959
11966
  "priorities": [