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.
- package/common/asking.js +4 -4
- package/common/characters.js +2 -2
- package/common/crew.instance.json +47 -61
- package/common/crew.test.json +4148 -3324
- package/common/dialogues.js +1 -1
- package/common/dimension.instance.json +8 -8
- package/common/dimension.js +4 -4
- package/common/edible.instance.json +72 -0
- package/common/emotions.instance.json +26 -0
- package/common/emotions.test.json +242 -174
- package/common/english_helpers.js +126 -0
- package/common/errors.js +3 -3
- package/common/evaluate.js +2 -2
- package/common/events.js +8 -8
- package/common/fastfood.instance.json +242 -18
- package/common/formulas.js +1 -1
- package/common/gdefaults.js +19 -2
- package/common/help.js +1 -1
- package/common/helpers/meta.js +1 -1
- package/common/helpers/properties.js +91 -49
- package/common/helpers.js +53 -0
- package/common/latin.instance.json +2 -2
- package/common/latin.js +4 -4
- package/common/listener.js +1 -1
- package/common/math.instance.json +8 -8
- package/common/math.js +4 -4
- package/common/meta.js +27 -27
- package/common/nameable.js +7 -7
- package/common/ordering.instance.json +78 -0
- package/common/ordering.test.json +663 -233
- package/common/people.instance.json +26 -12
- package/common/people.js +5 -3
- package/common/people.test.json +4071 -3813
- package/common/pipboy.js +2 -3
- package/common/properties.js +6 -1
- package/common/reminders.instance.json +4 -4
- package/common/reminders.js +2 -2
- package/common/reports.instance.json +2 -2
- package/common/scorekeeper.js +2 -2
- package/common/stm.js +2 -2
- package/common/tokenize.js +4 -1
- package/common/wp.instance.json +74 -2
- 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]))",
|
|
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
|
-
|
|
15
|
+
scope: "testing"
|
|
16
16
|
},
|
|
17
|
-
{ id: "dropable",
|
|
17
|
+
{ id: "dropable", scope: "testing" },
|
|
18
18
|
],
|
|
19
19
|
semantics: [
|
|
20
20
|
{
|
package/common/evaluate.js
CHANGED
|
@@ -8,7 +8,7 @@ const config = {
|
|
|
8
8
|
name: 'evaluate',
|
|
9
9
|
operators: [
|
|
10
10
|
"([evaluate] (value))",
|
|
11
|
-
{ pattern: "([value1])",
|
|
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
|
-
|
|
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])",
|
|
28
|
-
{ pattern: "([action1])",
|
|
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) }",
|
|
66
|
-
{ id: "action1", level: 0, bridge: "{ ...next(operator) }",
|
|
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',
|
|
70
|
-
{ child: 'action1', parent: 'action',
|
|
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
|
-
|
|
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
|
-
|
|
93
|
+
scope: "testing",
|
|
94
94
|
where: where(),
|
|
95
95
|
match: ({context, isA}) => context.marker == 'action1',
|
|
96
96
|
apply: ({context, kms}) => {
|
package/common/formulas.js
CHANGED
package/common/gdefaults.js
CHANGED
|
@@ -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' ||
|
|
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}) =>
|
|
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' }",
|
|
80
|
+
'km1': [{id: "km", initial: "{ value: 'km1', word: 'km1' }", scope: "testing" }],
|
|
81
81
|
}
|
|
82
82
|
},
|
|
83
83
|
};
|
package/common/helpers/meta.js
CHANGED
|
@@ -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]);
|