ekms 8.9.0-beta.9 → 8.9.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 (37) hide show
  1. package/common/animals.instance.json +65 -0
  2. package/common/articles.js +4 -0
  3. package/common/colors.instance.json +71 -0
  4. package/common/comparable.instance.json +15 -0
  5. package/common/conjunction.js +27 -18
  6. package/common/crew.instance.json +130 -176
  7. package/common/dialogues.js +14 -11
  8. package/common/dimension.instance.json +10 -0
  9. package/common/edible.instance.json +320 -0
  10. package/common/emotions.instance.json +8 -0
  11. package/common/fastfood.instance.json +1200 -308
  12. package/common/formulas.instance.json +10 -0
  13. package/common/helpers/conjunction.js +75 -0
  14. package/common/helpers/dialogues.js +14 -8
  15. package/common/helpers/properties.js +2 -2
  16. package/common/helpers.js +29 -0
  17. package/common/kirk.instance.json +5 -0
  18. package/common/length.instance.json +150 -0
  19. package/common/math.instance.json +10 -0
  20. package/common/meta.js +5 -3
  21. package/common/ordering.instance.json +78 -0
  22. package/common/people.instance.json +169 -4
  23. package/common/pipboy.instance.json +170 -0
  24. package/common/pokemon.instance.json +65 -0
  25. package/common/pos.js +9 -6
  26. package/common/pressure.instance.json +40 -0
  27. package/common/properties.instance.json +5 -0
  28. package/common/reports.instance.json +21 -1
  29. package/common/spock.instance.json +5 -0
  30. package/common/temperature.instance.json +40 -0
  31. package/common/ui.instance.json +10 -0
  32. package/common/ui.js +0 -1
  33. package/common/weight.instance.json +120 -0
  34. package/common/wp.instance.json +23224 -536
  35. package/common/wp.js +175 -30
  36. package/common/wp.test.json +35630 -1554
  37. package/package.json +3 -2
package/common/wp.js CHANGED
@@ -16,15 +16,65 @@ const instance = require('./wp.instance.json')
16
16
 
17
17
  make the text of the 1st to 3rd paragraphs blue
18
18
 
19
+
20
+ make every word bold and underlines and blue -> weirdly "bold underlined and blue" works
21
+
22
+ make the font ...
23
+ make the color blue
24
+ make the color of the first paragraph blue
25
+
26
+ words that start with a
27
+ make all the bold text uppercase
28
+ underline all the bold text
29
+ underline all the text
30
+ underline everything
31
+ 4 letter word
32
+ 4 to 6 letter word
33
+ word with 'a' in it
34
+ words containing a
35
+ every 5th word
36
+
37
+ in the first paragraph make the words that start with abc bold
38
+ bold the first three words that start with t
39
+ bold much and many
40
+ make the words that start with t bold and underlined
19
41
  */
20
42
 
