ekms 8.0.0-beta.37 → 8.0.0-beta.39

Sign up to get free protection for your applications and to get access to all the features.
@@ -681,7 +681,7 @@ let configStruct = {
681
681
  value = JSON.parse(JSON.stringify(value))
682
682
  let instance = await e(value)
683
683
  if (false && instance.evalue) {
684
- km('stm').api.mentioned(value)
684
+ km('stm').api.mentioned({ context: value })
685
685
  }
686
686
  if (instance.verbatim) {
687
687
  context.evalue = { verbatim: instance.verbatim }
@@ -778,7 +778,7 @@ let configStruct = {
778
778
  if (!onePrime.sameWasProcessed && !twoPrime.sameWasProcessed) {
779
779
  api.makeObject({ context: one, config, types: context.two.types || [] })
780
780
  kms.stm.api.setVariable(one.value, two)
781
- kms.stm.api.mentioned(one, two)
781
+ kms.stm.api.mentioned({ context: one, value: two })
782
782
  }
783
783
  }
784
784
  },
@@ -102,7 +102,7 @@
102
102
  ]
103
103
  ],
104
104
  "generatorp": "async ({context, g}) => `${await g(context.from)} ${context.word} ${await g(context.to)}`",
105
- "evaluator": "async ({context, kms, e, error}) => {\n /*\n error(({context, e}) => {\n context.evalue = 'dont know...'\n })\n */\n const from = context.from;\n const to = context.to;\n let evalue;\n let efrom = from\n if (!from.unit) {\n efrom = (await e(from)).evalue\n }\n if (to.value == efrom.unit.value) {\n evalue = efrom.amount\n } else {\n const formula = kms.formulas.api.get(to, [efrom.unit])\n if (!formula) {\n const reason = { marker: 'reason', focusableForPhrase: true, evalue: { marker: 'noconversion', from: efrom.unit, to } }\n kms.stm.api.mentioned(reason)\n error(reason)\n }\n kms.stm.api.setVariable(efrom.unit.value, efrom.amount)\n evalue = await e(formula)\n }\n /*\n '{\n \"marker\":\"dimension\",\n \"unit\":{\"marker\":\"unit\",\"range\":{\"start\":19,\"end\":25},\"word\":\"celcius\",\"text\":\"celcius\",\"value\":\"celcius\",\"unknown\":true,\"types\":[\"unit\",\"unknown\"]},\n \"value\":10,\n \"amount\":{\"word\":\"degrees\",\"number\":\"many\",\"text\":\"10 degrees\",\"marker\":\"degree\",\"range\":{\"start\":8,\"end\":17},\"value\":10,\"amount\":{\"value\":10,\"text\":\"10\",\"marker\":\"number\",\"word\":\"10\",\"range\":{\"start\":8,\"end\":9},\"types\":[\"number\"]}},\n \"text\":\"10 degrees celcius\",\"range\":{\"start\":8,\"end\":25}}'\n */\n context.evalue = { \n paraphrase: true,\n marker: 'dimension',\n level: 1,\n unit: to,\n amount: { evalue, paraphrase: undefined }\n }\n }"
105
+ "evaluator": "async ({context, kms, e, error}) => {\n /*\n error(({context, e}) => {\n context.evalue = 'dont know...'\n })\n */\n const from = context.from;\n const to = context.to;\n let evalue;\n let efrom = from\n if (!from.unit) {\n efrom = (await e(from)).evalue\n }\n if (to.value == efrom.unit.value) {\n evalue = efrom.amount\n } else {\n const formula = kms.formulas.api.get(to, [efrom.unit])\n if (!formula) {\n const reason = { marker: 'reason', focusableForPhrase: true, evalue: { marker: 'noconversion', from: efrom.unit, to } }\n kms.stm.api.mentioned({ context: reason })\n error(reason)\n }\n kms.stm.api.setVariable(efrom.unit.value, efrom.amount)\n evalue = await e(formula)\n }\n /*\n '{\n \"marker\":\"dimension\",\n \"unit\":{\"marker\":\"unit\",\"range\":{\"start\":19,\"end\":25},\"word\":\"celcius\",\"text\":\"celcius\",\"value\":\"celcius\",\"unknown\":true,\"types\":[\"unit\",\"unknown\"]},\n \"value\":10,\n \"amount\":{\"word\":\"degrees\",\"number\":\"many\",\"text\":\"10 degrees\",\"marker\":\"degree\",\"range\":{\"start\":8,\"end\":17},\"value\":10,\"amount\":{\"value\":10,\"text\":\"10\",\"marker\":\"number\",\"word\":\"10\",\"range\":{\"start\":8,\"end\":9},\"types\":[\"number\"]}},\n \"text\":\"10 degrees celcius\",\"range\":{\"start\":8,\"end\":25}}'\n */\n context.evalue = { \n paraphrase: true,\n marker: 'dimension',\n level: 1,\n unit: to,\n amount: { evalue, paraphrase: undefined }\n }\n }"
106
106
  },
