theprogrammablemind_4wp 7.6.0-beta.9 → 7.7.0-beta.0

Sign up to get free protection for your applications and to get access to all the features.
package/client.js CHANGED
@@ -1182,7 +1182,7 @@ const defaultInnerProcess = (config, errorHandler, responses) => {
1182
1182
  }
1183
1183
 
1184
1184
  if (responses.explain_priorities) {
1185
- console.log("Explain Priorities")
1185
+ console.log("Explain Priorities (listed from lower priority to higher priority)")
1186
1186
  for ([inputss, outpus, reason] of responses.explain_priorities) {
1187
1187
  console.log(` ${JSON.stringify(inputss)} reason: ${reason}`)
1188
1188
  }
@@ -1283,6 +1283,7 @@ const rebuildTemplate = async ({ config, target, template, errorHandler = defaul
1283
1283
  }
1284
1284
  if (results.contexts.length > 1) {
1285
1285
  console.log(`query "${query.query}". There is ${results.contexts.length} contexts in the results. Make sure its producing the results that you expect.`)
1286
+ throw new Error(`query "${query.query}". There is ${results.contexts.length} contexts in the results. Make sure its producing the results that you expect.`)
1286
1287
  } else if (results.paraphrases[0] != query.query) {
1287
1288
  console.log(`query "${query.query}". The paraphrase is different from the query "${results.paraphrases[0]}".`)
1288
1289
  } else {
@@ -1308,14 +1309,18 @@ const rebuildTemplate = async ({ config, target, template, errorHandler = defaul
1308
1309
  // it will just get added to the config
1309
1310
  const extraConfig = queryOrExtraConfig
1310
1311
  console.log('config', extraConfig)
1311
- try {
1312
- config.addInternal(_.cloneDeep(extraConfig), { handleCalculatedProps: true } )
1313
- } catch ( e ) {
1314
- const where = extraConfig.where ? ` ${extraConfig.where}` : ''
1315
- throw new Error(`Error processing extra config${where}: ${e.stack}}`)
1312
+ if (extraConfig.stop) {
1313
+ await looper([])
1314
+ } else {
1315
+ try {
1316
+ config.addInternal(_.cloneDeep(extraConfig), { handleCalculatedProps: true } )
1317
+ } catch ( e ) {
1318
+ const where = extraConfig.where ? ` ${extraConfig.where}` : ''
1319
+ throw new Error(`Error processing extra config${where}: ${e.stack}}`)
1320
+ }
1321
+ accumulators[property].push({ extraConfig: true, ...extraConfig })
1322
+ await looper(queries)
1316
1323
  }
1317
- accumulators[property].push({ extraConfig: true, ...extraConfig })
1318
- await looper(queries)
1319
1324
  }
1320
1325
  }
1321
1326
 
@@ -1398,7 +1403,7 @@ const checkTest = (testConfig) => {
1398
1403
  }
1399
1404
  }
1400
1405
 
1401
- const knowledgeModule = async ({
1406
+ const knowledgeModuleImpl = async ({
1402
1407
  module: moduleFromJSFile,
1403
1408
  description,
1404
1409
  section,
@@ -1712,7 +1717,13 @@ const knowledgeModule = async ({
1712
1717
  options.rebuild = true
1713
1718
  config.config.rebuild = true
1714
1719
  }
1715
- config.load(template.template, template.instance, { rebuild: needsRebuild })
1720
+ try {
1721
+ config.load(template.template, template.instance, { rebuild: needsRebuild })
1722
+ } catch( e ) {
1723
+ debugger
1724
+ console.error(`Error loading template for ${config.name}. ${e.error ? e.error : e}`)
1725
+ runtime.process.exit(-1)
1726
+ }
1716
1727
  if (!args.query) {
1717
1728
  printConfig()
1718
1729
  }
@@ -1792,14 +1803,14 @@ const knowledgeModule = async ({
1792
1803
  console.log(` actual ${label} `, actual)
1793
1804
  newError = true
1794
1805
  headerShown = true
1806
+ if (args.vimdiff) {
1807
+ vimdiff(result.actual.paraphrasesParenthesized, result.expected.paraphrasesParenthesized)
1808
+ }
1795
1809
  }
1796
1810
  }
1797
1811
  show('paraphrases', result.expected.paraphrases, result.actual.paraphrases)
1798
1812
  if (!args.testNoParenthesized) {
1799
1813
  show('paraphrases parenthesized', result.expected.paraphrasesParenthesized, result.actual.paraphrasesParenthesized)
1800
- if (args.vimdiff) {
1801
- vimdiff(result.actual.paraphrasesParenthesized, result.expected.paraphrasesParenthesized)
1802
- }
1803
1814
  }
1804
1815
  /*
1805
1816
  }
@@ -1832,10 +1843,10 @@ const knowledgeModule = async ({
1832
1843
  }
1833
1844
  const widths = [4, 18, 72]
1834
1845
  const lines = new Lines(widths)
1835
- lines.setElement(1, 1, 'expected checked')
1846
+ lines.setElement(1, 1, 'expected checked objects')
1836
1847
  lines.setElement(2, 2, JSON.stringify(result.expected.checked, null, 2))
1837
1848
  lines.log()
1838
- lines.setElement(1, 1, 'actual checked')
1849
+ lines.setElement(1, 1, 'actual checked objects')
1839
1850
  lines.setElement(2, 2, JSON.stringify(result.actual.checked, null, 2))
1840
1851
  lines.log()
1841
1852
  if (args.vimdiff) {
@@ -1850,10 +1861,10 @@ const knowledgeModule = async ({
1850
1861
  }
1851
1862
  const widths = [4, 18, 72]
1852
1863
  const lines = new Lines(widths)
1853
- lines.setElement(1, 1, 'expected checkedContexts', true)
1864
+ lines.setElement(1, 1, 'expected checked contexts', true)
1854
1865
  lines.setElement(2, 2, JSON.stringify(result.expected.checkedContexts, null, 2))
1855
1866
  lines.log()
1856
- lines.setElement(1, 1, 'actual checkedContexts', true)
1867
+ lines.setElement(1, 1, 'actual checked contexts', true)
1857
1868
  lines.setElement(2, 2, JSON.stringify(result.actual.checkedContexts, null, 2))
1858
1869
  lines.log()
1859
1870
  if (args.vimdiff) {
@@ -1985,7 +1996,6 @@ const knowledgeModule = async ({
1985
1996
  }
1986
1997
  moduleFromJSFile.exports = createConfigExport
1987
1998
  }
1988
-
1989
1999
  }
1990
2000
 
1991
2001
  /*
@@ -2033,6 +2043,10 @@ function w(func) {
2033
2043
  return func
2034
2044
  }
2035
2045
 
2046
+ const knowledgeModule = async (...args) => {
2047
+ await knowledgeModuleImpl(...args).catch((e) => console.error(e))
2048
+ }
2049
+
2036
2050
  module.exports = {
2037
2051
  process: _process,
2038
2052
  where,
package/package.json CHANGED
@@ -64,6 +64,6 @@
64
64
  "json-stable-stringify": "^1.0.1",
65
65
  "node-fetch": "^2.6.1"
66
66
  },
67
- "version": "7.6.0-beta.9",
67
+ "version": "7.7.0-beta.0",
68
68
  "license": "ISC"
69
69
  }
package/src/config.js CHANGED
@@ -27,7 +27,7 @@ const config_toServer = (config) => {
27
27
 
28
28
  const debugPriority = (priority) => {
29
29
  if (global.entodictonDebugPriority) {
30
- if (helpers.safeEquals(entodictonDebugPriority, priority)) {
30
+ if (helpers.subPriority(entodictonDebugPriority, priority)) {
31
31
  debugger; // debug hierarchy hit
32
32
  }
33
33
  }
package/src/generators.js CHANGED
@@ -169,7 +169,7 @@ class Generators {
169
169
  // assumed - properties added to context before the generators are called. For setting paraphrase property
170
170
  apply (args, context, assumed = {}, options = {}) {
171
171
  if (Array.isArray(context)) {
172
- return new Error("Expected a context not an array")
172
+ throw new Error("Expected a context not an array")
173
173
  }
174
174
  if (typeof context !== 'object') {
175
175
  return String(context)
package/src/helpers.js CHANGED
@@ -334,6 +334,45 @@ const ecatch = (where, call) => {
334
334
  }
335
335
  }
336
336
 
337
+ const equalKey = (key1, key2) => {
338
+ return key1[0] == key2[0] && key1[1] == key2[1]
339
+ }
340
+
341
+ // matches for { context: ..., [ordered], choose: ... } exactely OR
342
+ // [ <id1>, <id2> ] - where id1 is chosen
343
+ const subPriority = (sub, sup) => {
344
+ if (Array.isArray(sub)) {
345
+ const subChoosen = sub[0]
346
+ const subOther = sub[1]
347
+ const hasChoosen = sup.choose.find( (index) => equalKey(sup.context[index], subChoosen)) != undefined
348
+ const hasOtherChosen = sup.choose.find( (index) => equalKey(sup.context[index], subOther)) != undefined
349
+ const hasOther = sup.context.find( (other) => equalKey(other, subOther) ) !== undefined
350
+ return !!(hasChoosen && hasOther) && !hasOtherChosen
351
+ }
352
+
353
+ if (!safeEquals([...sub.choose].sort(), [...sup.choose].sort())) {
354
+ return false
355
+ }
356
+
357
+ const choose = (priority) => {
358
+ const chosen = []
359
+ for (const i of priority.choose) {
360
+ chosen.push(priority.context[i])
361
+ }
362
+ return chosen
363
+ }
364
+ const chosen1 = choose(sub)
365
+ const chosen2 = choose(sup)
366
+ const sameId = (id1, id2) => id1[0] == id2[0] && id1[1] == id2[1]
367
+ // same length so only need one way
368
+ const missing1 = chosen1.find( (id1) => !chosen2.find( (id2) => sameId(id1, id2)) )
369
+ if (missing1) {
370
+ return false
371
+ }
372
+
373
+ return true
374
+ }
375
+
337
376
  module.exports = {
338
377
  ecatch,
339
378
  functionsToStrings,
@@ -354,5 +393,6 @@ module.exports = {
354
393
  isCompound,
355
394
  InitCalls,
356
395
  hashCode,
357
- sortJson
396
+ sortJson,
397
+ subPriority,
358
398
  }
package/src/project.js CHANGED
@@ -16,6 +16,9 @@ const project = (object, filter) => {
16
16
  return object.map( element => project(element, filter) )
17
17
  } else {
18
18
  for (let properties of filter) {
19
+ if (typeof properties == 'function') {
20
+ properties = properties(object)
21
+ }
19
22
  if (typeof properties == 'object') {
20
23
  if (properties.propertyLists) {
21
24
  for (const propertyList in properties.propertyLists) {