tpmkms_4wp 8.9.1-beta.4 → 8.9.1-beta.40

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 (137) hide show
  1. package/common/animals.instance.json +6736 -831
  2. package/common/articles.js +22 -9
  3. package/common/articles.test.json +640 -2
  4. package/common/asking.js +3 -3
  5. package/common/asking.test.json +1599 -140
  6. package/common/avatar.js +9 -1
  7. package/common/avatar.test.json +6008 -2749
  8. package/common/characters.js +1 -1
  9. package/common/characters.test.json +1371 -95
  10. package/common/colors.instance.json +23062 -1689
  11. package/common/colors.test.json +704 -136
  12. package/common/comparable.instance.json +1337 -159
  13. package/common/comparable.js +13 -13
  14. package/common/comparable.test.json +3239 -558
  15. package/common/concept.js +11 -3
  16. package/common/concept.test.json +2853 -694
  17. package/common/conjunction.js +13 -1
  18. package/common/conjunction.test.json +229 -1
  19. package/common/countable.js +3 -9
  20. package/common/countable.test.json +1310 -638
  21. package/common/crew.instance.json +19486 -2159
  22. package/common/crew.js +19 -0
  23. package/common/crew.test.json +10218 -2145
  24. package/common/currency.js +2 -3
  25. package/common/currency.test.json +948 -64
  26. package/common/dialogues.js +103 -35
  27. package/common/dialogues.test.json +6611 -1905
  28. package/common/dimension.instance.json +760 -120
  29. package/common/dimension.js +18 -4
  30. package/common/dimension.test.json +23680 -11550
  31. package/common/edible.instance.json +21878 -2723
  32. package/common/edible.js +13 -0
  33. package/common/edible.test.json +1580 -304
  34. package/common/emotions.instance.json +2224 -253
  35. package/common/emotions.js +10 -2
  36. package/common/emotions.test.json +1134 -107
  37. package/common/errors.js +1 -1
  38. package/common/errors.test.json +88 -0
  39. package/common/evaluate.test.json +100 -1
  40. package/common/events.js +1 -1
  41. package/common/events.test.json +2197 -242
  42. package/common/fastfood.instance.json +82857 -10609
  43. package/common/fastfood.js +99 -12
  44. package/common/fastfood.test.json +65486 -21430
  45. package/common/formulas.instance.json +325 -58
  46. package/common/formulas.js +1 -1
  47. package/common/formulas.test.json +13202 -6757
  48. package/common/gdefaults.js +18 -8
  49. package/common/help.js +4 -4
  50. package/common/help.test.json +292 -4
  51. package/common/helpers/concept.js +6 -5
  52. package/common/helpers/conjunction.js +1 -1
  53. package/common/helpers/formulas.js +4 -4
  54. package/common/helpers/frankenhash.js +4 -4
  55. package/common/helpers/meta.js +4 -4
  56. package/common/helpers/ordering.js +2 -2
  57. package/common/helpers/properties.js +18 -48
  58. package/common/helpers.js +1 -1
  59. package/common/hierarchy.js +12 -3
  60. package/common/hierarchy.test.json +53813 -17340
  61. package/common/javascript.js +1 -1
  62. package/common/javascript.test.json +214 -11
  63. package/common/kirk.instance.json +322 -7
  64. package/common/kirk.test.json +1123 -254
  65. package/common/length.instance.json +9890 -797
  66. package/common/length.test.json +12055 -8184
  67. package/common/listener.test.json +39 -1
  68. package/common/math.instance.json +294 -57
  69. package/common/math.js +1 -1
  70. package/common/math.test.json +38557 -17754
  71. package/common/meta.instance.json +1 -0
  72. package/common/meta.js +13 -13
  73. package/common/meta.test.json +2770 -275
  74. package/common/nameable.js +1 -1
  75. package/common/nameable.test.json +5150 -1475
  76. package/common/negation.js +1 -1
  77. package/common/negation.test.json +146 -8
  78. package/common/numbers.js +1 -1
  79. package/common/numbers.test.json +234 -0
  80. package/common/ordering.instance.json +3861 -508
  81. package/common/ordering.test.json +2680 -1283
  82. package/common/ordinals.js +12 -2
  83. package/common/ordinals.test.json +627 -3
  84. package/common/people.instance.json +4041 -652
  85. package/common/people.js +1 -15
  86. package/common/people.test.json +27157 -13664
  87. package/common/percentages.js +1 -2
  88. package/common/percentages.test.json +313 -0
  89. package/common/pipboy.instance.json +13628 -1529
  90. package/common/pipboy.js +28 -48
  91. package/common/pipboy.test.json +17367 -5640
  92. package/common/pokemon.instance.json +6163 -690
  93. package/common/pokemon.test.json +1826 -389
  94. package/common/pos.js +16 -6
  95. package/common/pressure.instance.json +2635 -291
  96. package/common/pressure.test.json +2997 -1629
  97. package/common/properties.instance.json +907 -128
  98. package/common/properties.js +19 -28
  99. package/common/properties.test.json +46801 -14612
  100. package/common/punctuation.js +1 -1
  101. package/common/punctuation.test.json +327 -0
  102. package/common/reports.instance.json +997 -118
  103. package/common/reports.js +16 -9
  104. package/common/reports.test.json +16653 -2453
  105. package/common/scorekeeper.instance.json +1 -0
  106. package/common/scorekeeper.js +22 -12
  107. package/common/scorekeeper.test.json +42546 -15408
  108. package/common/sdefaults.js +2 -2
  109. package/common/sizeable.js +2 -2
  110. package/common/sizeable.test.json +1170 -215
  111. package/common/spock.instance.json +322 -7
  112. package/common/spock.test.json +1123 -254
  113. package/common/stgame.js +0 -1
  114. package/common/stgame.test.json +1371 -91
  115. package/common/stm.js +6 -6
  116. package/common/stm.test.json +842 -9
  117. package/common/tell.js +1 -1
  118. package/common/tell.test.json +224 -1
  119. package/common/temperature.instance.json +5980 -285
  120. package/common/temperature.test.json +2610 -1272
  121. package/common/tester.js +1 -1
  122. package/common/testing.test.json +84 -1
  123. package/common/time.test.json +5345 -272
  124. package/common/tokenize.js +3 -2
  125. package/common/tokenize.test.json +39 -0
  126. package/common/ui.instance.json +139 -26
  127. package/common/ui.js +0 -16
  128. package/common/ui.test.json +4620 -140
  129. package/common/weight.instance.json +10025 -771
  130. package/common/weight.js +10 -0
  131. package/common/weight.test.json +18658 -12176
  132. package/common/wp.instance.json +15801 -1655
  133. package/common/wp.js +181 -49
  134. package/common/wp.test.json +112970 -20663
  135. package/common/yesno.js +1 -1
  136. package/common/yesno.test.json +168 -4
  137. package/package.json +11 -6
