tpmkms_4wp 8.0.0-beta.4 → 8.0.0-beta.41

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. package/common/animals.instance.json +2855 -1363
  2. package/common/animals.js +2 -2
  3. package/common/articles.js +108 -0
  4. package/common/articles.test.json +310 -0
  5. package/common/avatar.js +2 -2
  6. package/common/characters.js +9 -11
  7. package/common/colors.instance.json +6980 -3523
  8. package/common/colors.js +2 -2
  9. package/common/colors.test.json +345 -780
  10. package/common/comparable.js +2 -15
  11. package/common/concept.js +17 -11
  12. package/common/countable.js +5 -5
  13. package/common/crew.instance.json +13032 -6570
  14. package/common/crew.js +4 -4
  15. package/common/crew.test.json +714 -452
  16. package/common/currency.js +7 -7
  17. package/common/dialogues.js +117 -238
  18. package/common/dimension.instance.json +265 -264
  19. package/common/dimension.js +13 -13
  20. package/common/dimension.test.json +446 -1640
  21. package/common/edible.instance.json +19910 -9988
  22. package/common/edible.js +2 -2
  23. package/common/emotions.instance.json +146 -128
  24. package/common/emotions.js +4 -4
  25. package/common/evaluate.instance.json +2 -0
  26. package/common/evaluate.js +55 -0
  27. package/common/evaluate.test.json +574 -0
  28. package/common/events.js +6 -6
  29. package/common/fastfood.instance.json +221110 -111293
  30. package/common/fastfood.js +25 -25
  31. package/common/formulas.instance.json +241 -255
  32. package/common/formulas.js +14 -14
  33. package/common/gdefaults.js +19 -19
  34. package/common/help.js +4 -4
  35. package/common/help.test.json +22 -22
  36. package/common/helpers/concept.js +9 -6
  37. package/common/helpers/dialogues.js +2 -3
  38. package/common/helpers/properties.js +48 -58
  39. package/common/helpers.js +1 -1
  40. package/common/hierarchy.js +12 -16
  41. package/common/javascript.js +8 -8
  42. package/common/kirk.instance.json +583 -289
  43. package/common/kirk.js +2 -2
  44. package/common/length.instance.json +5530 -4754
  45. package/common/length.js +2 -2
  46. package/common/listener.js +54 -0
  47. package/common/listener.test.json +104 -0
  48. package/common/math.instance.json +176 -1168
  49. package/common/math.js +11 -11
  50. package/common/meta.js +22 -29
  51. package/common/nameable.instance.json +2 -0
  52. package/common/nameable.js +142 -0
  53. package/common/nameable.test.json +2121 -0
  54. package/common/negation.instance.json +2 -0
  55. package/common/negation.js +38 -0
  56. package/common/negation.test.json +308 -0
  57. package/common/numbers.js +3 -3
  58. package/common/ordering.instance.json +340 -228
  59. package/common/ordering.js +5 -5
  60. package/common/people.instance.json +2066 -1014
  61. package/common/people.js +4 -5
  62. package/common/percentages.instance.json +2 -0
  63. package/common/percentages.js +57 -0
  64. package/common/percentages.test.json +751 -0
  65. package/common/pipboy.instance.json +7974 -6300
  66. package/common/pipboy.js +29 -32
  67. package/common/pokemon.instance.json +4207 -2069
  68. package/common/pokemon.js +4 -4
  69. package/common/pos.js +1 -1
  70. package/common/pressure.instance.json +1341 -1189
  71. package/common/pressure.js +2 -2
  72. package/common/properties.instance.json +130 -60
  73. package/common/properties.js +54 -125
  74. package/common/punctuation.js +2 -2
  75. package/common/reports.instance.json +595 -557
  76. package/common/reports.js +58 -76
  77. package/common/scorekeeper.js +14 -22
  78. package/common/sdefaults.js +13 -3
  79. package/common/sizeable.js +2 -2
  80. package/common/spock.instance.json +583 -289
  81. package/common/spock.js +2 -2
  82. package/common/stgame.js +13 -9
  83. package/common/stm.js +162 -19
  84. package/common/stm.test.json +1734 -1
  85. package/common/tell.js +10 -10
  86. package/common/temperature.instance.json +1484 -1204
  87. package/common/temperature.js +2 -2
  88. package/common/tester.js +2 -2
  89. package/common/testing.js +5 -5
  90. package/common/time.js +7 -7
  91. package/common/tokenize.js +1 -1
  92. package/common/ui.instance.json +257 -258
  93. package/common/ui.js +9 -9
  94. package/common/weight.instance.json +5212 -4233
  95. package/common/weight.js +2 -2
  96. package/common/yesno.js +1 -1
  97. package/main.js +59 -46
  98. package/package.json +27 -6
