ekms 8.9.0-beta.0 → 8.9.0-beta.10
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/countable.js +8 -2
- package/common/countable.test.json +586 -0
- package/common/crew.instance.json +176 -0
- package/common/fastfood.instance.json +270 -74
- package/common/hierarchy.js +5 -5
- package/common/hierarchy.test.json +1491 -0
- package/common/pipboy.instance.json +28 -28
- package/common/pipboy.js +0 -1
- package/common/reports.instance.json +1 -1
- package/common/ui.instance.json +125 -0
- package/common/ui.js +12 -5
- package/common/wp.instance.json +7379 -0
- package/common/wp.js +95 -0
- package/common/wp.test.json +7437 -0
- package/main.js +2 -0
- package/package.json +6 -2
package/common/wp.js
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
const { knowledgeModule, where, Digraph } = require('./runtime').theprogrammablemind
|
2
|
+
const { defaultContextCheck } = require('./helpers')
|
3
|
+
const helpers = require("./helpers")
|
4
|
+
const ui = require("./ui")
|
5
|
+
const countable = require("./countable")
|
6
|
+
const colors = require("./colors")
|
7
|
+
const errors = require("./errors")
|
8
|
+
const wp_tests = require('./wp.test.json')
|
9
|
+
const instance = require('./wp.instance.json')
|
10
|
+
|
11
|
+
/*
|
12
|
+
start inserting text until I say banana
|
13
|
+
...
|
14
|
+
or
|
15
|
+
stop inserting text
|
16
|
+
|
17
|
+
make the text of the 1st to 3rd paragraphs blue
|
18
|
+
|
19
|
+
*/
|
20
|
+
|
21
|
+
class API {
|
22
|
+
initialize({ objects }) {
|
23
|
+
this._objects = objects
|
24
|
+
}
|
25
|
+
|
26
|
+
changeColor({ unit, scope, color }) {
|
27
|
+
this._objects.changeColor = { unit, scope, color }
|
28
|
+
}
|
29
|
+
}
|
30
|
+
|
31
|
+
const api = new API()
|
32
|
+
|
33
|
+
let config = {
|
34
|
+
name: 'wp',
|
35
|
+
operators: [
|
36
|
+
// TODO write a parser for this so I can use statefulElement as the id
|
37
|
+
"([changeState|make] ([statefulelement]) ([stateValue|]))",
|
38
|
+
],
|
39
|
+
bridges: [
|
40
|
+
{
|
41
|
+
id: 'changeState',
|
42
|
+
parents: ['verb'],
|
43
|
+
bridge: "{ ...next(operator), element: after[0], state: after[1], operator: operator, generate: ['operator', 'element', 'state'] }",
|
44
|
+
semantic: ({api, context}) => {
|
45
|
+
const unit = context.element.marker
|
46
|
+
const scope = context.element.quantity.quantity
|
47
|
+
const color = context.state.value.split('_')[0]
|
48
|
+
api.changeColor({ unit, scope, color })
|
49
|
+
}
|
50
|
+
},
|
51
|
+
{
|
52
|
+
id: 'statefulelement',
|
53
|
+
},
|
54
|
+
{
|
55
|
+
id: 'stateValue',
|
56
|
+
children: ['color_colors'],
|
57
|
+
},
|
58
|
+
],
|
59
|
+
semantics: [
|
60
|
+
]
|
61
|
+
};
|
62
|
+
|
63
|
+
template = {
|
64
|
+
configs: [
|
65
|
+
'words are countable and statefulElements',
|
66
|
+
'characters are countable',
|
67
|
+
'paragraphs are countable',
|
68
|
+
],
|
69
|
+
}
|
70
|
+
|
71
|
+
knowledgeModule({
|
72
|
+
config,
|
73
|
+
includes: [ui, countable, colors, errors],
|
74
|
+
api: () => new API(),
|
75
|
+
|
76
|
+
module,
|
77
|
+
description: 'Word processor',
|
78
|
+
test: {
|
79
|
+
name: './wp.test.json',
|
80
|
+
contents: wp_tests,
|
81
|
+
checks: {
|
82
|
+
context: [
|
83
|
+
...defaultContextCheck(),
|
84
|
+
],
|
85
|
+
objects: [
|
86
|
+
'changeColor',
|
87
|
+
{ km: 'ui' },
|
88
|
+
],
|
89
|
+
},
|
90
|
+
},
|
91
|
+
template: {
|
92
|
+
template,
|
93
|
+
instance,
|
94
|
+
}
|
95
|
+
})
|