theprogrammablemind_4wp 7.5.8-beta.5 → 7.5.8-beta.51

Sign up to get free protection for your applications and to get access to all the features.
package/client.js CHANGED
@@ -15,14 +15,16 @@ const sortJson = runtime.sortJson
15
15
 
16
16
  const getAsk = (config) => (uuid) => (asks) => {
17
17
  for (let ask of asks) {
18
- config.addMotivation({
18
+ config.addSemantic({
19
19
  uuid,
20
+ oneShot: true,
20
21
  match: (args) => ask.matchr(args),
21
22
  apply: (args) => ask.applyr(args)
22
23
  })
23
24
  }
24
- config.addMotivation({
25
+ config.addSemantic({
25
26
  uuid,
27
+ oneShot: true,
26
28
  match: ({context}) => context.marker == 'controlEnd' || context.marker == 'controlBetween',
27
29
  apply: (args) => {
28
30
  for (let ask of asks) {
@@ -37,7 +39,7 @@ const getAsk = (config) => (uuid) => (asks) => {
37
39
  }
38
40
  }
39
41
  if (matchq(args)) {
40
- args.context.motivationKeep = true
42
+ // args.context.motivationKeep = true
41
43
  args.context.verbatim = applyq(args)
42
44
  args.context.isResponse = true;
43
45
  delete args.context.controlRemove;
@@ -58,7 +60,6 @@ const vimdiff = (actualJSON, expectedJSON) => {
58
60
  // console.log(`vimdiff ${path}/actual.json ${path}/expected.json`)
59
61
  {
60
62
  const editor = runtime.process.env.EDITOR || 'vimdiff'
61
- debugger
62
63
  // const child = runtime.child_process.spawn(editor, [`${path}/expected.json`, `${path}/actual.json`], { stdio: 'inherit' })
63
64
  console.log(`${editor} ${path}/expected.json ${path}/actual.json`)
64
65
  runtime.child_process.execSync(`${editor} ${path}/expected.json ${path}/actual.json`, {stdio: 'inherit'})
@@ -109,11 +110,12 @@ class ErrorReason extends Error {
109
110
 
110
111
  const setupArgs = (args, config, logs, hierarchy) => {
111
112
  config.setArgs(args)
112
- args.calls = new InitCalls(config.name)
113
+ args.calls = new InitCalls(args.isInstance ? `${args.isInstance}#${config.name}` : config.name)
113
114
  if (global.theprogrammablemind && global.theprogrammablemind.loadForTesting) {
114
115
  args.calls = new InitCalls(Object.keys(global.theprogrammablemind.loadForTesting)[0])
115
116
  }
116
117
  args.km = (name) => config.getConfig(name)
118
+ args.api = (name) => config.getConfig(name).api
117
119
  args.error = (context) => {
118
120
  throw new ErrorReason(context)
119
121
  }
@@ -143,7 +145,6 @@ const setupArgs = (args, config, logs, hierarchy) => {
143
145
  apis: getAPIs(uuid)
144
146
  }
145
147
  }
146
- args.motivation = (m) => config.addMotivation(m)
147
148
  args.breakOnSemantics = false
148
149
  args.theDebugger = {
149
150
  breakOnSemantics: (value) => args.breakOnSemantics = value
@@ -157,10 +158,10 @@ const setupArgs = (args, config, logs, hierarchy) => {
157
158
  }
158
159
  args.e = (c) => config.getEvaluator(args.s, args.calls, logs, c)
159
160
  args.log = (message) => logs.push(message)
160
- // config.getAddedArgs(args)
161
161
  args.gs = gs(args.g)
162
162
  args.gsp = gs(args.gp)
163
163
  args.gsr = gs(args.gr)
164
+ config.getAddedArgs(args)
164
165
  }
165
166
 
166
167
  const gs = (g) => (contexts, separator, lastSeparator) => {
@@ -298,7 +299,6 @@ const writeTest = (fn, query, objects, generated, paraphrases, responses, contex
298
299
  }
299
300
  associations.sort()
300
301
  // tests[query] = sortJson({ paraphrases, responses, contexts, objects: convertToStable(objects), associations, metadata, config, developerTest: saveDeveloper }, { depth: 25 })
301
- debugger
302
302
  results = sortJson({
303
303
  query,
304
304
  paraphrases,
@@ -367,7 +367,7 @@ const setupContexts = (rawContexts) => {
367
367
  return contexts
368
368
  }
369
369
 
370
- const processContextsB = ({ config, hierarchy, semantics, generators, json, isTest, query, data, retries, url, commandLineArgs }) => {
370
+ const processContextsB = ({ config, hierarchy, semantics, generators, json, isTest, isInstance, query, data, retries, url, commandLineArgs }) => {
371
371
  // TODO fix this name to contextsPrime
372
372
  const contextsPrime = []
373
373
  const generatedPrime = []
@@ -378,7 +378,7 @@ const processContextsB = ({ config, hierarchy, semantics, generators, json, isTe
378
378
  const contexts = setupContexts(json.contexts)
379
379
 
380
380
  const objects = config.get('objects')
381
- const args = { objects, isResponse: true, response: json, isTest, getObjects: getObjects(objects) }
381
+ const args = { objects, isResponse: true, response: json, isTest, isInstance, getObjects: getObjects(objects), isInstance }
382
382
  if (!json.logs) {
383
383
  json.logs = []
384
384
  }
@@ -418,19 +418,18 @@ const processContextsB = ({ config, hierarchy, semantics, generators, json, isTe
418
418
  if (json.has_errors) {
419
419
  throw new Error('There are errors in the logs. Run with the -d flag and grep for Error')
420
420
  }
421
+ const generateParenthesized = isTest || (commandLineArgs && commandLineArgs.save)
421
422
  if (!config.get('skipSemantics')) {
422
- if (!config.doMotivations(args, context)) {
423
- const semantics = config.getSemantics(json.logs)
424
- try {
425
- contextPrime = semantics.apply(args, context)
426
- } catch( e ) {
427
- if (e.message == 'Maximum call stack size exceeded') {
428
- const mostCalled = semantics.getMostCalled()
429
- e.message += `\nThe most called semantic was:\nnotes: ${mostCalled.notes}\nmatch: ${mostCalled.matcher.toString()}\napply: ${mostCalled._apply.toString()}\n`
430
- }
431
- // contextPrime = semantics.apply(args, { marker: 'error', context, error: e })
432
- contextPrime = semantics.apply(args, { marker: 'error', context, reason: e.reason })
423
+ const semantics = config.getSemantics(json.logs)
424
+ try {
425
+ contextPrime = semantics.apply(args, context)
426
+ } catch( e ) {
427
+ if (e.message == 'Maximum call stack size exceeded') {
428
+ const mostCalled = semantics.getMostCalled()
429
+ e.message += `\nThe most called semantic was:\nnotes: ${mostCalled.notes}\nmatch: ${mostCalled.matcher.toString()}\napply: ${mostCalled._apply.toString()}\n`
433
430
  }
431
+ // contextPrime = semantics.apply(args, { marker: 'error', context, error: e })
432
+ contextPrime = semantics.apply(args, { marker: 'error', context, reason: e.reason })
434
433
  }
435
434
  }
436
435
  if (contextPrime.controlRemove) {
@@ -439,7 +438,7 @@ const processContextsB = ({ config, hierarchy, semantics, generators, json, isTe
439
438
  let assumed = { isResponse: true };
440
439
  const generated = contextPrime.isResponse ? config.getGenerators(json.logs).apply(args, contextPrime, assumed)[0] : ''
441
440
  let generatedParenthesized = []
442
- if (isTest) {
441
+ if (generateParenthesized) {
443
442
  config.parenthesized = true
444
443
  generatedParenthesized = contextPrime.isResponse ? config.getGenerators(json.logs).apply(args, contextPrime, assumed)[0] : ''
445
444
  config.parenthesized = false
@@ -452,12 +451,12 @@ const processContextsB = ({ config, hierarchy, semantics, generators, json, isTe
452
451
  args.gs = gs(args.g)
453
452
  args.gsp = gs(args.gsp)
454
453
  args.gsr = gs(args.gr)
455
- if (isTest) {
454
+ if (generateParenthesized) {
456
455
  config.parenthesized = false
457
456
  }
458
457
  const paraphrases = config.getGenerators(json.logs).apply(args, contextPrime, assumed)[0]
459
458
  let paraphrasesParenthesized = []
460
- if (isTest) {
459
+ if (generateParenthesized) {
461
460
  config.parenthesized = true
462
461
  paraphrasesParenthesized = config.getGenerators(json.logs).apply(args, contextPrime, assumed)[0]
463
462
  config.parenthesized = false
@@ -471,7 +470,7 @@ const processContextsB = ({ config, hierarchy, semantics, generators, json, isTe
471
470
  contextsPrime.push(contextPrime)
472
471
  generatedPrime.push(generated)
473
472
  paraphrasesPrime.push(paraphrases)
474
- if (isTest) {
473
+ if (generateParenthesized) {
475
474
  paraphrasesParenthesizedPrime.push(paraphrasesParenthesized)
476
475
  generatedParenthesizedPrime.push(generatedParenthesized)
477
476
  }
@@ -549,8 +548,11 @@ const setupProcessB = ({ config, initializer, allowDelta=false } = {}) => {
549
548
  // console.log('config', config)
550
549
  data.delta = config.delta()
551
550
  } else {
552
- Object.assign(data, config.config)
551
+ config.toData(data)
552
+ // Object.assign(data, config.config)
553
553
  }
554
+
555
+ // config.toServer(data)
554
556
 
555
557
  if (data.namespaces) {
556
558
  for (const uuid of Object.keys(data.namespaces)) {
@@ -574,7 +576,7 @@ const setupProcessB = ({ config, initializer, allowDelta=false } = {}) => {
574
576
  }
575
577
 
576
578
  // instance template
577
- const processInstance = (config, instance) => {
579
+ const loadInstance = (config, instance) => {
578
580
  const transitoryMode = global.transitoryMode
579
581
  global.transitoryMode = false
580
582
  const { /* data, generators, semantics, */ hierarchy } = setupProcessB({ config })
@@ -584,15 +586,15 @@ const processInstance = (config, instance) => {
584
586
  if (results.extraConfig) {
585
587
  // config.addInternal(results, useOldVersion = true, skipObjects = false, includeNamespaces = true, allowNameToBeNull = false)
586
588
  // config.addInternal(config.template.queries[i], { handleCalculatedProps: true } )
587
- config.addInternal(instance.template.queries[i], { handleCalculatedProps: true } )
589
+ config.addInternal(instance.template.queries[i], { addFirst: true, handleCalculatedProps: true } )
588
590
  } else {
589
- processContextsB({ config, hierarchy, json: results/*, generators, semantics */, commandLineArgs: {} })
591
+ processContextsB({ config, hierarchy, json: results/*, generators, semantics */, commandLineArgs: {}, isInstance: `instance${i}` })
590
592
  }
591
593
  }
592
594
  global.transitoryMode = transitoryMode
593
595
  }
594
596
 
595
- const _process = async (config, query, { initializer, commandLineArgs, credentials, writeTests, isTest, saveDeveloper, testConfig, testsFN, errorHandler = defaultErrorHandler } = {}) => {
597
+ const _process = async (config, query, { initializer, commandLineArgs, credentials, writeTests, isTest, saveDeveloper, rebuildingTemplate, testConfig, testsFN, errorHandler = defaultErrorHandler } = {}) => {
596
598
  if (credentials) {
597
599
  config.server(credentials.server, credentials.key)
598
600
  }
@@ -616,6 +618,9 @@ const _process = async (config, query, { initializer, commandLineArgs, credentia
616
618
  if (commandLineArgs && commandLineArgs.checkForLoop) {
617
619
  data.checkForLoop = true
618
620
  }
621
+ if (rebuildingTemplate) {
622
+ data.errors_ignore_contextual_priorities_non_existant_ops = true
623
+ }
619
624
  let queries = query.split('\\n')
620
625
 
621
626
  try {
@@ -694,7 +699,12 @@ const _process = async (config, query, { initializer, commandLineArgs, credentia
694
699
 
695
700
  if (writeTests) {
696
701
  const actual_config = getConfigForTest(config, testConfig)
697
- writeTest(testsFN, query, config.config.objects, response.generated, response.paraphrases, response.responses, response.contexts, response.associations, response.metadata, actual_config, saveDeveloper, response.paraphrasesParenthesized, response.generatedParenthesized)
702
+ const saveObjects = {...config.config.objects}
703
+ saveObjects.nameToUUID = {}
704
+ for (let km of config.configs) {
705
+ saveObjects.nameToUUID[km.name] = km.uuid
706
+ }
707
+ writeTest(testsFN, query, saveObjects, response.generated, response.paraphrases, response.responses, response.contexts, response.associations, response.metadata, actual_config, saveDeveloper, response.paraphrasesParenthesized, response.generatedParenthesized)
698
708
  }
699
709
 
700
710
  return response
@@ -760,7 +770,6 @@ const runTest = async (config, expected, { args, verbose, afterTest, testConfig,
760
770
  testConfigName = testConfig.testModuleName
761
771
  }
762
772
  config.beforeQuery({ query: test, isModule: false, objects })
763
- // config.resetMotivations()
764
773
  try {
765
774
  const result = await _process(config, test, { errorHandler, isTest: true })
766
775
  result.query = test
@@ -778,12 +787,17 @@ const runTest = async (config, expected, { args, verbose, afterTest, testConfig,
778
787
  delete expected_objects.nameToUUID
779
788
  const actual_objects = sortJson(convertToStable(config.config.objects), { depth: 25 })
780
789
  const failed_paraphrases = !matching(result.paraphrases, expected.paraphrases)
781
- const failed_paraphrasesParenthesized = !matching(result.paraphrasesParenthesized, expected.paraphrasesParenthesized)
782
- const failed_generatedParenthesized = !matching(result.generatedParenthesized, expected.generatedParenthesized)
790
+ let failed_paraphrasesParenthesized = !matching(result.paraphrasesParenthesized, expected.paraphrasesParenthesized)
791
+ let failed_generatedParenthesized = !matching(result.generatedParenthesized, expected.generatedParenthesized)
783
792
  const failed_responses = !matching(result.responses, expected.responses)
784
793
  const failed_contexts = !matching(result.contexts, expected.contexts)
785
794
  const failed_objects = !matching(actual_objects, expected_objects)
786
795
 
796
+ if (args.testNoParenthesized) {
797
+ failed_paraphrasesParenthesized = false
798
+ failed_generatedParenthesized = false
799
+ }
800
+
787
801
  const pickEm = (getObjects) => {
788
802
  const picked = {}
789
803
  for (let prop of (testConfig.check || [])) {
@@ -809,6 +823,11 @@ const runTest = async (config, expected, { args, verbose, afterTest, testConfig,
809
823
  }
810
824
  return expected.objects.namespaced[expected.objects.nameToUUID[name]]
811
825
  }
826
+ try {
827
+ sortJson(pickEm(expectedGetObjects), { depth: 25 })
828
+ } catch ( e ) {
829
+ debugger
830
+ }
812
831
  const expected_checked = sortJson(pickEm(expectedGetObjects), { depth: 25 })
813
832
  const actualGetObjects = (name) => {
814
833
  if (!name) {
@@ -935,7 +954,6 @@ const runTests = async (config, testFile, juicyBits) => {
935
954
  const saveTest = async (testFile, config, test, expected, testConfig, saveDeveloper) => {
936
955
  config.rebuild()
937
956
  const objects = getObjects(config.config.objects)(config.uuid)
938
- //config.resetMotivations()
939
957
  config.beforeQuery({ query: test, isModule: false, objects })
940
958
  console.log(test)
941
959
  const result = await _process(config, test, { isTest: true })
@@ -1118,10 +1136,11 @@ const defaultErrorHandler = async (error) => {
1118
1136
  doErrorExit = true
1119
1137
  }
1120
1138
 
1121
- if (doErrorExit) {
1139
+ if (typeof runtime.process.exit == 'function' && doErrorExit) {
1122
1140
  runtime.process.exit(-1)
1123
1141
  }
1124
- // throw error
1142
+
1143
+ throw error
1125
1144
  }
1126
1145
 
1127
1146
  const defaultInnerProcess = (config, errorHandler, responses) => {
@@ -1142,6 +1161,37 @@ const defaultInnerProcess = (config, errorHandler, responses) => {
1142
1161
  } else {
1143
1162
  console.log('objects', runtime.util.inspect(config.get('objects'), { depth: Infinity, sorted: true }))
1144
1163
  }
1164
+
1165
+ const pickEm = () => {
1166
+ const picked = {}
1167
+ const namespaced = config.get('objects')['namespaced']
1168
+ for (let prop of (config.testConfig.check || [])) {
1169
+ if (prop.km) {
1170
+ /*
1171
+ const objects = namespaced[prop.km]]
1172
+ picked[prop.km] = {}
1173
+ for (let p of c.testConfig.check) {
1174
+ if (p.km) {
1175
+ continue
1176
+ }
1177
+ picked[p] = objects[p]
1178
+ }
1179
+ */
1180
+ console.log('TODO implement this if needed')
1181
+ } else {
1182
+ const objects = namespaced[config.uuid]
1183
+ picked[prop] = objects[prop]
1184
+ }
1185
+ }
1186
+ return picked
1187
+ }
1188
+
1189
+ const picked = pickEm()
1190
+ if (!_.isEmpty(picked)) {
1191
+ console.log('--- checked object properties ---')
1192
+ console.log(JSON.stringify(picked, null, 2))
1193
+ }
1194
+
1145
1195
  console.log('--- The contexts are ----------')
1146
1196
  console.log(JSON.stringify(sortJson(responses.contexts, { depth: 25 }), null, 2))
1147
1197
  console.log('')
@@ -1207,7 +1257,8 @@ entodicton.knowledgeModule( {
1207
1257
  `
1208
1258
  */
1209
1259
 
1210
- const build = async ({ config, target, template, errorHandler = defaultErrorHandler }) => {
1260
+ // loadTemplate BuiltTemplate
1261
+ const rebuildTemplate = async ({ config, target, template, errorHandler = defaultErrorHandler }) => {
1211
1262
  const accumulators = {
1212
1263
  resultss: [],
1213
1264
  fragments: [],
@@ -1231,8 +1282,6 @@ const build = async ({ config, target, template, errorHandler = defaultErrorHand
1231
1282
  if (property == 'fragments') {
1232
1283
  global.transitoryMode = true
1233
1284
  }
1234
- // greg32
1235
- // config.addInternal( query )
1236
1285
  if (hierarchy) {
1237
1286
  for (let edge of hierarchy) {
1238
1287
  if (Array.isArray(edge)) {
@@ -1244,7 +1293,7 @@ const build = async ({ config, target, template, errorHandler = defaultErrorHand
1244
1293
  }
1245
1294
 
1246
1295
  try {
1247
- const results = await _process(config, query.query, {initializer})
1296
+ const results = await _process(config, query.query, {initializer, rebuildingTemplate: true})
1248
1297
  if (config.config.debug) {
1249
1298
  // TODO pass in the error handler like the other ones
1250
1299
  defaultInnerProcess(config, defaultErrorHandler, results)
@@ -1274,6 +1323,12 @@ const build = async ({ config, target, template, errorHandler = defaultErrorHand
1274
1323
  // it will just get added to the config
1275
1324
  const extraConfig = queryOrExtraConfig
1276
1325
  console.log('config', extraConfig)
1326
+ try {
1327
+ config.addInternal(_.cloneDeep(extraConfig), { handleCalculatedProps: true } )
1328
+ } catch ( e ) {
1329
+ const where = extraConfig.where ? ` ${extraConfig.where}` : ''
1330
+ throw new Error(`Error processing extra config${where}: ${e.stack}}`)
1331
+ }
1277
1332
  accumulators[property].push({ extraConfig: true, ...extraConfig })
1278
1333
  await looper(queries)
1279
1334
  }
@@ -1349,9 +1404,15 @@ const knowledgeModule = async ({
1349
1404
  beforeTests = () => {},
1350
1405
  afterTests = () => {},
1351
1406
  beforeTest = () => {},
1352
- afterTest = () => {}
1407
+ afterTest = () => {},
1408
+ ...rest
1353
1409
  } = {}) => {
1354
1410
 
1411
+ const unknownArgs = Object.keys(rest)
1412
+ if (unknownArgs.length > 0) {
1413
+ throw new Error(`Unknown arguments to knowledgeModule: ${unknownArgs.join()}`)
1414
+ }
1415
+
1355
1416
  config.beforeQuery = beforeQuery
1356
1417
  config.beforeTests = beforeTests
1357
1418
  config.afterTests = afterTests
@@ -1431,7 +1492,8 @@ const knowledgeModule = async ({
1431
1492
  if (!isProcess) {
1432
1493
  if (template) {
1433
1494
  if (config.needsRebuild(template.template, template.instance)) {
1434
- throw new Error(`This module "${config.name}" cannot be used because the instance file needs rebuilding. Run on the command line with no arguements or the -rt argument to rebuild.`)
1495
+ const error = `This module "${config.name}" cannot be used because the instance file needs rebuilding. Run on the command line with no arguments or the -rt argument to rebuild.`
1496
+ throw new Error(error)
1435
1497
  }
1436
1498
  try {
1437
1499
  config.load(template.template, template.instance)
@@ -1446,9 +1508,10 @@ const knowledgeModule = async ({
1446
1508
  description: 'Entodicton knowledge module'
1447
1509
  })
1448
1510
 
1449
- const helpDebugAssociation = 'In order to get a debug break when a specific association is created set the DEBUG_ASSOCIATION environment variable to the JSON of the association to break on. For example DEBUG_ASSOCIATION=\'["the#0", "mammel#0"]\' })'
1450
- const helpDebugHierarchy = 'In order to get a debug break when a specific hierarchy is created set the DEBUG_HIERARCHY environment variable to the JSON of the child-parent pair to break on. For example DEBUG_HIERARCHY=\'["cat#1", "mammel#1"]\' })'
1451
- const helpDebugPriority = 'In order to get a debug break when a specific set of priorities is created set set DEBUG_PRIORITY environment variable to the JSON of the priorities that you want to break on. For example DEBUG_PRIORITY=\'["verb#0", "article#0"]\' })'
1511
+ const helpDebugAssociation = 'In order to get a debug break when a specific association is created set the DEBUG_ASSOCIATION environment variable to the JSON of the association to break on. For example DEBUG_ASSOCIATION=\'[["the", 0], ["mammal", 1]]\' })'
1512
+ const helpDebugHierarchy = 'In order to get a debug break when a specific hierarchy is created set the DEBUG_HIERARCHY environment variable to the JSON of the child-parent pair to break on. For example DEBUG_HIERARCHY=\'[["cat", 1], ["mammel", 1]]\' })'
1513
+ const helpDebugPriority = 'In order to get a debug break when a specific set of priorities is created set set DEBUG_PRIORITY environment variable to the JSON of the priorities that you want to break on. For example DEBUG_PRIORITY=\'[["verb", 0], ["article", 0]]\' })'
1514
+ const helpDebugContextualPriority = 'In order to get a debug break when a specific set of contextual priorities is created set set DEBUG_CONTEXTUAL_PRIORITY environment variable to the JSON of the priorities that you want to break on. For example DEBUG_CONTEXTUAL_PRIORITY=\'{ context: [["verb", 0], ["article", 0], select: 1}\' })'
1452
1515
  const helpDebugBridge = 'In order to get a debug break when a specific bridge is created set the DEBUG_BRIDGE environment variable to id/level to break on. For example DEBUG_BRIDGE=\'id#level\' })'
1453
1516
  const helpDebugOperator = 'In order to get a debug break when a specific hierarcy is created set the DEBUG_OPERATOR environment variable to debug any config loaded. For example DEBUG_OPERATOR=\'([operator] ([arg]))\' })'
1454
1517
 
@@ -1457,6 +1520,7 @@ const knowledgeModule = async ({
1457
1520
  parser.add_argument('-t', '--test', { action: 'store_true', help: 'Run the tests. Create tests by running with the --query + --save flag' })
1458
1521
  parser.add_argument('-tv', '--testVerbose', { action: 'store_true', help: 'Run the tests in verbose mode. Create tests by running with the --query or --loop with the --save flag' })
1459
1522
  parser.add_argument('-tva', '--testAllVerbose', { action: 'store_true', help: 'Run the tests in verbose mode. All the tests will be run instead of stopping at first failure. Create tests by running with the --query or --loop with the --save flag' })
1523
+ parser.add_argument('-tnp', '--testNoParenthesized', { action: 'store_true', help: 'Don\' check parenthesized differences for the tests' })
1460
1524
  parser.add_argument('-n', '--count', { help: 'Number of times to run the tests. Default is one. Use this to check for flakey test. If possible the system will print out a message with the word "hint" suggesting how to fix the problem' })
1461
1525
  // parser.add_argument('-b', '--build', { help: 'Specify the template file name of the form <kmName>. There should be a file called <baseKmName>.<kmName>.template.json with the queries to run. For example { queries: [...] }. The template file will be run and generate an instantiation called <baseKmName>.<kmName>.instance.json and a file called <kmName>.js that will load the template file (this is file generated only if not already existing) and a test file called <KmName>.tests.json. This can then be loaded into an instance of the current knowledge module to setup initial conditions.' })
1462
1526
  parser.add_argument('-rt', '--rebuildTemplate', { action: 'store_true', help: 'Force a template rebuild' })
@@ -1483,6 +1547,7 @@ const knowledgeModule = async ({
1483
1547
  parser.add_argument('-da', '--debugAssociation', { help: helpDebugAssociation })
1484
1548
  parser.add_argument('-dh', '--debugHierarchy', { help: helpDebugHierarchy })
1485
1549
  parser.add_argument('-dp', '--debugPriority', { help: helpDebugPriority })
1550
+ parser.add_argument('-dcp', '--debugContextualPriority', { help: helpDebugContextualPriority })
1486
1551
  parser.add_argument('-db', '--debugBridge', { help: helpDebugBridge })
1487
1552
  parser.add_argument('-do', '--debugOperator', { help: helpDebugOperator })
1488
1553
 
@@ -1712,11 +1777,13 @@ const knowledgeModule = async ({
1712
1777
  if (JSON.stringify(result.expected.paraphrases) !== JSON.stringify(result.actual.paraphrases)) {
1713
1778
  hasError = true
1714
1779
  }
1715
- if (JSON.stringify(result.expected.paraphrasesParenthesized) !== JSON.stringify(result.actual.paraphrasesParenthesized)) {
1716
- hasError = true
1717
- }
1718
- if (JSON.stringify(result.expected.generatedParenthesized) !== JSON.stringify(result.actual.generatedParenthesized)) {
1719
- hasError = true
1780
+ if (!args.testNoParenthesized) {
1781
+ if (JSON.stringify(result.expected.paraphrasesParenthesized) !== JSON.stringify(result.actual.paraphrasesParenthesized)) {
1782
+ hasError = true
1783
+ }
1784
+ if (JSON.stringify(result.expected.generatedParenthesized) !== JSON.stringify(result.actual.generatedParenthesized)) {
1785
+ hasError = true
1786
+ }
1720
1787
  }
1721
1788
  if (JSON.stringify(result.expected.responses) !== JSON.stringify(result.actual.responses)) {
1722
1789
  hasError = true
@@ -1742,9 +1809,13 @@ const knowledgeModule = async ({
1742
1809
  }
1743
1810
  }
1744
1811
  show('paraphrases', result.expected.paraphrases, result.actual.paraphrases)
1745
- show('paraphrases parenthesized', result.expected.paraphrasesParenthesized, result.actual.paraphrasesParenthesized)
1812
+ if (!args.testNoParenthesized) {
1813
+ show('paraphrases parenthesized', result.expected.paraphrasesParenthesized, result.actual.paraphrasesParenthesized)
1814
+ }
1746
1815
  show('responses', result.expected.responses, result.actual.responses)
1747
- show('responses parenthesized', result.expected.generatedParenthesized, result.actual.generatedParenthesized)
1816
+ if (!args.testNoParenthesized) {
1817
+ show('responses parenthesized', result.expected.generatedParenthesized, result.actual.generatedParenthesized)
1818
+ }
1748
1819
  /*
1749
1820
  if (JSON.stringify(result.expected.paraphrases) !== JSON.stringify(result.actual.paraphrases)) {
1750
1821
  if (!headerShown) {
@@ -1918,7 +1989,7 @@ module.exports = {
1918
1989
  w,
1919
1990
  // submitBug,
1920
1991
  ensureTestFile,
1921
- build,
1992
+ rebuildTemplate,
1922
1993
  processContext,
1923
1994
  processContexts,
1924
1995
  runTests,
@@ -1930,8 +2001,9 @@ module.exports = {
1930
2001
  Digraph,
1931
2002
  analyzeMetaData,
1932
2003
  processContextsB,
1933
- processInstance,
2004
+ loadInstance,
1934
2005
  gs,
1935
2006
  flattens,
1936
2007
  writeTest
1937
2008
  }
2009
+
package/index.js CHANGED
@@ -23,5 +23,6 @@ module.exports = {
23
23
  Generator,
24
24
  Digraph,
25
25
  flattens: flattens.flattens,
26
+ flatten: flattens.flatten,
26
27
  unflatten: unflatten.unflatten
27
28
  }
package/package.json CHANGED
@@ -63,6 +63,6 @@
63
63
  "json-stable-stringify": "^1.0.1",
64
64
  "node-fetch": "^2.6.1"
65
65
  },
66
- "version": "7.5.8-beta.5",
66
+ "version": "7.5.8-beta.51",
67
67
  "license": "ISC"
68
68
  }