package/common/wp.js CHANGED
@@ -9,20 +9,57 @@ const wp_tests = require('./wp.test.json')
9
9
  const instance = require('./wp.instance.json')
10
10
 
11
11
  /*
12
- working on
12
+ done
13
+
13
14
  bold the first word
14
15
  bold the first paragraph
15
16
  bold the first letter
16
-
17
- after
18
17
  bold the first word of every paragraph
18
+ bold the first word of the second and third paragraph
19
+ bold the paragraph that contains words that start with t
20
+ underline the paragraph that contains bolded words
21
+ underline the paragraphs that contain bolded words
19
22
  bold the first letter of every word
23
+ bold the third letter of the second paragraph
24
+ bold the first letter of every word that starts with t
25
+ underline the bolded words in the second paragraph
26
+ bold the words that start with t in the second paragraph
27
+ bold the first letter of the words that start with t in the second paragraph
28
+ in the second paragraph bold the first word
29
+ in the second paragraph bold the first letter of the words that start with t
30
+ underline the first bolded word
31
+ underline the first three words
32
+ in the first and second paragraph bold the second word
33
+ underline the first three bolded words
34
+ capitalize the first letter of the words that start with t
35
+
36
+ current
37
+
38
+ change is editable to is really editable
39
+
40
+ todo
41
+
42
+ the first to fifth word
43
+ underline the last three words
44
+ for paragraph 1 and 2 bold the first word
45
+ in the second paragraph for the words that start with t bold the first letter
46
+ underline the bolded paragraphs
47
+ bold the first three words after the second bolded letter
48
+ underline the words that start with t in the paragraph with 3 bolded words
49
+ underline the paragraph that contains three bolded words
50
+ underline the first bolded word that start with t
51
+ bold the first word of the second paragraph and third paragraph
52
+ the paragraph that contains the word boobies
20
53
 
21
54
  after
22
55
  make the words that start with t blue
23
56
 
24
57
  the bolded words that start with t
25
58
 
59
+ replace better with worse
60
+
61
+ change underlines to bolds
62
+
26
63
  start inserting text until I say banana
27
64
  ...
28
65
  or
@@ -90,7 +127,7 @@ const setUpdate = (isA, update, states) => {
90
127
  if (!update.styles) {
91
128
  update.styles = []
92
129
  }
93
- let style = root(state.value)
130
+ const style = root(state.value)
94
131
  /*
95
132
  if (style == 'underlined') {
96
133
  style = 'underline'
@@ -107,42 +144,68 @@ const setUpdate = (isA, update, states) => {
107
144
 
108
145
  const api = new API()
109
146
 
110
- let config = {
147
+ const config = {
111
148
  name: 'wp',
112
149
  };
113
150
 
114
151
  const changeState = ({api, isA, context, toArray, element, state}) => {
115
- let unit = root(context.element.marker)
116
152
  let scope
117
- let conditions = []
118
-
119
- if (context.element.ordinal) {
120
- conditions.push({ ordinals: toArray(context.element.ordinal).map((context) => context.value)})
121
- } else if (isA(context.element, 'everything')) {
122
- scope = 'all'
123
- } else if (context.element.quantity) {
124
- scope = context.element.quantity.quantity
125
- }
126
153
 
127
- if (context.element.conditions) {
128
- for (const condition of context.element.conditions) {
129
- if (condition.marker == 'wordComparisonWith_wp') {
130
- // with or not with that is the question
131
- const letters = condition.letters.letters.text
132
- conditions.push({ comparison: condition.comparison, letters })
133
- } else if (condition.marker == 'wordComparison_wp') {
134
- // with or not with that is the question
135
- const letters = condition.letters.text
136
- conditions.push({ comparison: condition.comparison, letters })
137
- } else if (isA(condition, 'styleModifier_wp')) {
138
- for (const style of toArray(condition)) {
139
- conditions.push({ hasStyle: style.marker })
154
+ const getElement = (selector, update) => {
155
+ const unit = root(selector.marker)
156
+ const conditions = []
157
+ let scope;
158
+ const condition = []
159
+ if (selector.ordinal) {
160
+ // TODO think this out better but its just POC so good enough for now
161
+ const condition = { ordinals: toArray(selector.ordinal).map((context) => context.value) }
162
+ if (selector.quantity) {
163
+ condition.count = selector.quantity.value
164
+ }
165
+ conditions.push(condition)
166
+ } else if (isA(selector, 'everything')) {
167
+ scope = 'all'
168
+ } else if (selector.quantity) {
169
+ scope = selector.quantity.quantity
170
+ } if (selector.distributer) {
171
+ scope = selector.distributer.value
172
+ }
173
+
174
+ if (selector.conditions) {
175
+ for (const condition of selector.conditions) {
176
+ if (condition.marker == 'wordComparisonWithVerb_wp') {
177
+ // with or not with that is the question
178
+ const letters = condition.letters.letters.text
179
+ conditions.push({ comparison: condition.comparison, letters })
180
+ } else if (condition.marker == 'wordComparison_wp') {
181
+ // with or not with that is the question
182
+ const letters = condition.letters.text
183
+ conditions.push({ comparison: condition.comparison, letters })
184
+ } else if (condition.marker == 'paragraphComparisonVerb_wp') {
185
+ // with or not with that is the question
186
+ const update = { selectors: [] }
187
+ const words = getElement(condition.words, update)
188
+ conditions.push({ comparison: condition.comparison, words: update})
189
+ } else if (isA(condition, 'styleModifier_wp')) {
190
+ for (const style of toArray(condition)) {
191
+ conditions.push({ hasStyle: style.marker })
192
+ }
140
193
  }
141
194
  }
142
195
  }
196
+
197
+ if (selector.context) {
198
+ for (const context of toArray(selector.context)) {
199
+ getElement(context, update)
200
+ }
201
+ }
202
+
203
+ update.selectors.push({ unit, scope, conditions })
143
204
  }
144
205
 
145
- const update = { unit, scope, conditions }
206
+ const update = { selectors: [] }
207
+ getElement(context.element, update)
208
+
146
209
  setUpdate(isA, update, toArray(context.state))
147
210
  api.changeState(update)
148
211
  }
@@ -150,9 +213,9 @@ const changeState = ({api, isA, context, toArray, element, state}) => {
150
213
  template = {
151
214
  configs: [
152
215
  'setidsuffix _wp',
153
- 'words are countable orderable and statefulElements',
154
- 'characters are countable orderable and statefulElements',
155
- 'paragraphs are countable orderable and statefulElement',
216
+ 'words are countable distributable orderable textContainers and statefulElements',
217
+ 'characters are countable distributable orderable and statefulElements',
218
+ 'paragraphs are countable distributable orderable textContainers and statefulElement',
156
219
  'text is a statefulElement',
157
220
  'letters means characters',
158
221
  'bold, italic, code, capitalize, lowercase and underline are styles',
@@ -168,14 +231,88 @@ template = {
168
231
  "resetIdSuffix",
169
232
  {
170
233
  operators: [
234
+ "([change_wp|change] (context.text !== 'to')* (context.text == 'to'))",
171
235
  "([changeState_wp|make] ([statefulElement_wp]) ([stateValue_wp|]))",
172
236
  "((style_wp/*) [applyStyle_wp] ([statefulElement_wp|]))",
173
- "((word_wp/*) [wordComparisonWith_wp] ([comparisonWith_wp|with] (a/0)? (letters)))",
237
+ "((word_wp/*) [wordComparisonWithVerb_wp] ([comparisonWith_wp|with] (a/0)? (letters)))",
174
238
  "((word_wp/*) [wordComparison_wp] (a/0)? (letters))",
175
239
  // this one is "the bolded/underlined/italized/... word"
176
240
  "((styleModifier_wp/*) [modifiedByStyle_wp] (statefulElement_wp/* && context.determiner == undefined))",
241
+ // the first letter of each paragraph
242
+ "((statefulElement_wp/*)? <statefulElementInContext_wp|of,in> (statefulElement_wp/*))",
243
+ // the paragraph that contains words that start with t
244
+ "((paragraph_wp/*) [paragraphComparisonVerb_wp] (word_wp/*))",
177
245
  ],
246
+ associations: {
247
+ negative: [
248
+ ],
249
+ positive: [
250
+ // TODO remove these after crucible work done and fix the associator rules
251
+ // [['style_wp', 0], ['statefulElement_wp', 0], ['statefulElementInContext_wp', 0], ['every', 0], ['statefulElement_wp', 0]],
252
+ { context: [['style_wp', 0], ['word_wp', 0], ['statefulElementInContext_wp', 0], ['paragraph_wp', 0]], choose: 0 },
253
+ { context: [['style_wp', 0], ['letter_wp', 0], ['statefulElementInContext_wp', 0], ['word_wp', 0]], choose: 0 },
254
+ { context: [['paragraph_wp', 0], ['thatVerb', 0], ['paragraphComparisonVerb_wp', 0], ['word_wp', 0]], choose: 0 },
255
+ { context: [['paragraph_wp', 0], ['thatVerb', 0], ['paragraphComparisonVerb_wp', 0], ['styleModifier_wp', 0], ['word_wp', 0]], choose: 0 },
256
+ { context: [['word_wp', 0], ['thatVerb', 0], ['wordComparison_wp', 0]], choose: 0 },
257
+ { context: [["style_wp",1],["article",0],["statefulElement_wp",1],["thatVerb",0],["paragraphComparisonVerb_wp",0],["styleModifier_wp",0],["statefulElement_wp",0]], choose: 0 },
258
+ { context: [["style_wp",1],["article",0],["statefulElement_wp",1],["thatVerb",0],["paragraphComparisonVerb_wp",0],["word_wp",0],["thatVerb",0],["wordComparisonWithVerb_wp",0],["comparisonWith_wp",0],["unknown",0]], choose: 0 },
259
+ { context: [["article",0],["statefulElement_wp",1],["thatVerb",0],["paragraphComparisonVerb_wp",0],["styleModifier_wp",0],["statefulElement_wp",0]], choose: 0 },
260
+
261
+ { context: [["style_wp",1],["article",0],["statefulElement_wp",1],["thatVerb",0],["wordComparison_wp",0],["unknown",0]], choose: 0 },
262
+ { context: [["style_wp",1],["statefulElement_wp",1],["thatVerb",0],["wordComparison_wp",0],["unknown",0]], choose: 0 },
263
+ ]
264
+ },
265
+
178
266
  bridges: [
267
+ {
268
+ id: 'change_wp',
269
+ bridge: "{ ...next(operator), from: after[0][0], generate: [operator, 'from', after[1]] }",
270
+ },
271
+ {
272
+ id: 'paragraphComparisonVerb_wp',
273
+ parents: ['verb'],
274
+ words: [
275
+ { word: 'contain', comparison: 'include' },
276
+ { word: 'contains', comparison: 'include' },
277
+ { word: 'include', comparison: 'include' },
278
+ { word: 'includes', comparison: 'include' },
279
+ ],
280
+ bridge: "{ ...next(operator), element: before[0], subject: before[0], words: after[0], verb: operator, generate: ['element', 'verb', 'words'] }",
281
+ },
282
+ {
283
+ id: 'statefulElementInContext_wp',
284
+ parents: ['preposition'],
285
+ optional: {
286
+ '-1': "{ ...operator, invisible: true }",
287
+ },
288
+ bridge: "{ ...next(before[0]), context: append(before[0].context, [after[0]]), generate: [before[0], operator, after[0]], modifiers: [] }",
289
+ semantic: (args) => {
290
+ const { context, contexts } = args
291
+ for (let i = context.context_index + 1; i < contexts.length; ++i) {
292
+ if (contexts[i].marker == 'applyStyle_wp') {
293
+ const element = contexts[i].element
294
+ if (!element.context) {
295
+ element.context = []
296
+ }
297
+ element.context = element.context.concat(context.context)
298
+ }
299
+ }
300
+ console.log(JSON.stringify(Object.keys(args)))
301
+ },
302
+ },
303
+ {
304
+ id: 'applyStyle_wp',
305
+ parents: ['verb'],
306
+ convolution: true,
307
+ bridge: "{ ...next(operator), element: after[0], state: before[0], operator: operator, generate: ['state', 'element'] }",
308
+ localHierarchy: [
309
+ ['thisitthat', 'statefulElement_wp'],
310
+ ['everything', 'statefulElement_wp'],
311
+ ],
312
+ semantic: (args) => {
313
+ changeState({...args, element: args.context.element, state: args.context.state})
314
+ }
315
+ },
179
316
  {
180
317
  id: 'modifiedByStyle_wp',
181
318
  // parents: ['verb'],
@@ -184,7 +321,7 @@ template = {
184
321
  bridge: "{ ...after[0], style: before[0], target: after[0], generate: ['style', 'target'], conditions: append(after[0].conditions, [before[0]]) }",
185
322
  },
186
323
  {
187
- id: 'wordComparisonWith_wp',
324
+ id: 'wordComparisonWithVerb_wp',
188
325
  parents: ['verb'],
189
326
  words: [
190
327
  { word: 'start', comparison: 'prefix' },
@@ -216,19 +353,6 @@ template = {
216
353
  },
217
354
  bridge: "{ ...next(operator), operator: operator, letters: after[1], generate: ['operator', 'letters'] }",
218
355
  },
219
- {
220
- id: 'applyStyle_wp',
221
- parents: ['verb'],
222
- convolution: true,
223
- bridge: "{ ...next(operator), element: after[0], state: before[0], operator: operator, generate: ['state', 'element'] }",
224
- localHierarchy: [
225
- ['thisitthat', 'statefulElement_wp'],
226
- ['everything', 'statefulElement_wp'],
227
- ],
228
- semantic: (args) => {
229
- changeState({...args, element: args.context.element, state: args.context.state})
230
- }
231
- },
232
356
  {
233
357
  id: 'changeState_wp',
234
358
  parents: ['verb'],
@@ -270,7 +394,15 @@ template = {
270
394
  },
271
395
  ],
272
396
  priorities: [
273
- // { "context": [['underline_wp',0], ['statefulElement_wp', 1], ['thatVerb', 0]], ordered: true, choose: [2] },
397
+ { "context": [['ordinal', 1], ['list', 0], ['ordinal', 1], ['statefulElement_wp', 0]], ordered: true, choose: [1] },
398
+ { "context": [['word_wp', 1], ['wordComparisonWithVerb_wp', 0], ['comparisonWith_wp', 1], ['statefulElementInContext_wp', 0]], ordered: true, choose: [1] },
399
+ { "context": [['paragraphComparisonVerb_wp', 0], ['word_wp', 0], ['wordComparisonWithVerb_wp', 0]], ordered: true, choose: [2] },
400
+ { "context": [['statefulElementInContext_wp', 0], ['word_wp', 0], ['wordComparisonWithVerb_wp', 0]], ordered: true, choose: [2] },
401
+ { "context": [['statefulElementInContext_wp', 0], ['word_wp', 1], ['wordComparisonWithVerb_wp', 0], ['comparisonWith_wp', 1]], ordered: true, choose: [2,3] },
402
+ { "context": [['statefulElementInContext_wp', 0], ['comparisonWith_wp', 0]], choose: [1] },
403
+ { "context": [['paragraphComparisonVerb_wp', 0], ['wordComparisonWithVerb_wp', 0]], choose: [1] },
404
+ { "context": [['ordinal',1], ['list', 0], ['ordinal', 1], ['word_wp', 1]], ordered: true, choose: [1] },
405
+ { "context": [['changeState_wp',0], ['every', 0], ['word_wp', 1], ['list', 1]], ordered: true, choose: [1] },
274
406
  { "context": [['changeState_wp',0], ['statefulElement_wp', 0], ['list', 0]], ordered: true, choose: [0] },
275
407
  { "context": [['comparisonWith_wp',0], ['unknown', 0], ['list', 1]], ordered: true, choose: [0] },
276
408
  ],
@@ -293,7 +425,7 @@ knowledgeModule({
293
425
  contents: wp_tests,
294
426
  checks: {
295
427
  context: [
296
- ...defaultContextCheck(),
428
+ ...defaultContextCheck(['distributer', 'subject', 'element', 'letters', 'target', 'conditions' ]),
297
429
  ],
298
430
  objects: [
299
431
  'changeState',