ekms 9.5.0-beta.0 → 9.5.1-beta.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 (43) hide show
  1. package/common/asking.js +4 -4
  2. package/common/characters.js +2 -2
  3. package/common/crew.instance.json +47 -61
  4. package/common/crew.test.json +4148 -3324
  5. package/common/dialogues.js +1 -1
  6. package/common/dimension.instance.json +8 -8
  7. package/common/dimension.js +4 -4
  8. package/common/edible.instance.json +72 -0
  9. package/common/emotions.instance.json +26 -0
  10. package/common/emotions.test.json +242 -174
  11. package/common/english_helpers.js +126 -0
  12. package/common/errors.js +3 -3
  13. package/common/evaluate.js +2 -2
  14. package/common/events.js +8 -8
  15. package/common/fastfood.instance.json +242 -18
  16. package/common/formulas.js +1 -1
  17. package/common/gdefaults.js +19 -2
  18. package/common/help.js +1 -1
  19. package/common/helpers/meta.js +1 -1
  20. package/common/helpers/properties.js +91 -49
  21. package/common/helpers.js +53 -0
  22. package/common/latin.instance.json +2 -2
  23. package/common/latin.js +4 -4
  24. package/common/listener.js +1 -1
  25. package/common/math.instance.json +8 -8
  26. package/common/math.js +4 -4
  27. package/common/meta.js +27 -27
  28. package/common/nameable.js +7 -7
  29. package/common/ordering.instance.json +78 -0
  30. package/common/ordering.test.json +663 -233
  31. package/common/people.instance.json +26 -12
  32. package/common/people.js +5 -3
  33. package/common/people.test.json +4071 -3813
  34. package/common/pipboy.js +2 -3
  35. package/common/properties.js +6 -1
  36. package/common/reminders.instance.json +4 -4
  37. package/common/reminders.js +2 -2
  38. package/common/reports.instance.json +2 -2
  39. package/common/scorekeeper.js +2 -2
  40. package/common/stm.js +2 -2
  41. package/common/tokenize.js +4 -1
  42. package/common/wp.instance.json +74 -2
  43. package/package.json +4 -2