21
43
  class API {
22
44
  initialize({ objects }) {
23
45
  this._objects = objects
46
+ this._objects.changeState = []
24
47
  }
25
48
 
26
- changeColor({ unit, scope, color }) {
27
- this._objects.changeColor = { unit, scope, color }
49
+ changeState(value) {
50
+ this._objects.changeState.push(value)
51
+ }
52
+ }
53
+
54
+ const root = (id) => {
55
+ return id.split('_')[0]
56
+ }
57
+
58
+ const setUpdate = (isA, update, states) => {
59
+ let color;
60
+ const styles = []
61
+ for (const state of states) {
62
+ if (isA(state, 'style_wp')) {
63
+ if (!update.styles) {
64
+ update.styles = []
65
+ }
66
+ let style = root(state.value)
67
+ /*
68
+ if (style == 'underlined') {
69
+ style = 'underline'
70
+ } else if (style == 'italicize') {
71
+ style = 'italic'
72
+ }
73
+ */
74
+ update.styles.push(style)
75
+ } else {
76
+ update.color = root(state.value)
77
+ }
28
78
  }
29
79
  }
30
80
 
@@ -32,40 +82,135 @@ const api = new API()
32
82
 
33
83
  let config = {
34
84
  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
85
  };
62
86
 
87
+ const changeState = ({api, isA, context, toArray, element, state}) => {
88
+ let unit = root(context.element.marker)
89
+ let scope
90
+ let conditions = []
91
+ if (isA(context.element, 'everything')) {
92
+ scope = 'all'
93
+ } else if (context.element.condition) {
94
+ const condition = context.element.condition
95
+ if (condition.marker == 'wordComparison_wp') {
96
+ const letters = condition.letters.letters.text
97
+ conditions.push({ comparison: condition.comparison, letters })
98
+ }
99
+ } else {
100
+ scope = context.element.quantity.quantity
101
+ }
102
+ const update = { unit, scope, conditions }
103
+ setUpdate(isA, update, toArray(context.state))
104
+ api.changeState(update)
105
+ }
106
+
63
107
  template = {
64
108
  configs: [
109
+ 'setidsuffix _wp',
65
110
  'words are countable and statefulElements',
66
111
  'characters are countable',
67
112
  'paragraphs are countable',
68
- ],
113
+ 'bold, italic, code, capitalize, lowercase and underline are styles',
114
+ 'underlined means underline',
115
+ 'capitalized means capitalize',
116
+ 'uppercase means capitalize',
117
+ 'italicize means italic',
118
+ 'italicized means italic',
119
+ // 'start end and contain are wordComparisons',
120
+ // 'styles are negatable',
121
+ "resetIdSuffix",
122
+ {
123
+ operators: [
124
+ "([changeState_wp|make] ([statefulElement_wp]) ([stateValue_wp|]))",
125
+ "((style_wp/*) [applyStyle_wp] ([statefulElement_wp|]))",
126
+ "((word_wp/*) [wordComparison_wp] ([startsWith_wp|with] (a/0)? (letters)))",
127
+ ],
128
+ bridges: [
129
+ {
130
+ id: 'wordComparison_wp',
131
+ parents: ['verb'],
132
+ words: [
133
+ { word: 'start', comparison: 'prefix' },
134
+ { word: 'starts', comparison: 'prefix', },
135
+ { word: 'end', comparison: 'suffix' },
136
+ { word: 'ends', comparison: 'suffix' },
137
+ { word: 'contain', comparison: 'include' },
138
+ { word: 'contains', comparison: 'include' },
139
+ { word: 'include', comparison: 'include' },
140
+ { word: 'includes', comparison: 'include' },
141
+ ],
142
+ bridge: "{ ...next(operator), element: before[0], subject: before[0], letters: after[0], verb: operator, generate: ['element', 'verb', 'letters'] }",
143
+ },
144
+ {
145
+ id: 'startsWith_wp',
146
+ parents: ['preposition'],
147
+ optional: {
148
+ 1: "{ marker: 'a' }",
149
+ },
150
+ bridge: "{ ...next(operator), operator: operator, letters: after[1], generate: ['operator', 'letters'] }",
151
+ },
152
+ {
153
+ id: 'applyStyle_wp',
154
+ parents: ['verb'],
155
+ convolution: true,
156
+ bridge: "{ ...next(operator), element: after[0], state: before[0], operator: operator, generate: ['state', 'element'] }",
157
+ localHierarchy: [
158
+ ['thisitthat', 'statefulElement_wp'],
159
+ ['everything', 'statefulElement_wp'],
160
+ ],
161
+ semantic: (args) => {
162
+ changeState({...args, element: args.context.element, state: args.context.state})
163
+ }
164
+ },
165
+ {
166
+ id: 'changeState_wp',
167
+ parents: ['verb'],
168
+ bridge: "{ ...next(operator), element: after[0], state: after[1], operator: operator, generate: ['operator', 'element', 'state'] }",
169
+ localHierarchy: [
170
+ ['thisitthat', 'statefulElement_wp'],
171
+ ['everything', 'statefulElement_wp'],
172
+ ],
173
+ semantic: (args) => {
174
+ changeState({...args, element: args.context.element, state: args.context.state})
175
+ }
176
+ },
177
+ {
178
+ id: 'stateValue_wp',
179
+ children: ['color_colors', 'style_wp'],
180
+ },
181
+ ],
182
+ semantics: [
183
+ {
184
+ where: where(),
185
+ match: ({context, isA}) => isA(context, 'style_wp') && !context.same && !context.isResponse && !context.evaluate,
186
+ apply: ({context, api, isA, toArray}) => {
187
+ const update = { scope: 'selection' }
188
+ setUpdate(isA, update, toArray(context))
189
+ api.changeState(update)
190
+ }
191
+ },
192
+ {
193
+ where: where(),
194
+ match: ({context, isA}) => isA(context, 'statefulElement_wp') && !context.same && !context.isResponse && !context.evaluate,
195
+ apply: ({context, api, isA, toArray}) => {
196
+ const unit = root(context.marker)
197
+ let scope
198
+ if (context.quantity) {
199
+ scope = context.quantity.quantity
200
+ }
201
+ // TODO set default scope for "every word bold underlined etc"
202
+ }
203
+ },
204
+ ],
205
+ priorities: [
206
+ { "context": [['changeState_wp',0], ['statefulElement_wp', 0], ['list', 0]], ordered: true, choose: [0] },
207
+ { "context": [['startsWith_wp',0], ['unknown', 0], ['list', 1]], ordered: true, choose: [0] },
208
+ ],
209
+ },
210
+ // "([changeState_wp|make] ([statefulElement_wp]) ([stateValue_wp|]))",
211
+ // "((style_wp/*) [applyStyle_wp] ([statefulElement_wp|]))",
212
+ // "x statefulElement_wp y means y changeState_wp x",
213
+ ]
69
214
  }
70
215
 
71
216
  knowledgeModule({
@@ -83,7 +228,7 @@ knowledgeModule({
83
228
  ...defaultContextCheck(),
84
229
  ],
85
230
  objects: [
86
- 'changeColor',
231
+ 'changeState',
87
232
  { km: 'ui' },
88
233
  ],
89
234
  },