107
107
  {
108
108
  "id": "unit"
@@ -140,7 +140,7 @@ let configStruct = {
140
140
  const formula = kms.formulas.api.get(to, [efrom.unit])
141
141
  if (!formula) {
142
142
  const reason = { marker: 'reason', focusableForPhrase: true, evalue: { marker: 'noconversion', from: efrom.unit, to } }
143
- kms.stm.api.mentioned(reason)
143
+ kms.stm.api.mentioned({ context: reason })
144
144
  error(reason)
145
145
  }
146
146
  kms.stm.api.setVariable(efrom.unit.value, efrom.amount)
@@ -917,7 +917,7 @@ class State {
917
917
  }
918
918
 
919
919
  this.api.add(item)
920
- this.api.args.mentioned(food)
920
+ this.api.args.mentioned({ context: food })
921
921
 
922
922
  for (const addIt of addsInsteadOfModifications) {
923
923
  this.add(addIt)
@@ -12,13 +12,13 @@ class API {
12
12
 
13
13
  // report is a context
14
14
  setName(context, name) {
15
- if (!context.nameable) {
16
- context.nameable = {}
15
+ if (!context.stm) {
16
+ context.stm = {}
17
17
  }
18
- if (!context.nameable.names) {
19
- context.nameable.names = []
18
+ if (!context.stm.names) {
19
+ context.stm.names = []
20
20
  }
21
- context.nameable.names.push(name)
21
+ context.stm.names.push(name)
22
22
  }
23
23
 
24
24
  get(name) {
@@ -29,8 +29,8 @@ class API {
29
29
  const contexts = this.args.kms.stm.api.getByType(type)
30
30
  const names = new Set()
31
31
  for (const context of contexts) {
32
- if (context.nameable.names) {
33
- for (const name of context.nameable.names) {
32
+ if (context.stm.names) {
33
+ for (const name of context.stm.names) {
34
34
  names.add(name)
35
35
  }
36
36
  }
@@ -50,7 +50,7 @@ class API {
50
50
  setCurrent(name) {
51
51
  const context = this.objects.named[name]
52
52
  if (context) {
53
- this.args.km('stm').api.mentioned(context)
53
+ this.args.km('stm').api.mentioned({ context })
54
54
  }
55
55
  }
56
56
  }
@@ -93,18 +93,16 @@
93
93
  "fromSTM": true,
94
94
  "level": 1,
95
95
  "marker": "m1",
96
- "nameable": {
97
- "names": [
98
- "banana"
99
- ]
100
- },
101
96
  "pullFromContext": false,
102
97
  "range": {
103
98
  "end": 10,
104
99
  "start": 9
105
100
  },
106
101
  "stm": {
107
- "id": 1
102
+ "id": 1,
103
+ "names": [
104
+ "banana"
105
+ ]
108
106
  },
109
107
  "text": "m1",
110
108
  "types": [
@@ -353,18 +351,16 @@
353
351
  "fromSTM": true,
354
352
  "level": 1,
355
353
  "marker": "m1",
356
- "nameable": {
357
- "names": [
358
- "banana"
359
- ]
360
- },
361
354
  "pullFromContext": false,
362
355
  "range": {
363
356
  "end": 10,
364
357
  "start": 9
365
358
  },
366
359
  "stm": {
367
- "id": 1
360
+ "id": 1,
361
+ "names": [
362
+ "banana"
363
+ ]
368
364
  },
369
365
  "text": "m1",
370
366
  "types": [
@@ -463,18 +459,16 @@
463
459
  "fromSTM": true,
464
460
  "level": 1,
465
461
  "marker": "m1",
466
- "nameable": {
467
- "names": [
468
- "banana"
469
- ]
470
- },
471
462
  "pullFromContext": false,
472
463
  "range": {
473
464
  "end": 10,
474
465
  "start": 9
475
466
  },
476
467
  "stm": {
477
- "id": 1
468
+ "id": 1,
469
+ "names": [
470
+ "banana"
471
+ ]
478
472
  },
479
473
  "text": "m1",
480
474
  "types": [
@@ -549,18 +543,16 @@
549
543
  "fromSTM": true,
550
544
  "level": 1,
551
545
  "marker": "m1",
552
- "nameable": {
553
- "names": [
554
- "banana"
555
- ]
556
- },
557
546
  "pullFromContext": false,
558
547
  "range": {
559
548
  "end": 10,
560
549
  "start": 9
561
550
  },
562
551
  "stm": {
563
- "id": 1
552
+ "id": 1,
553
+ "names": [
554
+ "banana"
555
+ ]
564
556
  },
565
557
  "text": "m1",
566
558
  "types": [
@@ -650,18 +642,16 @@
650
642
  "fromSTM": true,
651
643
  "level": 1,
652
644
  "marker": "m1",
653
- "nameable": {
654
- "names": [
655
- "banana"
656
- ]
657
- },
658
645
  "pullFromContext": false,
659
646
  "range": {
660
647
  "end": 10,
661
648
  "start": 9
662
649
  },
663
650
  "stm": {
664
- "id": 1
651
+ "id": 1,
652
+ "names": [
653
+ "banana"
654
+ ]
665
655
  },
666
656
  "text": "m1",
667
657
  "types": [
@@ -868,18 +858,16 @@
868
858
  "fromSTM": true,
869
859
  "level": 1,
870
860
  "marker": "m1",
871
- "nameable": {
872
- "names": [
873
- "banana"
874
- ]
875
- },
876
861
  "pullFromContext": false,
877
862
  "range": {
878
863
  "end": 10,
879
864
  "start": 9
880
865
  },
881
866
  "stm": {
882
- "id": 1
867
+ "id": 1,
868
+ "names": [
869
+ "banana"
870
+ ]
883
871
  },
884
872
  "text": "m1",
885
873
  "types": [
@@ -916,18 +904,16 @@
916
904
  "fromSTM": true,
917
905
  "level": 1,
918
906
  "marker": "m1",
919
- "nameable": {
920
- "names": [
921
- "banana"
922
- ]
923
- },
924
907
  "pullFromContext": false,
925
908
  "range": {
926
909
  "end": 10,
927
910
  "start": 9
928
911
  },
929
912
  "stm": {
930
- "id": 1
913
+ "id": 1,
914
+ "names": [
915
+ "banana"
916
+ ]
931
917
  },
932
918
  "text": "m1",
933
919
  "types": [
@@ -1045,18 +1031,16 @@
1045
1031
  "fromSTM": true,
1046
1032
  "level": 1,
1047
1033
  "marker": "m1",
1048
- "nameable": {
1049
- "names": [
1050
- "banana"
1051
- ]
1052
- },
1053
1034
  "pullFromContext": false,
1054
1035
  "range": {
1055
1036
  "end": 10,
1056
1037
  "start": 9
1057
1038
  },
1058
1039
  "stm": {
1059
- "id": 1
1040
+ "id": 1,
1041
+ "names": [
1042
+ "banana"
1043
+ ]
1060
1044
  },
1061
1045
  "text": "m1",
1062
1046
  "types": [
@@ -1133,18 +1117,16 @@
1133
1117
  "fromSTM": true,
1134
1118
  "level": 1,
1135
1119
  "marker": "m1",
1136
- "nameable": {
1137
- "names": [
1138
- "banana"
1139
- ]
1140
- },
1141
1120
  "pullFromContext": false,
1142
1121
  "range": {
1143
1122
  "end": 10,
1144
1123
  "start": 9
1145
1124
  },
1146
1125
  "stm": {
1147
- "id": 1
1126
+ "id": 1,
1127
+ "names": [
1128
+ "banana"
1129
+ ]
1148
1130
  },
1149
1131
  "text": "m1",
1150
1132
  "types": [
@@ -1424,18 +1406,16 @@
1424
1406
  "fromSTM": true,
1425
1407
  "level": 1,
1426
1408
  "marker": "m1",
1427
- "nameable": {
1428
- "names": [
1429
- "banana"
1430
- ]
1431
- },
1432
1409
  "pullFromContext": false,
1433
1410
  "range": {
1434
1411
  "end": 10,
1435
1412
  "start": 9
1436
1413
  },
1437
1414
  "stm": {
1438
- "id": 1
1415
+ "id": 1,
1416
+ "names": [
1417
+ "banana"
1418
+ ]
1439
1419
  },
1440
1420
  "text": "m1",
1441
1421
  "types": [
@@ -1573,18 +1553,16 @@
1573
1553
  "fromSTM": true,
1574
1554
  "level": 1,
1575
1555
  "marker": "m1",
1576
- "nameable": {
1577
- "names": [
1578
- "banana"
1579
- ]
1580
- },
1581
1556
  "pullFromContext": false,
1582
1557
  "range": {
1583
1558
  "end": 10,
1584
1559
  "start": 9
1585
1560
  },
1586
1561
  "stm": {
1587
- "id": 1
1562
+ "id": 1,
1563
+ "names": [
1564
+ "banana"
1565
+ ]
1588
1566
  },
1589
1567
  "text": "m1",
1590
1568
  "types": [
@@ -1651,18 +1629,16 @@
1651
1629
  "fromSTM": true,
1652
1630
  "level": 1,
1653
1631
  "marker": "m1",
1654
- "nameable": {
1655
- "names": [
1656
- "banana"
1657
- ]
1658
- },
1659
1632
  "pullFromContext": false,
1660
1633
  "range": {
1661
1634
  "end": 10,
1662
1635
  "start": 9
1663
1636
  },
1664
1637
  "stm": {
1665
- "id": 1
1638
+ "id": 1,
1639
+ "names": [
1640
+ "banana"
1641
+ ]
1666
1642
  },
1667
1643
  "text": "m1",
1668
1644
  "types": [
@@ -1754,18 +1730,16 @@
1754
1730
  "fromSTM": true,
1755
1731
  "level": 1,
1756
1732
  "marker": "m1",
1757
- "nameable": {
1758
- "names": [
1759
- "banana"
1760
- ]
1761
- },
1762
1733
  "pullFromContext": false,
1763
1734
  "range": {
1764
1735
  "end": 10,
1765
1736
  "start": 9
1766
1737
  },
1767
1738
  "stm": {
1768
- "id": 1
1739
+ "id": 1,
1740
+ "names": [
1741
+ "banana"
1742
+ ]
1769
1743
  },
1770
1744
  "text": "m1",
1771
1745
  "types": [
@@ -1936,18 +1910,16 @@
1936
1910
  "fromSTM": true,
1937
1911
  "level": 1,
1938
1912
  "marker": "m1",
1939
- "nameable": {
1940
- "names": [
1941
- "banana"
1942
- ]
1943
- },
1944
1913
  "pullFromContext": false,
1945
1914
  "range": {
1946
1915
  "end": 10,
1947
1916
  "start": 9
1948
1917
  },
1949
1918
  "stm": {
1950
- "id": 1
1919
+ "id": 1,
1920
+ "names": [
1921
+ "banana"
1922
+ ]
1951
1923
  },
1952
1924
  "text": "m1",
1953
1925
  "types": [
@@ -1986,18 +1958,16 @@
1986
1958
  "fromSTM": true,
1987
1959
  "level": 1,
1988
1960
  "marker": "m1",
1989
- "nameable": {
1990
- "names": [
1991
- "banana"
1992
- ]
1993
- },
1994
1961
  "pullFromContext": false,
1995
1962
  "range": {
1996
1963
  "end": 10,
1997
1964
  "start": 9
1998
1965
  },
1999
1966
  "stm": {
2000
- "id": 1
1967
+ "id": 1,
1968
+ "names": [
1969
+ "banana"
1970
+ ]
2001
1971
  },
2002
1972
  "text": "m1",
2003
1973
  "types": [
@@ -2096,18 +2066,16 @@
2096
2066
  "fromSTM": true,
2097
2067
  "level": 1,
2098
2068
  "marker": "m1",
2099
- "nameable": {
2100
- "names": [
2101
- "banana"
2102
- ]
2103
- },
2104
2069
  "pullFromContext": false,
2105
2070
  "range": {
2106
2071
  "end": 10,
2107
2072
  "start": 9
2108
2073
  },
2109
2074
  "stm": {
2110
- "id": 1
2075
+ "id": 1,
2076
+ "names": [
2077
+ "banana"
2078
+ ]
2111
2079
  },
2112
2080
  "text": "m1",
2113
2081
  "types": [
package/common/reports.js CHANGED
@@ -38,7 +38,7 @@ const compareValue = (property, v1, v2) => {
38
38
  const newReport = ({km, objects}) => {
39
39
  objects.tempReportId += 1
40
40
  const reportId = `tempReport${objects.tempReportId}`
41
- km('stm').api.mentioned({ marker: "report", text: reportId, types: [ "report" ], value: reportId, word: reportId })
41
+ km('stm').api.mentioned({ context: { marker: "report", text: reportId, types: [ "report" ], value: reportId, word: reportId } })
42
42
  // name to listing
43
43
  objects.listings[reportId] = {
44
44
  columns: ['name', 'supplier'],
@@ -336,12 +336,14 @@ let configStruct = {
336
336
  objects.listings[name] = {...listing}
337
337
  config.addWord(`${name}`, { id: 'report', initial: `{ value: "${name}" }` })
338
338
  km('stm').api.mentioned({
339
+ context: {
339
340
  marker: "report",
340
341
  text: name,
341
342
  types: [ "report" ],
342
343
  value: id,
343
344
  word: name
344
- })
345
+ }
346
+ })
345
347
  }
346
348
  },
347
349
  ],
@@ -43,7 +43,7 @@ const setNextPlayer = (km, objects) => {
43
43
  word: "turn"
44
44
  }
45
45
  const api = km('stm').api
46
- api.mentioned(turn)
46
+ api.mentioned({ context: turn })
47
47
  }
48
48
 
49
49
  const addPlayer = (objects, config, player) => {
package/common/stm.js CHANGED
@@ -39,7 +39,7 @@ class API {
39
39
  return this._objects.mentioned.filter( (context) => this.isA(context.marker, type) )
40
40
  }
41
41
 
42
- mentioned(concept, value = undefined) {
42
+ mentioned({ context:concept, value=null } = {}) {
43
43
  // TODO value should perhaps have been called id as in concept id and then value could be value
44
44
  if (value) {
45
45
  concept = { ...concept, pullFromContext: false }
@@ -65,7 +65,7 @@ class API {
65
65
  this._objects.mentioned.unshift(concept)
66
66
  }
67
67
 
68
- mentions(context, useHierarchy=true) {
68
+ mentions({ context, useHierarchy=true } = {}) {
69
69
  const findPrevious = !!context.stm_previous
70
70
 
71
71
  // care about value first
@@ -126,7 +126,7 @@ class API {
126
126
  if (!name) {
127
127
  return
128
128
  }
129
- let valueNew = this.mentions({ marker: name, value: name }, false) || name
129
+ let valueNew = this.mentions({ context: { marker: name, value: name }, useHierarchy: false }) || name
130
130
  if (valueNew && valueNew.value) {
131
131
  valueNew = valueNew.value
132
132
  }
@@ -134,7 +134,7 @@ class API {
134
134
  }
135
135
 
136
136
  setVariable(name, value) {
137
- this.mentioned({ marker: name }, value)
137
+ this.mentioned({ context: { marker: name }, value })
138
138
  }
139
139
  }
140
140
 
@@ -168,7 +168,7 @@ const configStruct = {
168
168
  if (value == context.rememberee.value) {
169
169
  value = context.rememberee
170
170
  }
171
- api.mentioned(value)
171
+ api.mentioned({ context: value })
172
172
  },
173
173
  },
174
174
  {
@@ -188,7 +188,7 @@ const configStruct = {
188
188
  // match: ({context}) => context.marker == 'it' && context.pullFromContext, // && context.value,
189
189
  match: ({context, callId}) => context.pullFromContext && !context.same, // && context.value,
190
190
  apply: async ({callId, context, kms, e, log, retry}) => {
191
- context.value = kms.stm.api.mentions(context)
191
+ context.value = kms.stm.api.mentions({ context })
192
192
  if (!context.value) {
193
193
  // retry()
194
194
  context.value = { marker: 'answerNotKnown' }
@@ -213,11 +213,11 @@ let createConfig = async () => {
213
213
 
214
214
  await config.initializer( ({config}) => {
215
215
  config.addArgs(({kms}) => ({
216
- mentioned: (context) => {
217
- kms.stm.api.mentioned(context)
216
+ mentioned: ({ context }) => {
217
+ kms.stm.api.mentioned({ context })
218
218
  },
219
- mentions: (context) => {
220
- return kms.stm.api.mentions(context)
219
+ mentions: ({ context }) => {
220
+ return kms.stm.api.mentions({ context })
221
221
  },
222
222
  }))
223
223
  })
package/package.json CHANGED
@@ -291,8 +291,8 @@
291
291
  "table": "^6.7.1",
292
292
  "base-64": "^1.0.0",
293
293
  "argparse": "^2.0.1",
294
- "theprogrammablemind": "8.0.0-beta.37"
294
+ "theprogrammablemind": "8.0.0-beta.39"
295
295
  },
296
- "version": "8.0.0-beta.37",
296
+ "version": "8.0.0-beta.39",
297
297
  "license": "UNLICENSED"
298
298
  }