ekms 8.0.0-beta.7 → 8.0.0-beta.70
Sign up to get free protection for your applications and to get access to all the features.
- package/common/animals.instance.json +2871 -1379
- package/common/animals.js +17 -20
- package/common/articles.js +103 -0
- package/common/articles.test.json +310 -0
- package/common/avatar.js +5 -9
- package/common/characters.js +22 -28
- package/common/colors.instance.json +7170 -3657
- package/common/colors.js +4 -8
- package/common/colors.test.json +345 -780
- package/common/comparable.instance.json +1750 -0
- package/common/comparable.js +36 -28
- package/common/comparable.test.json +438 -2
- package/common/concept.js +120 -118
- package/common/countable.js +19 -13
- package/common/countable.test.json +1050 -0
- package/common/crew.instance.json +13066 -6469
- package/common/crew.js +36 -41
- package/common/crew.test.json +714 -452
- package/common/currency.js +27 -45
- package/common/dialogues.js +161 -285
- package/common/dimension.instance.json +474 -253
- package/common/dimension.js +16 -22
- package/common/dimension.test.json +446 -1640
- package/common/edible.instance.json +20053 -10093
- package/common/edible.js +3 -8
- package/common/emotions.instance.json +147 -69
- package/common/emotions.js +35 -38
- package/common/evaluate.instance.json +2 -0
- package/common/evaluate.js +49 -0
- package/common/evaluate.test.json +574 -0
- package/common/events.js +10 -14
- package/common/fastfood.instance.json +221166 -111223
- package/common/fastfood.js +75 -85
- package/common/fastfood.test.json +268 -90
- package/common/formulas.instance.json +455 -249
- package/common/formulas.js +19 -26
- package/common/gdefaults.js +24 -26
- package/common/help.js +7 -12
- package/common/help.test.json +63 -8
- package/common/helpers/concept.js +10 -7
- package/common/helpers/dialogues.js +2 -3
- package/common/helpers/properties.js +54 -62
- package/common/helpers.js +6 -5
- package/common/hierarchy.js +16 -24
- package/common/javascript.js +11 -18
- package/common/kirk.instance.json +584 -290
- package/common/kirk.js +5 -8
- package/common/length.instance.json +8834 -4757
- package/common/length.js +4 -8
- package/common/listener.js +48 -0
- package/common/listener.test.json +104 -0
- package/common/math.instance.json +425 -1187
- package/common/math.js +16 -20
- package/common/meta.js +23 -47
- package/common/nameable.instance.json +2 -0
- package/common/nameable.js +144 -0
- package/common/nameable.test.json +3191 -0
- package/common/negation.instance.json +2 -0
- package/common/negation.js +38 -0
- package/common/negation.test.json +308 -0
- package/common/numbers.js +27 -31
- package/common/ordering.instance.json +366 -246
- package/common/ordering.js +80 -86
- package/common/people.instance.json +2074 -1022
- package/common/people.js +8 -13
- package/common/percentages.instance.json +2 -0
- package/common/percentages.js +53 -0
- package/common/percentages.test.json +751 -0
- package/common/pipboy.instance.json +11745 -6329
- package/common/pipboy.js +48 -59
- package/common/pokemon.instance.json +4226 -2081
- package/common/pokemon.js +7 -20
- package/common/pos.js +15 -13
- package/common/pressure.instance.json +2208 -1175
- package/common/pressure.js +4 -8
- package/common/properties.instance.json +131 -61
- package/common/properties.js +57 -134
- package/common/punctuation.js +15 -7
- package/common/reports.instance.json +1018 -530
- package/common/reports.js +77 -100
- package/common/reports.test.json +15623 -10458
- package/common/scorekeeper.js +18 -30
- package/common/sdefaults.js +16 -7
- package/common/sizeable.js +6 -10
- package/common/spock.instance.json +584 -290
- package/common/spock.js +5 -8
- package/common/stgame.js +19 -19
- package/common/stm.js +164 -27
- package/common/stm.test.json +1734 -1
- package/common/tell.js +14 -18
- package/common/temperature.instance.json +2271 -1222
- package/common/temperature.js +4 -8
- package/common/tester.js +15 -4
- package/common/testing.js +8 -12
- package/common/time.js +20 -25
- package/common/tokenize.js +5 -6
- package/common/ui.instance.json +459 -240
- package/common/ui.js +16 -22
- package/common/weight.instance.json +7646 -4026
- package/common/weight.js +4 -8
- package/common/yesno.js +5 -5
- package/main.js +14 -2
- package/package.json +28 -5
package/common/concept.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
const {
|
1
|
+
const { knowledgeModule, flatten, where, Digraph } = require('./runtime').theprogrammablemind
|
2
2
|
const { defaultContextCheck } = require('./helpers')
|
3
3
|
const { API }= require('./helpers/concept')
|
4
4
|
const dialogues = require('./dialogues.js')
|
@@ -14,135 +14,137 @@ const concept_instance = require('./concept.instance.json')
|
|
14
14
|
plain and regular fries mean the same thing
|
15
15
|
*/
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
{
|
48
|
-
"
|
49
|
-
|
50
|
-
|
51
|
-
"word": "water"
|
52
|
-
},
|
53
|
-
"marker": "water_type",
|
54
|
-
"modifiers": [
|
55
|
-
"water"
|
56
|
-
],
|
57
|
-
"types": [
|
58
|
-
"water_type"
|
59
|
-
],
|
60
|
-
"value": "water_type",
|
61
|
-
"word": "type",
|
62
|
-
"paraphrase": true
|
17
|
+
config = {
|
18
|
+
name: 'concept',
|
19
|
+
operators: [
|
20
|
+
"((context.punctuation != true)* [modifies|] (concept))",
|
21
|
+
"([concept])",
|
22
|
+
"([literally] (modifies/0))",
|
23
|
+
],
|
24
|
+
bridges: [
|
25
|
+
{
|
26
|
+
id: "modifies",
|
27
|
+
isA: ['verb'],
|
28
|
+
words: [{ word: 'modifies', number: 'one', flatten: false }, { word: 'modify', number: 'many', flatten: true }],
|
29
|
+
// bridge: "{ ...next(operator), modifiers: before, concept: after[0], flatten: true }"
|
30
|
+
bridge: "{ ...next(operator), modifiers: before, concept: after[0] }"
|
31
|
+
},
|
32
|
+
{ id: "literally", bridge: "{ ...after[0], flatten: false, literally: true }" },
|
33
|
+
{ id: "concept", bridge: "{ ...next(operator) }" },
|
34
|
+
],
|
35
|
+
priorities: [
|
36
|
+
{ "context": [['literally', 0], ['modifies', 0], ], "choose": [0] },
|
37
|
+
],
|
38
|
+
hierarchy: [
|
39
|
+
['concept', 'theAble'],
|
40
|
+
['concept', 'queryable'],
|
41
|
+
],
|
42
|
+
generators: [
|
43
|
+
{
|
44
|
+
notes: '"fire type, water type and earth type" to "fire water and earth type"',
|
45
|
+
/*
|
46
|
+
{
|
47
|
+
"water": {
|
48
|
+
"marker": "water",
|
49
|
+
"value": "water",
|
50
|
+
"word": "water"
|
63
51
|
},
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
return
|
75
|
-
}
|
76
|
-
if (!context.value[0].word) {
|
77
|
-
return
|
78
|
-
}
|
79
|
-
const word = context.value[0].word
|
80
|
-
|
81
|
-
for (let value of context.value) {
|
82
|
-
if (!(value.modifiers && value.modifiers.length == 1 && value.word == word)) {
|
83
|
-
return
|
84
|
-
}
|
85
|
-
}
|
86
|
-
return true
|
52
|
+
"marker": "water_type",
|
53
|
+
"modifiers": [
|
54
|
+
"water"
|
55
|
+
],
|
56
|
+
"types": [
|
57
|
+
"water_type"
|
58
|
+
],
|
59
|
+
"value": "water_type",
|
60
|
+
"word": "type",
|
61
|
+
"paraphrase": true
|
87
62
|
},
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
context.modifier = {
|
94
|
-
marker: 'list',
|
95
|
-
paraphrase: true,
|
96
|
-
value: modifiers
|
97
|
-
}
|
98
|
-
context.paraphrase = true
|
99
|
-
return g(context)
|
63
|
+
*/
|
64
|
+
where: where(),
|
65
|
+
match: ({context}) => {
|
66
|
+
if (!context.paraphrase) {
|
67
|
+
return
|
100
68
|
}
|
101
|
-
|
102
|
-
|
103
|
-
where: where(),
|
104
|
-
match: ({context}) => context.marker == 'modifies' && context.paraphrase,
|
105
|
-
apply: ({context, gp, gw}) => {
|
106
|
-
if (context.literally) {
|
107
|
-
return `${context.modifiers.map(gp).join(" ")} literally ${gw(context, { number: context.modifiers[context.modifiers.length - 1] })} ${gp(context.concept)}`
|
108
|
-
} else {
|
109
|
-
return `${context.modifiers.map(gp).join(" ")} ${gw(context, { number: context.modifiers[context.modifiers.length - 1] })} ${gp(context.concept)}`
|
110
|
-
}
|
69
|
+
if (context.marker !== 'list') {
|
70
|
+
return
|
111
71
|
}
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
literalModifiers = context.modifiers[0]
|
124
|
-
modifiers = literalModifiers.value.map(modifier => modifier.value)
|
125
|
-
modifiers = modifiers.slice(0, -1).concat([literalModifiers.marker]).concat(modifiers.slice(-1))
|
126
|
-
} else {
|
127
|
-
modifiers = context.modifiers.map(modifier => modifier.value)
|
72
|
+
if ((context.value || []).length < 2) {
|
73
|
+
return
|
74
|
+
}
|
75
|
+
if (!context.value[0].word) {
|
76
|
+
return
|
77
|
+
}
|
78
|
+
const word = context.value[0].word
|
79
|
+
|
80
|
+
for (let value of context.value) {
|
81
|
+
if (!(value.modifiers && value.modifiers.length == 1 && value.word == word)) {
|
82
|
+
return
|
128
83
|
}
|
129
|
-
// km('concept').api.kindOfConcept({ config, modifiers, object: context.concept.value || context.concept.marker })
|
130
|
-
km('concept').api.kindOfConcept({ config, modifiers, object: context.concept })
|
131
84
|
}
|
85
|
+
return true
|
132
86
|
},
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
87
|
+
apply: async ({g, context}) => {
|
88
|
+
const modifiers = context.value.map( (p) => p[p.modifiers[0]] )
|
89
|
+
context.word = context.value[0].word
|
90
|
+
context.value = null
|
91
|
+
context.modifiers = ['modifier']
|
92
|
+
context.modifier = {
|
93
|
+
marker: 'list',
|
94
|
+
paraphrase: true,
|
95
|
+
value: modifiers
|
96
|
+
}
|
97
|
+
context.paraphrase = true
|
98
|
+
return await g(context)
|
99
|
+
}
|
100
|
+
},
|
101
|
+
{
|
102
|
+
where: where(),
|
103
|
+
match: ({context}) => context.marker == 'modifies' && context.paraphrase,
|
104
|
+
apply: async ({context, gp, gw}) => {
|
105
|
+
const modifiers = []
|
106
|
+
for (modifier of context.modifiers) {
|
107
|
+
modifiers.push(await gp(modifier))
|
108
|
+
}
|
109
|
+
if (context.literally) {
|
110
|
+
return `${modifiers.join(" ")} literally ${await gw(context, { number: context.modifiers[context.modifiers.length - 1] })} ${await gp(context.concept)}`
|
111
|
+
} else {
|
112
|
+
return `${modifiers.join(" ")} ${await gw(context, { number: context.modifiers[context.modifiers.length - 1] })} ${await gp(context.concept)}`
|
113
|
+
}
|
114
|
+
}
|
115
|
+
// const chosen = chooseNumber(context, word.singular, word.plural)
|
116
|
+
},
|
117
|
+
],
|
118
|
+
semantics: [
|
119
|
+
{
|
120
|
+
notes: 'define a modifier',
|
121
|
+
where: where(),
|
122
|
+
match: ({context}) => context.marker == 'modifies',
|
123
|
+
apply: ({config, query, km, context}) => {
|
124
|
+
let modifiers
|
125
|
+
if (context.literally) {
|
126
|
+
literalModifiers = context.modifiers[0]
|
127
|
+
// modifiers = literalModifiers.value.map(modifier => modifier.value)
|
128
|
+
modifiers = literalModifiers.value
|
129
|
+
modifiers = modifiers.slice(0, -1).concat([literalModifiers.marker]).concat(modifiers.slice(-1))
|
130
|
+
} else {
|
131
|
+
modifiers = context.modifiers
|
132
|
+
// modifiers = context.modifiers.map(modifier => modifier.value)
|
133
|
+
}
|
134
|
+
// km('concept').api.kindOfConcept({ config, modifiers, object: context.concept.value || context.concept.marker })
|
135
|
+
km('concept').api.kindOfConcept({ config, modifiers, object: context.concept })
|
136
|
+
}
|
137
|
+
},
|
138
|
+
],
|
140
139
|
}
|
141
140
|
|
142
141
|
knowledgeModule({
|
142
|
+
config,
|
143
|
+
includes: [dialogues],
|
144
|
+
api: () => new API(),
|
145
|
+
|
143
146
|
module,
|
144
147
|
description: 'The idea of a concept whatever that might end up being',
|
145
|
-
createConfig,
|
146
148
|
test: {
|
147
149
|
name: './concept.test.json',
|
148
150
|
contents: concept_tests,
|
package/common/countable.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
const {
|
1
|
+
const { knowledgeModule, where, Digraph } = require('./runtime').theprogrammablemind
|
2
2
|
const { defaultContextCheck } = require('./helpers')
|
3
3
|
const dialogues = require("./hierarchy")
|
4
4
|
const numbers = require("./numbers")
|
@@ -11,12 +11,14 @@ const countable_tests = require('./countable.test.json')
|
|
11
11
|
2 6 and 3 10 piece nuggets
|
12
12
|
*/
|
13
13
|
|
14
|
-
let
|
14
|
+
let config = {
|
15
15
|
name: 'countable',
|
16
16
|
operators: [
|
17
17
|
"(([quantifier|]) [counting] ([countable]))",
|
18
18
|
"(([number|]) [countOfPieces|] ([piece]))",
|
19
19
|
"((countOfPieces/*) [countingPieces] ([hasCountOfPieces]))",
|
20
|
+
"([more] (countable/*))",
|
21
|
+
"([less] (countable/*))",
|
20
22
|
"([all])",
|
21
23
|
// everything
|
22
24
|
],
|
@@ -24,7 +26,7 @@ let configStruct = {
|
|
24
26
|
{
|
25
27
|
id: "counting",
|
26
28
|
convolution: true,
|
27
|
-
before: ['
|
29
|
+
before: ['verb'],
|
28
30
|
bridge: "{ ...after, modifiers: append(['quantity'], after[0].modifiers), quantity: before[0], number: default(before[0].number, before[0].value), instance: true }"
|
29
31
|
},
|
30
32
|
{
|
@@ -44,6 +46,14 @@ let configStruct = {
|
|
44
46
|
{
|
45
47
|
id: "piece",
|
46
48
|
},
|
49
|
+
{
|
50
|
+
id: "more",
|
51
|
+
bridge: "{ ...next(after[0]), more: operator, modifiers: append(['more'], after[0].modifiers) }",
|
52
|
+
},
|
53
|
+
{
|
54
|
+
id: "less",
|
55
|
+
bridge: "{ ...next(after[0]), less: operator, modifiers: append(['less'], after[0].modifiers) }",
|
56
|
+
},
|
47
57
|
{
|
48
58
|
id: "quantifier",
|
49
59
|
children: ['number', 'all'],
|
@@ -63,28 +73,24 @@ let configStruct = {
|
|
63
73
|
{
|
64
74
|
where: where(),
|
65
75
|
match: ({context}) => false && context.quantity,
|
66
|
-
apply: ({context, g}) => {
|
76
|
+
apply: async ({context, g}) => {
|
67
77
|
let number = context.quantity.number || 'one'
|
68
78
|
if (context.quantity.value > 1) {
|
69
79
|
number = 'many'
|
70
80
|
}
|
71
|
-
const countable = g({ ...context, quantity: undefined, number})
|
72
|
-
return `${g(context.quantity)} ${countable}`
|
81
|
+
const countable = await g({ ...context, quantity: undefined, number})
|
82
|
+
return `${await g(context.quantity)} ${countable}`
|
73
83
|
}
|
74
84
|
},
|
75
85
|
]
|
76
86
|
};
|
77
87
|
|
78
|
-
const createConfig = () => {
|
79
|
-
const config = new Config(configStruct, module)
|
80
|
-
config.add(dialogues(), numbers())
|
81
|
-
return config
|
82
|
-
}
|
83
|
-
|
84
88
|
knowledgeModule({
|
89
|
+
config,
|
90
|
+
includes: [dialogues, numbers],
|
91
|
+
|
85
92
|
module,
|
86
93
|
description: 'Countable things',
|
87
|
-
createConfig,
|
88
94
|
test: {
|
89
95
|
name: './countable.test.json',
|
90
96
|
contents: countable_tests,
|