@@ -0,0 +1,126 @@
1
+ function conjugateVerb(infinitive) {
2
+ // Validate
3
+ if (typeof infinitive !== 'string') {
4
+ throw new Error('Input must be a non-empty string');
5
+ }
6
+
7
+ // Normalise input – remove optional leading "to " and trim
8
+ const baseVerb = infinitive.replace(/^to\s+/i, '').trim().toLowerCase();
9
+
10
+ // Validate
11
+ if (!baseVerb) {
12
+ throw new Error('Input must be a non-empty string');
13
+ }
14
+
15
+ // Result container
16
+ const conjugations = [];
17
+
18
+ // Infinitive form – **without** "to"
19
+ conjugations.push({ word: baseVerb, number: 'none', person: 'none', tense: 'infinitive' });
20
+
21
+ // Irregular present-tense forms
22
+ const irregulars = {
23
+ be: {
24
+ singular: { first: 'am', second: 'are', third: 'is' },
25
+ plural: { first: 'are', second: 'are', third: 'are' }
26
+ },
27
+ have: {
28
+ singular: { first: 'have', second: 'have', third: 'has' },
29
+ plural: { first: 'have', second: 'have', third: 'have' }
30
+ },
31
+ do: {
32
+ singular: { first: 'do', second: 'do', third: 'does' },
33
+ plural: { first: 'do', second: 'do', third: 'do' }
34
+ },
35
+ go: {
36
+ singular: { first: 'go', second: 'go', third: 'goes' },
37
+ plural: { first: 'go', second: 'go', third: 'go' }
38
+ },
39
+ say: {
40
+ singular: { first: 'say', second: 'say', third: 'says' },
41
+ plural: { first: 'say', second: 'say', third: 'say' }
42
+ }
43
+ };
44
+
45
+ // Regular present-tense helper
46
+ function conjugateRegular(verb, number, person) {
47
+ if (number === 'singular' && person === 'third') {
48
+ if (/[sxz]$/.test(verb)) return verb + 'es'; // box → boxes
49
+ if (/[^aeiou]y$/.test(verb)) return verb.slice(0, -1) + 'ies'; // fly → flies
50
+ if (/o$/.test(verb)) return verb + 'es'; // go → goes (fallback)
51
+ if (/[cs]h$/.test(verb)) return verb + 'es'; // watch → watches
52
+ return verb + 's'; // walk → walks
53
+ }
54
+ return verb;
55
+ }
56
+
57
+ const numbers = ['singular', 'plural'];
58
+ const persons = ['first', 'second', 'third'];
59
+
60
+ // ----- Conjugation -----
61
+ if (irregulars[baseVerb]) {
62
+ const map = irregulars[baseVerb];
63
+ for (const n of numbers) {
64
+ for (const p of persons) {
65
+ conjugations.push({ word: map[n][p], number: n, person: p, tense: 'present' });
66
+ }
67
+ }
68
+ } else {
69
+ for (const n of numbers) {
70
+ for (const p of persons) {
71
+ const word = conjugateRegular(baseVerb, n, p);
72
+ conjugations.push({ word, number: n, person: p, tense: 'present' });
73
+ }
74
+ }
75
+ }
76
+
77
+ return conjugations;
78
+ }
79
+
80
+ function getInfinitive(conjugated) {
81
+ const word = conjugated.trim().toLowerCase();
82
+ if (!word) throw new Error('Input must be a non-empty string');
83
+
84
+ // Special cases: irregular 3rd-person singular forms
85
+ const irregularMap = {
86
+ 'is': 'be',
87
+ 'has': 'have',
88
+ 'does': 'do',
89
+ 'goes': 'go',
90
+ 'says': 'say',
91
+ 'am': 'be',
92
+ 'are': 'be'
93
+ };
94
+
95
+ if (irregularMap[word]) {
96
+ return irregularMap[word];
97
+ }
98
+
99
+ // For regular verbs: undo the -s / -es / -ies endings
100
+ if (word.endsWith('ies') && word.length > 3) {
101
+ // flies → fly
102
+ return word.slice(0, -3) + 'y';
103
+ }
104
+
105
+ if (word.endsWith('es') && word.length > 3) {
106
+ const stem = word.slice(0, -2);
107
+ // boxes → box, watches → watch, goes → go
108
+ if (/[sxz]$/.test(stem) || /[cs]h$/.test(stem) || stem.endsWith('o')) {
109
+ return stem;
110
+ }
111
+ }
112
+
113
+ if (word.endsWith('s') && !word.endsWith('ss') && word.length > 1) {
114
+ // moves → move, walks → walk
115
+ return word.slice(0, -1);
116
+ }
117
+
118
+ // If no suffix removed, return as-is (base form or unknown)
119
+ return word;
120
+ }
121
+
122
+ module.exports = {
123
+ conjugateVerb,
124
+ getInfinitive,
125
+ }
126
+
package/common/errors.js CHANGED
@@ -6,15 +6,15 @@ const tests = require('./errors.test.json')
6
6
  const config = {
7
7
  name: 'errors',
8
8
  operators: [
9
- { pattern: "([drop] ([dropable]))", development: true },
9
+ { pattern: "([drop] ([dropable]))", scope: "testing" },
10
10
  ],
11
11
  bridges: [
12
12
  {
13
13
  id: "drop",
14
14
  bridge: "{ ...next(operator), arg: after[0] }",
15
- development: true
15
+ scope: "testing"
16
16
  },
17
- { id: "dropable", development: true },
17
+ { id: "dropable", scope: "testing" },
18
18
  ],
19
19
  semantics: [
20
20
  {
@@ -8,7 +8,7 @@ const config = {
8
8
  name: 'evaluate',
9
9
  operators: [
10
10
  "([evaluate] (value))",
11
- { pattern: "([value1])", development: true },
11
+ { pattern: "([value1])", scope: "testing" },
12
12
  ],
13
13
  bridges: [
14
14
  {
@@ -17,7 +17,7 @@ const config = {
17
17
  evaluator: ({context}) => {
18
18
  context.evalue = 'value1 after evaluation'
19
19
  },
20
- development: true,
20
+ scope: "testing",
21
21
  },
22
22
  {
23
23
  where: where(),
package/common/events.js CHANGED
@@ -24,8 +24,8 @@ const config = {
24
24
  operators: [
25
25
  "([after] ([event]) ([action]))",
26
26
  "(([changeable]) [changes])",
27
- { pattern: "([event1])", development: true },
28
- { pattern: "([action1])", development: true },
27
+ { pattern: "([event1])", scope: "testing" },
28
+ { pattern: "([action1])", scope: "testing" },
29
29
  ],
30
30
  bridges: [
31
31
  {
@@ -62,12 +62,12 @@ const config = {
62
62
  }
63
63
  ]
64
64
  },
65
- { id: "event1", level: 0, bridge: "{ ...next(operator) }", development: true },
66
- { id: "action1", level: 0, bridge: "{ ...next(operator) }", development: true },
65
+ { id: "event1", level: 0, bridge: "{ ...next(operator) }", scope: "testing" },
66
+ { id: "action1", level: 0, bridge: "{ ...next(operator) }", scope: "testing" },
67
67
  ],
68
68
  hierarchy: [
69
- { child: 'event1', parent: 'event', development: true },
70
- { child: 'action1', parent: 'action', development: true },
69
+ { child: 'event1', parent: 'event', scope: "testing" },
70
+ { child: 'action1', parent: 'action', scope: "testing" },
71
71
  ['changes', 'event'],
72
72
  ],
73
73
  generators: [
@@ -81,7 +81,7 @@ const config = {
81
81
  semantics: [
82
82
  {
83
83
  notes: 'event1',
84
- development: true,
84
+ scope: "testing",
85
85
  where: where(),
86
86
  match: ({context}) => context.marker == 'event1' && !context.event,
87
87
  apply: ({context, kms, insert}) => {
@@ -90,7 +90,7 @@ const config = {
90
90
  },
91
91
  {
92
92
  notes: 'action1',
93
- development: true,
93
+ scope: "testing",
94
94
  where: where(),
95
95
  match: ({context, isA}) => context.marker == 'action1',
96
96
  apply: ({context, kms}) => {
@@ -96646,6 +96646,24 @@
96646
96646
  0
96647
96647
  ]
96648
96648
  ],
96649
+ [
96650
+ [
96651
+ "countable",
96652
+ 0
96653
+ ],
96654
+ [
96655
+ "is",
96656
+ 0
96657
+ ],
96658
+ [
96659
+ "list",
96660
+ 1
96661
+ ],
96662
+ [
96663
+ "strawberry",
96664
+ 0
96665
+ ]
96666
+ ],
96649
96667
  [
96650
96668
  [
96651
96669
  "countable",
@@ -109693,6 +109711,10 @@
109693
109711
  [
109694
109712
  "smoothie",
109695
109713
  0
109714
+ ],
109715
+ [
109716
+ "strawberry",
109717
+ 0
109696
109718
  ]
109697
109719
  ],
109698
109720
  [
@@ -150283,6 +150305,24 @@
150283
150305
  0
150284
150306
  ]
150285
150307
  ],
150308
+ [
150309
+ [
150310
+ "a",
150311
+ 0
150312
+ ],
150313
+ [
150314
+ "is",
150315
+ 0
150316
+ ],
150317
+ [
150318
+ "meal",
150319
+ 0
150320
+ ],
150321
+ [
150322
+ "unknown",
150323
+ 0
150324
+ ]
150325
+ ],
150286
150326
  [
150287
150327
  [
150288
150328
  "is",
@@ -345358,10 +345398,6 @@
345358
345398
  "french",
345359
345399
  0
345360
345400
  ],
345361
- [
345362
- "french_toast_sandwich",
345363
- 0
345364
- ],
345365
345401
  [
345366
345402
  "is",
345367
345403
  0
@@ -345394,6 +345430,10 @@
345394
345430
  "platter",
345395
345431
  0
345396
345432
  ],
345433
+ [
345434
+ "sandwich",
345435
+ 0
345436
+ ],
345397
345437
  [
345398
345438
  "sausage",
345399
345439
  0
@@ -345425,13 +345465,17 @@
345425
345465
  0
345426
345466
  ],
345427
345467
  [
345428
- "egg",
345468
+ "egg_muffin",
345429
345469
  0
345430
345470
  ],
345431
345471
  [
345432
345472
  "french",
345433
345473
  0
345434
345474
  ],
345475
+ [
345476
+ "french_toast_sandwich",
345477
+ 0
345478
+ ],
345435
345479
  [
345436
345480
  "is",
345437
345481
  0
@@ -345464,10 +345508,6 @@
345464
345508
  "platter",
345465
345509
  0
345466
345510
  ],
345467
- [
345468
- "sandwich",
345469
- 0
345470
- ],
345471
345511
  [
345472
345512
  "sausage",
345473
345513
  0
@@ -593603,6 +593643,60 @@
593603
593643
  0
593604
593644
  ]
593605
593645
  ],
593646
+ [
593647
+ [
593648
+ "bacon",
593649
+ 0
593650
+ ],
593651
+ [
593652
+ "cheeseburger",
593653
+ 0
593654
+ ],
593655
+ [
593656
+ "chicken",
593657
+ 0
593658
+ ],
593659
+ [
593660
+ "club",
593661
+ 0
593662
+ ],
593663
+ [
593664
+ "comma",
593665
+ 0
593666
+ ],
593667
+ [
593668
+ "crispy",
593669
+ 0
593670
+ ],
593671
+ [
593672
+ "go",
593673
+ 0
593674
+ ],
593675
+ [
593676
+ "is",
593677
+ 0
593678
+ ],
593679
+ [
593680
+ "junior",
593681
+ 0
593682
+ ],
593683
+ [
593684
+ "list",
593685
+ 0
593686
+ ],
593687
+ [
593688
+ "meal",
593689
+ 0
593690
+ ],
593691
+ [
593692
+ "value",
593693
+ 0
593694
+ ],
593695
+ [
593696
+ "wrap",
593697
+ 0
593698
+ ]
593699
+ ],
593606
593700
  [
593607
593701
  [
593608
593702
  "bacon_cheeseburger",
@@ -594005,6 +594099,24 @@
594005
594099
  0
594006
594100
  ]
594007
594101
  ],
594102
+ [
594103
+ [
594104
+ "is",
594105
+ 0
594106
+ ],
594107
+ [
594108
+ "list",
594109
+ 1
594110
+ ],
594111
+ [
594112
+ "meal",
594113
+ 0
594114
+ ],
594115
+ [
594116
+ "value",
594117
+ 0
594118
+ ]
594119
+ ],
594008
594120
  [
594009
594121
  [
594010
594122
  "is",
@@ -607439,6 +607551,24 @@
607439
607551
  0
607440
607552
  ]
607441
607553
  ],
607554
+ [
607555
+ [
607556
+ "a",
607557
+ 0
607558
+ ],
607559
+ [
607560
+ "is",
607561
+ 0
607562
+ ],
607563
+ [
607564
+ "meal",
607565
+ 0
607566
+ ],
607567
+ [
607568
+ "unknown",
607569
+ 0
607570
+ ]
607571
+ ],
607442
607572
  [
607443
607573
  [
607444
607574
  "a",
@@ -608025,6 +608155,60 @@
608025
608155
  0
608026
608156
  ]
608027
608157
  ],
608158
+ [
608159
+ [
608160
+ "bacon",
608161
+ 0
608162
+ ],
608163
+ [
608164
+ "cheeseburger",
608165
+ 0
608166
+ ],
608167
+ [
608168
+ "chicken",
608169
+ 0
608170
+ ],
608171
+ [
608172
+ "club",
608173
+ 0
608174
+ ],
608175
+ [
608176
+ "comma",
608177
+ 0
608178
+ ],
608179
+ [
608180
+ "crispy",
608181
+ 0
608182
+ ],
608183
+ [
608184
+ "go",
608185
+ 0
608186
+ ],
608187
+ [
608188
+ "is",
608189
+ 0
608190
+ ],
608191
+ [
608192
+ "junior",
608193
+ 0
608194
+ ],
608195
+ [
608196
+ "list",
608197
+ 0
608198
+ ],
608199
+ [
608200
+ "meal",
608201
+ 0
608202
+ ],
608203
+ [
608204
+ "value",
608205
+ 0
608206
+ ],
608207
+ [
608208
+ "wrap",
608209
+ 0
608210
+ ]
608211
+ ],
608028
608212
  [
608029
608213
  [
608030
608214
  "bacon",
@@ -609342,10 +609526,6 @@
609342
609526
  "french",
609343
609527
  0
609344
609528
  ],
609345
- [
609346
- "french_toast_sandwich",
609347
- 0
609348
- ],
609349
609529
  [
609350
609530
  "is",
609351
609531
  0
@@ -609378,6 +609558,10 @@
609378
609558
  "platter",
609379
609559
  0
609380
609560
  ],
609561
+ [
609562
+ "sandwich",
609563
+ 0
609564
+ ],
609381
609565
  [
609382
609566
  "sausage",
609383
609567
  0
@@ -609409,13 +609593,17 @@
609409
609593
  0
609410
609594
  ],
609411
609595
  [
609412
- "egg",
609596
+ "egg_muffin",
609413
609597
  0
609414
609598
  ],
609415
609599
  [
609416
609600
  "french",
609417
609601
  0
609418
609602
  ],
609603
+ [
609604
+ "french_toast_sandwich",
609605
+ 0
609606
+ ],
609419
609607
  [
609420
609608
  "is",
609421
609609
  0
@@ -609448,10 +609636,6 @@
609448
609636
  "platter",
609449
609637
  0
609450
609638
  ],
609451
- [
609452
- "sandwich",
609453
- 0
609454
- ],
609455
609639
  [
609456
609640
  "sausage",
609457
609641
  0
@@ -612007,6 +612191,24 @@
612007
612191
  0
612008
612192
  ]
612009
612193
  ],
612194
+ [
612195
+ [
612196
+ "countable",
612197
+ 0
612198
+ ],
612199
+ [
612200
+ "is",
612201
+ 0
612202
+ ],
612203
+ [
612204
+ "list",
612205
+ 1
612206
+ ],
612207
+ [
612208
+ "strawberry",
612209
+ 0
612210
+ ]
612211
+ ],
612010
612212
  [
612011
612213
  [
612012
612214
  "crispy_chicken",
@@ -612669,6 +612871,10 @@
612669
612871
  [
612670
612872
  "smoothie",
612671
612873
  0
612874
+ ],
612875
+ [
612876
+ "strawberry",
612877
+ 0
612672
612878
  ]
612673
612879
  ],
612674
612880
  [
@@ -612817,6 +613023,24 @@
612817
613023
  0
612818
613024
  ]
612819
613025
  ],
613026
+ [
613027
+ [
613028
+ "is",
613029
+ 0
613030
+ ],
613031
+ [
613032
+ "list",
613033
+ 1
613034
+ ],
613035
+ [
613036
+ "meal",
613037
+ 0
613038
+ ],
613039
+ [
613040
+ "value",
613041
+ 0
613042
+ ]
613043
+ ],
612820
613044
  [
612821
613045
  [
612822
613046
  "is",
@@ -13,7 +13,7 @@ const instance = require('./formulas.instance.json')
13
13
  /*
14
14
  const template = {
15
15
  configs: [
16
- // { query: "x equals y + 4", development: true },
16
+ // { query: "x equals y + 4", scope: "testing" },
17
17
  ]
18
18
  }
19
19
  */
@@ -3,6 +3,7 @@ const { defaultContextCheck } = require('./helpers')
3
3
  const { knowledgeModule, where } = require('./runtime').theprogrammablemind
4
4
  const tokenize = require('./tokenize.js')
5
5
  const gdefaults_tests = require('./gdefaults.test.json')
6
+ const englishHelpers = require('./english_helpers.js')
6
7
  const { getValue, isMany } = require('./helpers.js')
7
8
  const helpers = require('./helpers')
8
9
 
@@ -151,15 +152,28 @@ const config = {
151
152
  {
152
153
  where: where(),
153
154
  priority: -1,
154
- match: ({context}) => context.evaluateWord && context.paraphrase && context.word && (context.number == 'many' || countext.number > 1),
155
+ match: ({context}) => context.evaluateWord && context.paraphrase && context.word && (context.number == 'many' || context.number > 1),
155
156
  apply: ({context}) => pluralize.plural(context.word),
156
157
  },
157
158
 
159
+ {
160
+ where: where(),
161
+ priority: -1,
162
+ match: ({context}) => context.evaluateWord && context.isVerb && context.paraphrase && context.word && context.number == 'one' && !context.imperative,
163
+ apply: ({context}) => {
164
+ const infinitive = englishHelpers.getInfinitive(context.word)
165
+ const cases = englishHelpers.conjugateVerb(infinitive)
166
+ return pluralize.plural(context.word)
167
+ },
168
+ },
169
+
158
170
  {
159
171
  where: where(),
160
172
  priority: -1,
161
173
  match: ({context}) => context.evaluateWord && context.paraphrase && context.word && context.number == 'one',
162
- apply: ({context}) => pluralize.singular(context.word),
174
+ apply: ({context}) => {
175
+ return pluralize.singular(context.word)
176
+ },
163
177
  },
164
178
 
165
179
  {
@@ -277,6 +291,9 @@ const initializer = ({config}) => {
277
291
  let value = element
278
292
  if (element.property) {
279
293
  value = context[element.property]
294
+ if (element.context) {
295
+ Object.assign(value, element.context)
296
+ }
280
297
  }
281
298
  if (value) {
282
299
  strings.push(separator)
package/common/help.js CHANGED
@@ -77,7 +77,7 @@ const config = {
77
77
  words: {
78
78
  "literals": {
79
79
  // "km1": { "the": [{"id": "the", "initial": "{ modifiers: [] }" }],
80
- 'km1': [{id: "km", initial: "{ value: 'km1', word: 'km1' }", development: true }],
80
+ 'km1': [{id: "km", initial: "{ value: 'km1', word: 'km1' }", scope: "testing" }],
81
81
  }
82
82
  },
83
83
  };
@@ -65,7 +65,7 @@ const translationMapping = (from, to) => {
65
65
  if (matchField) {
66
66
  let found = false
67
67
  const todo = Object.keys(to).map( (key) => [key] )
68
- while (!found) {
68
+ while (!found && todo.length > 0) {
69
69
  const tkey = todo.shift()
70
70
  const tvalue = hashIndexesGet(to, tkey);
71
71
  const fvalue = hashIndexesGet(from, [fkey]);