@@ -136,7 +136,7 @@ class API {
136
136
  notes: 'semantic for setting value with constraint',
137
137
  match: ({context, isA}) => isA(context.marker, after[0].tag) && context.evaluate && context.constraints,
138
138
  // match: ({context, isA}) => context.marker == after[0].tag && context.evaluate,
139
- apply: ({km, context, e, log, isA, s}) => {
139
+ apply: async ({km, context, e, log, isA}) => {
140
140
  const constraint = context.constraints[0];
141
141
  const value = constraint.constraint;
142
142
  let property = constraint.property;
@@ -151,7 +151,7 @@ class API {
151
151
  // value.greg = true
152
152
  // value.ownee.query = true
153
153
  value.query = true
154
- let instance = e(value)
154
+ let instance = await e(value)
155
155
  if (instance.verbatim) {
156
156
  context.evalue = { verbatim: instance.verbatim }
157
157
  return
@@ -168,13 +168,13 @@ class API {
168
168
  config.addGenerator({
169
169
  notes: 'generator for constraint',
170
170
  match: ({context}) => context.marker == edAble.operator && context.paraphrase && context.constrained,
171
- apply: ({context, g}) => {
171
+ apply: async ({context, g}) => {
172
172
  if (context[before[0].tag].marker == 'by') {
173
173
  // the cat wendy owned
174
- return `${g({...context[after[0].tag], paraphrase: true})} ${edAble.word} ${g({...context[before[0].tag], paraphrase: true})}`
174
+ return `${await g({...context[after[0].tag], paraphrase: true})} ${edAble.word} ${await g({...context[before[0].tag], paraphrase: true})}`
175
175
  } else {
176
176
  // the cat owned by wendy
177
- return `${g({...context[after[0].tag], paraphrase: true})} ${edAble.word} ${['by', g({...context[before[0].tag], paraphrase: true})].filter((t) => t).join(' ')}`
177
+ return `${await g({...context[after[0].tag], paraphrase: true})} ${edAble.word} ${['by', await g({...context[before[0].tag], paraphrase: true})].filter((t) => t).join(' ')}`
178
178
  }
179
179
  },
180
180
  })
@@ -194,19 +194,19 @@ class API {
194
194
 
195
195
  return false;
196
196
  },
197
- apply: ({context, g}) => {
197
+ apply: async ({context, g}) => {
198
198
  const chosen = chooseNumber(context, word.singular, word.plural)
199
- return `${g(context[before[0].tag])} ${chosen} ${g(context[after[0].tag])}`
199
+ return `${await g(context[before[0].tag])} ${chosen} ${await g(context[after[0].tag])}`
200
200
  }
201
201
  })
202
202
  config.addGenerator({
203
203
  match: ({context}) => context.marker == edAble.operator && context.isEd,
204
- apply: ({context, g}) => {
204
+ apply: async ({context, g}) => {
205
205
  const chosen = chooseNumber(context[after[0].tag], 'is', 'are')
206
206
  if (context[before[0].tag].evalue && context[before[0].tag].evalue.marker == 'answerNotKnown') {
207
- return g(context[before[0].tag])
207
+ return await g(context[before[0].tag])
208
208
  }
209
- return `${g(context[after[0].tag])} ${chosen} ${edAble.word} by ${g(context[before[0].tag])}`
209
+ return `${await g(context[after[0].tag])} ${chosen} ${edAble.word} by ${await g(context[before[0].tag])}`
210
210
  }
211
211
  })
212
212
  /*
@@ -250,7 +250,7 @@ class API {
250
250
  notes: `generator for who/what is X owned by`,
251
251
  // match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'is') && context.one && context.one.marker == 'ownee' && context.one.constraints && context.one.constraints[0] && context.one.constraints[0].constraint.marker == 'owned' && context.one.constraints[0].constraint.owner.implicit,
252
252
  match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'is') && context.one && context.one.marker == after[0].tag && context.one.constraints && context.one.constraints[0] && context.one.constraints[0].constraint.marker == edAble.operator && context.one.constraints[0].constraint[before[0].tag].implicit,
253
- apply: ({context, g, gs, callId}) => {
253
+ apply: async ({context, g, gs, callId}) => {
254
254
  const isToFromM = [{"from":["one"],"to":["two"]},{"from":["two"],"to":["one"]}]
255
255
  const fromF = config.fragment(whoIsWhatVerbedBy).contexts()[0]
256
256
  // const fromF = config.fragment[before[0].tag]"ownerVar is owneeVar owned by").contexts()[0]
@@ -269,11 +269,11 @@ class API {
269
269
  // const from = context.one.constraints[0].constraint
270
270
  const from = context
271
271
  const im = translationMappingToInstantiatorMappings(tmPrime, from, to)
272
- const translation = toF.instantiate(im)
272
+ const translation = await toF.instantiate(im)
273
273
  if (Array.isArray(translation)) {
274
- return gs(translation)
274
+ return await gs(translation)
275
275
  } else {
276
- return g(translation)
276
+ return await g(translation)
277
277
  }
278
278
  }
279
279
  }
@@ -383,11 +383,16 @@ class API {
383
383
  config.addGenerator({
384
384
  notes: 'ordering generator for paraphrase',
385
385
  match: ({context}) => context.marker == operator && context.paraphrase && !context.query,
386
- apply: ({context, gp, g}) => {
387
- const beforeGenerator = before.map( (arg) => g(context[arg.tag]) )
388
- const afterGenerator = after.map( (arg) => gp(context[arg.tag]) )
386
+ apply: async ({context, gp, g}) => {
387
+ const beforeGenerator = []
388
+ for (const arg of before) {
389
+ beforeGenerator.push(await g(context[arg.tag]))
390
+ }
391
+ const afterGenerator = []
392
+ for (const arg of after) {
393
+ afterGenerator.push(await gp(context[arg.tag]))
394
+ }
389
395
  const word = context.word
390
- // return beforeGenerator.concat([`${context.word}`]).concat(afterGenerator).join(' ')
391
396
  const sub = []
392
397
  if (context.subphrase) {
393
398
  sub.push(['that'])
@@ -399,7 +404,7 @@ class API {
399
404
  config.addGenerator({
400
405
  notes: 'ordering generator for response',
401
406
  match: ({context}) => context.marker == operator && context.evalue && context.isResponse,
402
- apply: ({context, g, km}) => {
407
+ apply: async ({context, g, km}) => {
403
408
  const brief = km("dialogues").api.getBrief()
404
409
 
405
410
  const { evalue } = context
@@ -414,7 +419,7 @@ class API {
414
419
  if (evalue.truthValueOnly || brief) {
415
420
  return `${yesno}`
416
421
  } else {
417
- return `${yesno} ${g(Object.assign({}, evalue, { paraphrase: true }))}`
422
+ return `${yesno} ${await g(Object.assign({}, evalue, { paraphrase: true }))}`
418
423
  }
419
424
  }
420
425
  })
@@ -628,8 +633,8 @@ class API {
628
633
  setValue: ([object, property], value, has) => {
629
634
  return this.setProperty(object, property, value, has, true)
630
635
  },
631
- getValue: ([object, property]) => {
632
- return this.getPropertyDirectly(object, property)
636
+ getValue: async ([object, property]) => {
637
+ return await this.getPropertyDirectly(object, property)
633
638
  },
634
639
  })
635
640
  }
@@ -645,16 +650,18 @@ class API {
645
650
  error.code = 'ReadOnly'
646
651
  throw error
647
652
  },
648
- getValue: ([object, property]) => {
649
- return this.getPropertyDirectly(object, property)
653
+ getValue: async ([object, property]) => {
654
+ return await this.getPropertyDirectly(object, property)
650
655
  },
651
656
  })
652
657
  this.propertiesFH.setHandler(path, handler)
653
658
  }
654
659
 
655
- getObject(object) {
660
+ /*
661
+ async getObject(object) {
656
662
  return this.propertiesFH.getValue([object])
657
663
  }
664
+ */
658
665
 
659
666
  getHandler(object, property) {
660
667
  return this.propertiesFH.getHandler([object, property])
@@ -671,34 +678,33 @@ class API {
671
678
  // return context.value
672
679
  }
673
680
 
674
- getProperty(object, property, g) {
681
+ async getProperty(object, property, g) {
675
682
  object = this.toValue(object)
676
683
  property = this.toValue(property)
677
684
  const handler = this.propertiesFH.getHandler([object, property])
678
685
  if (handler) {
679
- return handler.getValue([object, property])
686
+ return await handler.getValue([object, property])
680
687
  }
681
- return this.getPropertyDirectly(object, property, g)
688
+ return await this.getPropertyDirectly(object, property, g)
682
689
  }
683
690
 
684
- getPropertyDirectly(object, property, g) {
691
+ async getPropertyDirectly(object, property, g) {
685
692
  if (property == 'property') {
686
- const objectProps = this.propertiesFH.getValue([object])
693
+ const objectProps = await this.propertiesFH.getValue([object])
687
694
  const values = []
688
695
  for (let key of Object.keys(objectProps)) {
689
696
  if (objectProps[key].has) {
690
- // values.push(`${g(key)}: ${g({ ...objectProps[key].value, evaluate: true })}`)
691
- values.push(`${g(key)}: ${g({ ...objectProps[key].value, paraphrase: true })}`)
697
+ values.push(`${await g(key)}: ${await g({ ...objectProps[key].value, paraphrase: true })}`)
692
698
  }
693
699
  }
694
700
  return { marker: 'list', value: values }
695
701
  } else {
696
- return this.propertiesFH.getValue([object, property]).value
702
+ return (await this.propertiesFH.getValue([object, property])).value
697
703
  }
698
704
  }
699
705
 
700
- hasProperty(object, property, has) {
701
- return this.propertiesFH.getValue([object, property]).has
706
+ async hasProperty(object, property, has) {
707
+ return (await this.propertiesFH.getValue([object, property])).has
702
708
  }
703
709
 
704
710
  setProperty(object, property, value, has, skipHandler) {
@@ -726,7 +732,7 @@ class API {
726
732
  }
727
733
  }
728
734
 
729
- knownObject(object) {
735
+ async knownObject(object) {
730
736
  if (object == 'property') {
731
737
  return object
732
738
  }
@@ -735,10 +741,10 @@ class API {
735
741
  }
736
742
  const path = [object]
737
743
  // return this.knownPropertyNew(path)
738
- return this.propertiesFH.knownProperty(path)
744
+ return await this.propertiesFH.knownProperty(path)
739
745
  }
740
746
 
741
- hasProperty(object, property) {
747
+ async hasProperty(object, property) {
742
748
  if (property == 'property') {
743
749
  return true;
744
750
  }
@@ -748,7 +754,7 @@ class API {
748
754
  const seen = [object];
749
755
  while (todo.length > 0) {
750
756
  const next = todo.pop();
751
- if ((this.propertiesFH.getValue([next, property], false) || {}).has) {
757
+ if ((await this.propertiesFH.getValue([next, property], false) || {}).has) {
752
758
  return true
753
759
  }
754
760
  const parents = this._objects.parents[next] || [];
@@ -763,11 +769,11 @@ class API {
763
769
  }
764
770
 
765
771
  // NOT DONE
766
- knownProperty(object, property) {
772
+ async knownProperty(object, property) {
767
773
  object = this.toValue(object)
768
774
  property = this.toValue(property)
769
775
  if (property == 'property') {
770
- const objectProps = this.propertiesFH.getValue([object])
776
+ const objectProps = await this.propertiesFH.getValue([object])
771
777
  return !_.isEmpty(objectProps)
772
778
  }
773
779
 
@@ -776,7 +782,7 @@ class API {
776
782
  const seen = [object];
777
783
  while (todo.length > 0) {
778
784
  const next = todo.pop();
779
- if ((this.propertiesFH.getValue([next, property], false) || {}).has) {
785
+ if ((await this.propertiesFH.getValue([next, property], false) || {}).has) {
780
786
  return true
781
787
  }
782
788
  const parents = this._objects.parents[next] || [];
@@ -911,22 +917,6 @@ class API {
911
917
 
912
918
  set config(config) {
913
919
  this._config = config
914
- /*
915
- const toJSON = (h) => {
916
- if (h.child && h.parent) {
917
- return h
918
- } else {
919
- return { child: h[0], parent: h[1] }
920
- }
921
- }
922
- for (const tuple of [...config().config.hierarchy]) {
923
- const h = toJSON(tuple);
924
- // TODO should this notice development flag?
925
- if (this.isOperator(h.child) && this.isOperator(h.parent)) {
926
- this.rememberIsA(h.child, h.parent)
927
- }
928
- }
929
- */
930
920
  }
931
921
 
932
922
  get config() {
package/common/helpers.js CHANGED
@@ -131,7 +131,7 @@ const toEValue = (context) => {
131
131
  return context;
132
132
  }
133
133
 
134
- const defaultContextProperties = ['marker', 'text', 'verbatim', 'isResponse']
134
+ const defaultContextProperties = ['marker', 'text', 'verbatim', 'isResponse', { property: 'response', filter: ['marker', 'text', 'verbatim'] }]
135
135
  const defaultContextCheck = [
136
136
  ...defaultContextProperties,
137
137
  (object) => {
@@ -61,7 +61,7 @@ let configStruct = {
61
61
  notes: 'what type is pikachu',
62
62
  where: where(),
63
63
  match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'is') && context.query && !['what'].includes(context.one.marker) && !['what'].includes(context.two.marker) && (context.one.query || context.two.query),
64
- apply: ({context, hierarchy, km, log, e, s}) => {
64
+ apply: async ({context, hierarchy, km, log, e}) => {
65
65
  const one = context.one;
66
66
  const two = context.two;
67
67
  let concept, value;
@@ -72,7 +72,7 @@ let configStruct = {
72
72
  concept = two;
73
73
  value = one;
74
74
  }
75
- let instance = e(value)
75
+ let instance = await e(value)
76
76
  if (instance.verbatim) {
77
77
  context.evalue = { verbatim: instance.verbatim }
78
78
  context.isResponse = true
@@ -80,9 +80,6 @@ let configStruct = {
80
80
  }
81
81
  instance = getTypes(km, concept, instance)
82
82
 
83
- // instance.focusable = ['one', 'two']
84
- // concept = JSON.parse(JSON.stringify(value))
85
- // greg
86
83
  concept = _.cloneDeep(value)
87
84
  concept.isQuery = undefined
88
85
 
@@ -106,10 +103,10 @@ let configStruct = {
106
103
  notes: 'type of pikachu', // the types of type is the next one
107
104
  where: where(),
108
105
  match: ({context}) => context.marker == 'type' && context.evaluate && context.object && context.objects[context.objects.length-1].number == 'one' && pluralize.isSingular(context.objects[0].word),
109
- apply: ({context, objects, e, gs, km, log, s}) => {
106
+ apply: async ({context, objects, e, gs, km, log}) => {
110
107
  const concept = context.objects[0];
111
108
  const value = context.objects[1];
112
- let instance = e(value)
109
+ let instance = await e(value)
113
110
  if (instance.verbatim) {
114
111
  context.evalue = { verbatim: instance.verbatim }
115
112
  return
@@ -135,14 +132,14 @@ let configStruct = {
135
132
  }
136
133
  return hierarchy.isA(context.marker, 'is') && context.query && args( { types: ['hierarchyAble', 'hierarchyAble'], properties: ['one', 'two'] } )
137
134
  },
138
- apply: ({context, km, objects, g}) => {
135
+ apply: async ({context, km, objects, g}) => {
139
136
  const api = km('properties').api
140
137
  const one = context.one
141
138
  const two = context.two
142
139
  const oneId = pluralize.singular(one.value);
143
140
  if (!api.conceptExists(oneId)) {
144
141
  context.evalue = {
145
- verbatim: `I don't know about ${g({ ...one, paraphrase: true})}`
142
+ verbatim: `I don't know about ${await g({ ...one, paraphrase: true})}`
146
143
  }
147
144
  context.isResponse = true
148
145
  return
@@ -150,7 +147,7 @@ let configStruct = {
150
147
  const twoId = pluralize.singular(two.value);
151
148
  if (!api.conceptExists(twoId)) {
152
149
  context.evalue = {
153
- verbatim: `I don't know about ${g({ ...two, paraphrase: true})}`
150
+ verbatim: `I don't know about ${await g({ ...two, paraphrase: true})}`
154
151
  }
155
152
  context.isResponse = true
156
153
  return
@@ -201,7 +198,6 @@ let configStruct = {
201
198
  },
202
199
  {
203
200
  notes: 'humans are mammels',
204
- // match: ({context, listable}) => listable(context, 'unknown') && context.same,
205
201
  where: where(),
206
202
  match: ({context, listable, hierarchy, isA, callId}) => {
207
203
  if (!context.same) {
@@ -270,7 +266,7 @@ let configStruct = {
270
266
  notes: 'types of type', // what are the types of animals
271
267
  where: where(),
272
268
  match: ({context}) => context.marker == 'type' && context.evaluate && context.object,
273
- apply: ({context, objects, gs, km, isA}) => {
269
+ apply: ({context, objects, km, isA}) => {
274
270
  const api = km('properties').api
275
271
  const conceptApi = km('concept').api
276
272
  const type = pluralize.singular(context.object.value);
@@ -288,16 +284,16 @@ let configStruct = {
288
284
  ]
289
285
  };
290
286
 
291
- const createConfig = () => {
287
+ const createConfig = async () => {
292
288
  const config = new Config(configStruct, module)
293
289
  config.stop_auto_rebuild()
294
- config.add(properties())
295
- config.initializer( ({apis, hierarchy}) => {
290
+ await config.add(properties)
291
+ await config.initializer( ({apis, hierarchy}) => {
296
292
  apis('stm').addIsA( (child, parent) => {
297
293
  return hierarchy.isA(child, parent)
298
294
  })
299
295
  })
300
- config.restart_auto_rebuild()
296
+ await config.restart_auto_rebuild()
301
297
  return config
302
298
  }
303
299
 
@@ -36,14 +36,14 @@ let configStruct = {
36
36
  {
37
37
  where: where(),
38
38
  match: ({context}) => context.marker == 'assignment' && context.paraphrase,
39
- apply: ({context, g}) => `let ${g(context.variable)} = ${g(context.value)}`
39
+ apply: async ({context, g}) => `let ${await g(context.variable)} = ${await g(context.value)}`
40
40
  },
41
41
  {
42
42
  where: where(),
43
43
  match: ({context}) => context.marker == 'assignment' && context.isResponse,
44
- apply: ({context, g}) => {
45
- const value = g(context.variable)
46
- return `${g(context.variable)} == ${g(context.value)}`
44
+ apply: async ({context, g}) => {
45
+ // const value = await g(context.variable)
46
+ return `${await g(context.variable)} == ${await g(context.value)}`
47
47
  }
48
48
  },
49
49
  ],
@@ -60,15 +60,15 @@ let configStruct = {
60
60
  ],
61
61
  };
62
62
 
63
- const createConfig = () => {
63
+ const createConfig = async () => {
64
64
  const config = new Config(configStruct, module)
65
65
  config.stop_auto_rebuild()
66
- config.add(dialogues())
66
+ await config.add(dialogues)
67
67
 
68
- config.initializer( ({objects, uuid}) => {
68
+ await config.initializer( ({objects, uuid}) => {
69
69
  objects.variables = {}
70
70
  })
71
- config.restart_auto_rebuild()
71
+ await config.restart_auto_rebuild()
72
72
  return config
73
73
  }
74
74