tpmkms_4wp 8.9.0-beta.2 → 8.9.0-beta.20

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