ekms 9.6.3-beta.2 → 9.6.3-beta.4

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.
@@ -893,7 +893,7 @@ class State {
893
893
  }
894
894
 
895
895
  this.api.add(item)
896
- this.api.args.mentioned({ context: food })
896
+ this.api.args.remember({ context: food })
897
897
 
898
898
  for (const addIt of addsInsteadOfModifications) {
899
899
  this.add(addIt)
@@ -19,12 +19,12 @@ class API {
19
19
  context.namespaced.nameable ??= {}
20
20
  context.namespaced.nameable.names ??= []
21
21
  context.namespaced.nameable.names.push(name)
22
- this.args.config.addWord(name, { id: context.marker, initial: `{ value: "${name}", pullFromContext: true, nameable_named: true }` })
22
+ this.args.config.addWord(name, { id: context.marker, initial: `{ value: "${name}", pullFromContext: true, nameable_named: true, instance: ${context.instance ? 'true' : 'false'} }` })
23
23
  }
24
24
 
25
25
  // used by mongo km
26
26
  get(type, name) {
27
- return this.args.kms.stm.api.mentions({
27
+ return this.args.kms.stm.api.recall({
28
28
  context: type,
29
29
  condition: (context) => {
30
30
  if (context.namespaced?.nameable && context.namespaced.nameable.names) {
@@ -54,16 +54,16 @@ class API {
54
54
  setCurrent(name) {
55
55
  const context = this.objects.named[name]
56
56
  if (context) {
57
- this.args.km('stm').api.mentioned({ context })
57
+ this.args.km('stm').api.remember({ context })
58
58
  }
59
59
  }
60
60
  }
61
61
 
62
62
  function initializer({config}) {
63
- config.addArgs(({kms, mentioned}) => {
63
+ config.addArgs(({kms, remember}) => {
64
64
  return {
65
- mentioned: (args) => {
66
- mentioned(args)
65
+ remember: (args) => {
66
+ remember(args)
67
67
  if (args.name) {
68
68
  kms.nameable.api.setName(args.context, args.name)
69
69
  }
@@ -34,11 +34,45 @@ const config = {
34
34
  semantics: [
35
35
  {
36
36
  where: where(),
37
- match: ({context}) => context.marker == 'mentions' && context.evaluate,
38
- apply: async ({callId, _continue, toList, context, kms, e, log, retry}) => {
39
- if (context.args?.context?.ordinal?.marker == 'ordinal' && context.args?.context?.ordinal?.value == -1) {
40
- const lastN = context.args.context.quantity?.value || 1
41
- context.args.lastN = lastN
37
+ match: ({context}) => context.marker == 'mentions' && context.evaluate && context.args?.context?.ordinal,
38
+ apply: async ({callId, _continue, toList, context, kms, e, log, toArray, retry}) => {
39
+ // const ordinals = toArray(context.args?.context?.ordinal)
40
+ const lastNotFirst = context.args?.context?.ordinal.value < 0
41
+ const quantity = context.args.context.quantity?.value || 1
42
+ context.args.filter ??= (r) => r
43
+ context.args.all = true
44
+ const oldFilter = context.args.filter
45
+ context.args.filter = (result) => {
46
+ const reversed = context.args.frameOfReference?.namespaced?.stm?.reversed
47
+ let selected = []
48
+ for (const ordinal of toArray(context.args?.context?.ordinal)) {
49
+ if (context.args.context.quantity) {
50
+ if (lastNotFirst) {
51
+ if (reversed) {
52
+ selected = selected.concat(result.slice(-quantity))
53
+ } else {
54
+ selected = selected.concat(result.slice(0, quantity).reverse())
55
+ }
56
+ } else {
57
+ if (!reversed) {
58
+ selected = selected.concat(result.slice(-quantity).reverse())
59
+ } else {
60
+ selected = selected.concat(result.slice(0, quantity))
61
+ }
62
+ }
63
+ } else {
64
+ let point
65
+ if (ordinal.value > 0) {
66
+ point = result[ordinal.value-1]
67
+ } else {
68
+ point = result[result.length + ordinal.value]
69
+ }
70
+ if (point) {
71
+ selected.push(point)
72
+ }
73
+ }
74
+ }
75
+ return oldFilter(selected)
42
76
  }
43
77
  _continue()
44
78
  }
@@ -53,6 +87,18 @@ const config = {
53
87
  "2nd": [{"id": "ordinal", "initial": "{ value: 2, ordinal: true, instance: true }" }],
54
88
  "third": [{"id": "ordinal", "initial": "{ value: 3, ordinal: true, instance: true }" }],
55
89
  "3rd": [{"id": "ordinal", "initial": "{ value: 3, ordinal: true, instance: true }" }],
90
+ "fourth": [{"id": "ordinal", "initial": "{ value: 4, ordinal: true, instance: true }" }],
91
+ "4rd": [{"id": "ordinal", "initial": "{ value: 4, ordinal: true, instance: true }" }],
92
+ "fifth": [{"id": "ordinal", "initial": "{ value: 5, ordinal: true, instance: true }" }],
93
+ "5th": [{"id": "ordinal", "initial": "{ value: 5, ordinal: true, instance: true }" }],
94
+ "sixth": [{"id": "ordinal", "initial": "{ value: 6, ordinal: true, instance: true }" }],
95
+ "6th": [{"id": "ordinal", "initial": "{ value: 6, ordinal: true, instance: true }" }],
96
+ "seventh": [{"id": "ordinal", "initial": "{ value: 7, ordinal: true, instance: true }" }],
97
+ "7th": [{"id": "ordinal", "initial": "{ value: 7, ordinal: true, instance: true }" }],
98
+ "eigth": [{"id": "ordinal", "initial": "{ value: 8, ordinal: true, instance: true }" }],
99
+ "8th": [{"id": "ordinal", "initial": "{ value: 8, ordinal: true, instance: true }" }],
100
+ "ninth": [{"id": "ordinal", "initial": "{ value: 9, ordinal: true, instance: true }" }],
101
+ "9th": [{"id": "ordinal", "initial": "{ value: 9, ordinal: true, instance: true }" }],
56
102
  },
57
103
  patterns: [
58
104
  { "pattern": [{ type: 'digit' }, { repeat: true }, 'th'], defs: [{id: "ordinal", uuid: '1', initial: "{ value: int(substr(text, -2)), ordinal: true, instance: true }" }]},
package/common/pipboy.js CHANGED
@@ -417,7 +417,7 @@ const config = {
417
417
  generatorp: ({context, g}) => `${context.marker} ${g(context.type)}`,
418
418
  isA: ['verby'],
419
419
  semantic: ({context, kms}) => {
420
- kms.dialogues.api.mentioned({
420
+ kms.dialogues.api.remember({
421
421
  marker: context.type.marker,
422
422
  value: context.type.marker
423
423
  })
@@ -485,6 +485,7 @@ const config = {
485
485
  !(context.types || []).includes('property') &&
486
486
  // !context.value && // greghere
487
487
  !context.ordinal &&
488
+ (!context.objects || context.objects.length !== 2 || !context.objects[1].instance) &&
488
489
  (api.objects && api.objects.children && api.objects.children[context.marker]) &&
489
490
  !context.evaluate.toConcept,
490
491
  apply: ({context, objects, api, km}) => {
@@ -625,7 +626,7 @@ const config = {
625
626
  !context.evaluate.toConcept, // && !context.value,
626
627
  // greghere
627
628
  // match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'property') && context.evaluate,
628
- apply: async ({callId, context, api, kms, objects, g, s, log, mentions}) => {
629
+ apply: async ({callId, context, api, kms, objects, g, s, log, recall}) => {
629
630
  const toDo = [ ...context.objects ]
630
631
 
631
632
  async function toValue(objectContext) {
@@ -666,7 +667,7 @@ const config = {
666
667
 
667
668
  let fromMentions
668
669
  if (!await api.knownProperty(currentContext, nextContext)) {
669
- fromMentions = await mentions({ context: nextContext, frameOfReference: currentContext })
670
+ fromMentions = await recall({ context: nextContext, all: nextContext.number == 'many', frameOfReference: currentContext })
670
671
  if (!fromMentions) {
671
672
  context.verbatim = `There is no property ${await g({...nextContext, paraphrase: true})} of ${await g({...currentContext, paraphrase: true})}`
672
673
  return
@@ -20,7 +20,7 @@
20
20
  "semantics": [
21
21
  {
22
22
  "match": "({context}) => context.marker == 'convertToUnits' && context.evaluate && (context.from?.unit?.marker == 'unitPerUnit' || context.to.marker == 'unitPerUnit')",
23
- "apply": "async ({mentioned, context, kms, e, callId, resolveEvaluate, toEValue, error}) => {\n\n async function convert(fromUnits, fromAmount, toUnits) {\n let evalue;\n if (toUnits.value == fromUnits.value) {\n evalue = fromAmount\n // if (!fromAmount.value) {\n // debugger\n //}\n evalue.evalue = fromAmount.evalue || fromAmount.value\n } else {\n const formula = kms.formulas.api.get(toUnits, [fromUnits])\n if (!formula) {\n const reason = { marker: 'reason', focusableForPhrase: true, evalue: { marker: 'noconversion', from: fromUnits, to: toUnits } }\n kms.stm.api.mentioned({ context: reason })\n error(reason)\n }\n kms.stm.api.setVariable(fromUnits.value, fromAmount)\n evalue = await e(formula)\n }\n return evalue\n }\n\n if (!context.from.unit) {\n resolveEvaluate(context.from, await e(context.from))\n }\n\n\n const from = toEValue(context.from)\n mentioned(context.to)\n const evalueNumerator = await convert(from.unit.numerator, from.amount, context.to.numerator)\n const evalueDenominator = await convert(from.unit.denominator, 1, context.to.denominator)\n const evalue = { evalue: (toFinalValue(evalueNumerator) || evalueNumerator.value) / (toFinalValue(evalueDenominator) || evalueDenominator.evalue) }\n context.evalue = {\n paraphrase: true,\n marker: 'quantity',\n level: 1,\n unit: context.to,\n amount: { evalue, paraphrase: undefined }\n }\n }"
23
+ "apply": "async ({remember, context, kms, e, callId, resolveEvaluate, toEValue, error}) => {\n\n async function convert(fromUnits, fromAmount, toUnits) {\n let evalue;\n if (toUnits.value == fromUnits.value) {\n evalue = fromAmount\n // if (!fromAmount.value) {\n // debugger\n //}\n evalue.evalue = fromAmount.evalue || fromAmount.value\n } else {\n const formula = kms.formulas.api.get(toUnits, [fromUnits])\n if (!formula) {\n const reason = { marker: 'reason', focusableForPhrase: true, evalue: { marker: 'noconversion', from: fromUnits, to: toUnits } }\n kms.stm.api.remember({ context: reason })\n error(reason)\n }\n kms.stm.api.setVariable(fromUnits.value, fromAmount)\n evalue = await e(formula)\n }\n return evalue\n }\n\n if (!context.from.unit) {\n resolveEvaluate(context.from, await e(context.from))\n }\n\n\n const from = toEValue(context.from)\n remember(context.to)\n const evalueNumerator = await convert(from.unit.numerator, from.amount, context.to.numerator)\n const evalueDenominator = await convert(from.unit.denominator, 1, context.to.denominator)\n const evalue = { evalue: (toFinalValue(evalueNumerator) || evalueNumerator.value) / (toFinalValue(evalueDenominator) || evalueDenominator.evalue) }\n context.evalue = {\n paraphrase: true,\n marker: 'quantity',\n level: 1,\n unit: context.to,\n amount: { evalue, paraphrase: undefined }\n }\n }"
24
24
  }
25
25
  ]
26
26
  }
package/common/rates.js CHANGED
@@ -37,7 +37,7 @@ const template = {
37
37
  {
38
38
  where: where(),
39
39
  match: ({context}) => context.marker == 'convertToUnits' && context.evaluate && (context.from?.unit?.marker == 'unitPerUnit' || context.to.marker == 'unitPerUnit'),
40
- apply: async ({mentioned, context, kms, e, callId, resolveEvaluate, toEValue, error}) => {
40
+ apply: async ({remember, context, kms, e, callId, resolveEvaluate, toEValue, error}) => {
41
41
 
42
42
  async function convert(fromUnits, fromAmount, toUnits) {
43
43
  let evalue;
@@ -51,7 +51,7 @@ const template = {
51
51
  const formula = kms.formulas.api.get(toUnits, [fromUnits])
52
52
  if (!formula) {
53
53
  const reason = { marker: 'reason', focusableForPhrase: true, evalue: { marker: 'noconversion', from: fromUnits, to: toUnits } }
54
- kms.stm.api.mentioned({ context: reason })
54
+ kms.stm.api.remember({ context: reason })
55
55
  error(reason)
56
56
  }
57
57
  kms.stm.api.setVariable(fromUnits.value, fromAmount)
@@ -66,7 +66,7 @@ const template = {
66
66
 
67
67
 
68
68
  const from = toEValue(context.from)
69
- mentioned(context.to)
69
+ remember(context.to)
70
70
  const evalueNumerator = await convert(from.unit.numerator, from.amount, context.to.numerator)
71
71
  const evalueDenominator = await convert(from.unit.denominator, 1, context.to.denominator)
72
72
  const evalue = { evalue: (toFinalValue(evalueNumerator) || evalueNumerator.value) / (toFinalValue(evalueDenominator) || evalueDenominator.evalue) }
@@ -106,7 +106,7 @@ class API {
106
106
  const id = ++this._objects.id
107
107
  reminder.id = id
108
108
  this._objects.reminders.push(reminder)
109
- this.args.mentioned({ context: reminder })
109
+ this.args.remember({ context: reminder })
110
110
  this._objects.current = id
111
111
  }
112
112