tpmkms_4wp 9.5.1-beta.30 → 9.5.1-beta.31

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.
@@ -1,5 +1,5 @@
1
- const { knowledgeModule, where, Digraph } = require('./runtime').theprogrammablemind
2
- const { defaultObjectCheck, defaultContextCheck } = require('./helpers')
1
+ const { debug, knowledgeModule, where, Digraph } = require('./runtime').theprogrammablemind
2
+ const { defaultObjectCheck, defaultContextCheck, defaultContextCheckProperties } = require('./helpers')
3
3
  const hierarchy = require('./hierarchy.js')
4
4
  const formulas = require('./formulas.js')
5
5
  const testing = require('./testing.js')
@@ -32,8 +32,21 @@ const instance = require('./dimension.instance.json')
32
32
  */
33
33
  class API {
34
34
 
35
- initialize({ config }) {
35
+ initialize({ config, objects }) {
36
36
  this._config = config
37
+ this._objects = objects
38
+ }
39
+
40
+ setMeasurementSystem(measurementSystem) {
41
+ this._objects.measurementSystem = measurementSystem
42
+ }
43
+
44
+ // if the user says 2 feet deduce english etc
45
+ deduceMeasurementSystem(utterance) {
46
+ }
47
+
48
+ getMeasurementSystem() {
49
+ return this._objects.measurementSystem
37
50
  }
38
51
 
39
52
  setup( {dimension, units} ) {
@@ -65,7 +78,6 @@ const config = {
65
78
  operators: [
66
79
  "([quantity])",
67
80
  "([unit])",
68
- // "(([unit]) [kindOfDimension|of] ([dimension]))",
69
81
  "((amount/* || number/*) [amountOfCoordinate|] ([unit]))",
70
82
  "(([amount]) [unit])",
71
83
  "((@<=quantity || context.possession == true) [convertToUnits|in] (unit))",
@@ -106,15 +118,6 @@ const config = {
106
118
  scope: "testing"
107
119
  },
108
120
  { id: "amount", },
109
- /*
110
- {
111
- id: "kindOfDimension",
112
- bridge: "{ ...next(operator), subclass: before[0], class: after[0], value: concat(before[0].marker.id, after[0].marker.id) }",
113
- // bridge: "{ ...next(operator), subclass: before[0], class: after[0], value: concat(before[0].marker, after[0].marker) }",
114
- isA: ['preposition'],
115
- generatorp: ({context, gp}) => `${gp(context.subclass)} ${context.word} ${gp(context.class)}`,
116
- },
117
- */
118
121
  {
119
122
  where: where(),
120
123
  id: "degree",
@@ -126,9 +129,7 @@ const config = {
126
129
  {
127
130
  id: "amountOfCoordinate",
128
131
  convolution: true,
129
- // bridge: "{ marker: next(catch(operator(after[0].dimension), operator('dimension'))), dead: true, unit: after[0], value: before[0].value, amount: before[0] }"
130
132
  bridge: "{ marker: next(operator('quantity')), dead: true, unit: after[0], value: before[0].value, amount: before[0] }"
131
- // bridge: "{ marker: operator('dimension'), unit: after[0], value: before[0].value, amount: before[0] }"
132
133
  },
133
134
  {
134
135
  where: where(),
@@ -221,19 +222,14 @@ const config = {
221
222
 
222
223
  const template = {
223
224
  configs: [
224
- "dimension and unit are concepts",
225
+ "measurement modifies unit",
226
+ "dimension and measurement unit are concepts",
227
+ "unit means measurement unit",
225
228
  ({apis}) => {
226
229
  apis('properties').addHierarchyWatcher({
227
- match: ({parentId, isA}) => isA(parentId, 'unit'),
228
- apply: ({config, childId, parent}) => {
230
+ match: ({parentId, isA}) => isA(parentId, 'unit') && parentId.startsWith('unit_'),
231
+ apply: ({config, childId, parent, parentId}) => {
229
232
  config.updateBridge(childId, ({ bridge }) => {
230
- // console.log(JSON.stringify(childId, null, 2))
231
- // console.log(JSON.stringify(parentId, null, 2))
232
- // debugger
233
- // if (!bridge) {
234
- // debugger
235
- // return
236
- // }
237
233
  if (!bridge.init) {
238
234
  bridge.init = {}
239
235
  }
@@ -243,7 +239,32 @@ const template = {
243
239
  }
244
240
  })
245
241
  },
242
+ "metric modifies system",
243
+ "imperial modifies system",
244
+ "measurement modifies system",
245
+ "the metric system is a measurement system",
246
+ "the imperial system is a measurement system",
247
+ "imperial modifies unit",
248
+ "metric modifies unit",
249
+ "imperial unit is a unit",
250
+ "metric unit is a unit",
246
251
  config,
252
+ {
253
+ operators: [
254
+ "([useMeasurementSystem|use] (measurement_system))",
255
+ ],
256
+ bridges: [
257
+ {
258
+ id: 'useMeasurementSystem',
259
+ isA: ['verb'],
260
+ bridge: "{ ...next(operator), system: after[0], interpolate: [ { context: operator }, { property: 'system' } ] }",
261
+ semantic: ({context, api}) => {
262
+ api.setMeasurementSystem(context.system.value)
263
+ },
264
+ check: defaultContextCheckProperties(['system']),
265
+ },
266
+ ],
267
+ },
247
268
  ],
248
269
  }
249
270
 
@@ -259,15 +280,19 @@ knowledgeModule({
259
280
  name: './dimension.test.json',
260
281
  contents: tests,
261
282
  checks: {
262
- objects: [{ km: 'properties' }],
283
+ objects: [
284
+ { km: 'properties' },
285
+ { path: ['measurementSystem'] },
286
+ ],
263
287
  context: [
288
+ defaultContextCheck({ marker: 'metric_system', exported: true }),
264
289
  defaultContextCheck({ marker: 'convertToUnits', exported: true, extra: ['from', 'to'] }),
265
290
  defaultContextCheck({
266
291
  match: ({context, isA}) => isA(context.marker, 'unit'),
267
292
  exported: true,
268
293
  extra: ['dimension'],
269
294
  }),
270
- defaultContextCheck(['dimension', 'response']),
295
+ // defaultContextCheck(['dimension', 'response']),
271
296
  ],
272
297
  },
273
298
  },