theprogrammablemind 7.5.8-beta.3 → 7.5.8-beta.30
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.
- package/client.js +121 -50
- package/index.js +1 -0
- package/package.json +1 -1
- package/src/config.js +363 -179
- package/src/helpers.js +1 -1
- package/src/semantics.js +6 -1
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.
|
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.
|
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;
|
@@ -109,11 +111,12 @@ class ErrorReason extends Error {
|
|
109
111
|
|
110
112
|
const setupArgs = (args, config, logs, hierarchy) => {
|
111
113
|
config.setArgs(args)
|
112
|
-
args.calls = new InitCalls(config.name)
|
114
|
+
args.calls = new InitCalls(args.isInstance ? `${args.isInstance}#${config.name}` : config.name)
|
113
115
|
if (global.theprogrammablemind && global.theprogrammablemind.loadForTesting) {
|
114
116
|
args.calls = new InitCalls(Object.keys(global.theprogrammablemind.loadForTesting)[0])
|
115
117
|
}
|
116
118
|
args.km = (name) => config.getConfig(name)
|
119
|
+
args.api = (name) => config.getConfig(name).api
|
117
120
|
args.error = (context) => {
|
118
121
|
throw new ErrorReason(context)
|
119
122
|
}
|
@@ -143,7 +146,6 @@ const setupArgs = (args, config, logs, hierarchy) => {
|
|
143
146
|
apis: getAPIs(uuid)
|
144
147
|
}
|
145
148
|
}
|
146
|
-
args.motivation = (m) => config.addMotivation(m)
|
147
149
|
args.breakOnSemantics = false
|
148
150
|
args.theDebugger = {
|
149
151
|
breakOnSemantics: (value) => args.breakOnSemantics = value
|
@@ -157,10 +159,10 @@ const setupArgs = (args, config, logs, hierarchy) => {
|
|
157
159
|
}
|
158
160
|
args.e = (c) => config.getEvaluator(args.s, args.calls, logs, c)
|
159
161
|
args.log = (message) => logs.push(message)
|
160
|
-
// config.getAddedArgs(args)
|
161
162
|
args.gs = gs(args.g)
|
162
163
|
args.gsp = gs(args.gp)
|
163
164
|
args.gsr = gs(args.gr)
|
165
|
+
config.getAddedArgs(args)
|
164
166
|
}
|
165
167
|
|
166
168
|
const gs = (g) => (contexts, separator, lastSeparator) => {
|
@@ -298,7 +300,6 @@ const writeTest = (fn, query, objects, generated, paraphrases, responses, contex
|
|
298
300
|
}
|
299
301
|
associations.sort()
|
300
302
|
// tests[query] = sortJson({ paraphrases, responses, contexts, objects: convertToStable(objects), associations, metadata, config, developerTest: saveDeveloper }, { depth: 25 })
|
301
|
-
debugger
|
302
303
|
results = sortJson({
|
303
304
|
query,
|
304
305
|
paraphrases,
|
@@ -367,7 +368,7 @@ const setupContexts = (rawContexts) => {
|
|
367
368
|
return contexts
|
368
369
|
}
|
369
370
|
|
370
|
-
const processContextsB = ({ config, hierarchy, semantics, generators, json, isTest, query, data, retries, url, commandLineArgs }) => {
|
371
|
+
const processContextsB = ({ config, hierarchy, semantics, generators, json, isTest, isInstance, query, data, retries, url, commandLineArgs }) => {
|
371
372
|
// TODO fix this name to contextsPrime
|
372
373
|
const contextsPrime = []
|
373
374
|
const generatedPrime = []
|
@@ -378,7 +379,7 @@ const processContextsB = ({ config, hierarchy, semantics, generators, json, isTe
|
|
378
379
|
const contexts = setupContexts(json.contexts)
|
379
380
|
|
380
381
|
const objects = config.get('objects')
|
381
|
-
const args = { objects, isResponse: true, response: json, isTest, getObjects: getObjects(objects) }
|
382
|
+
const args = { objects, isResponse: true, response: json, isTest, isInstance, getObjects: getObjects(objects), isInstance }
|
382
383
|
if (!json.logs) {
|
383
384
|
json.logs = []
|
384
385
|
}
|
@@ -418,19 +419,18 @@ const processContextsB = ({ config, hierarchy, semantics, generators, json, isTe
|
|
418
419
|
if (json.has_errors) {
|
419
420
|
throw new Error('There are errors in the logs. Run with the -d flag and grep for Error')
|
420
421
|
}
|
422
|
+
const generateParenthesized = isTest || (commandLineArgs && commandLineArgs.save)
|
421
423
|
if (!config.get('skipSemantics')) {
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
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 })
|
424
|
+
const semantics = config.getSemantics(json.logs)
|
425
|
+
try {
|
426
|
+
contextPrime = semantics.apply(args, context)
|
427
|
+
} catch( e ) {
|
428
|
+
if (e.message == 'Maximum call stack size exceeded') {
|
429
|
+
const mostCalled = semantics.getMostCalled()
|
430
|
+
e.message += `\nThe most called semantic was:\nnotes: ${mostCalled.notes}\nmatch: ${mostCalled.matcher.toString()}\napply: ${mostCalled._apply.toString()}\n`
|
433
431
|
}
|
432
|
+
// contextPrime = semantics.apply(args, { marker: 'error', context, error: e })
|
433
|
+
contextPrime = semantics.apply(args, { marker: 'error', context, reason: e.reason })
|
434
434
|
}
|
435
435
|
}
|
436
436
|
if (contextPrime.controlRemove) {
|
@@ -439,7 +439,7 @@ const processContextsB = ({ config, hierarchy, semantics, generators, json, isTe
|
|
439
439
|
let assumed = { isResponse: true };
|
440
440
|
const generated = contextPrime.isResponse ? config.getGenerators(json.logs).apply(args, contextPrime, assumed)[0] : ''
|
441
441
|
let generatedParenthesized = []
|
442
|
-
if (
|
442
|
+
if (generateParenthesized) {
|
443
443
|
config.parenthesized = true
|
444
444
|
generatedParenthesized = contextPrime.isResponse ? config.getGenerators(json.logs).apply(args, contextPrime, assumed)[0] : ''
|
445
445
|
config.parenthesized = false
|
@@ -452,12 +452,12 @@ const processContextsB = ({ config, hierarchy, semantics, generators, json, isTe
|
|
452
452
|
args.gs = gs(args.g)
|
453
453
|
args.gsp = gs(args.gsp)
|
454
454
|
args.gsr = gs(args.gr)
|
455
|
-
if (
|
455
|
+
if (generateParenthesized) {
|
456
456
|
config.parenthesized = false
|
457
457
|
}
|
458
458
|
const paraphrases = config.getGenerators(json.logs).apply(args, contextPrime, assumed)[0]
|
459
459
|
let paraphrasesParenthesized = []
|
460
|
-
if (
|
460
|
+
if (generateParenthesized) {
|
461
461
|
config.parenthesized = true
|
462
462
|
paraphrasesParenthesized = config.getGenerators(json.logs).apply(args, contextPrime, assumed)[0]
|
463
463
|
config.parenthesized = false
|
@@ -471,7 +471,7 @@ const processContextsB = ({ config, hierarchy, semantics, generators, json, isTe
|
|
471
471
|
contextsPrime.push(contextPrime)
|
472
472
|
generatedPrime.push(generated)
|
473
473
|
paraphrasesPrime.push(paraphrases)
|
474
|
-
if (
|
474
|
+
if (generateParenthesized) {
|
475
475
|
paraphrasesParenthesizedPrime.push(paraphrasesParenthesized)
|
476
476
|
generatedParenthesizedPrime.push(generatedParenthesized)
|
477
477
|
}
|
@@ -549,8 +549,11 @@ const setupProcessB = ({ config, initializer, allowDelta=false } = {}) => {
|
|
549
549
|
// console.log('config', config)
|
550
550
|
data.delta = config.delta()
|
551
551
|
} else {
|
552
|
-
|
552
|
+
config.toData(data)
|
553
|
+
// Object.assign(data, config.config)
|
553
554
|
}
|
555
|
+
|
556
|
+
// config.toServer(data)
|
554
557
|
|
555
558
|
if (data.namespaces) {
|
556
559
|
for (const uuid of Object.keys(data.namespaces)) {
|
@@ -586,13 +589,13 @@ const processInstance = (config, instance) => {
|
|
586
589
|
// config.addInternal(config.template.queries[i], { handleCalculatedProps: true } )
|
587
590
|
config.addInternal(instance.template.queries[i], { handleCalculatedProps: true } )
|
588
591
|
} else {
|
589
|
-
processContextsB({ config, hierarchy, json: results/*, generators, semantics */, commandLineArgs: {} })
|
592
|
+
processContextsB({ config, hierarchy, json: results/*, generators, semantics */, commandLineArgs: {}, isInstance: `instance${i}` })
|
590
593
|
}
|
591
594
|
}
|
592
595
|
global.transitoryMode = transitoryMode
|
593
596
|
}
|
594
597
|
|
595
|
-
const _process = async (config, query, { initializer, commandLineArgs, credentials, writeTests, isTest, saveDeveloper, testConfig, testsFN, errorHandler = defaultErrorHandler } = {}) => {
|
598
|
+
const _process = async (config, query, { initializer, commandLineArgs, credentials, writeTests, isTest, saveDeveloper, rebuildingTemplate, testConfig, testsFN, errorHandler = defaultErrorHandler } = {}) => {
|
596
599
|
if (credentials) {
|
597
600
|
config.server(credentials.server, credentials.key)
|
598
601
|
}
|
@@ -616,6 +619,9 @@ const _process = async (config, query, { initializer, commandLineArgs, credentia
|
|
616
619
|
if (commandLineArgs && commandLineArgs.checkForLoop) {
|
617
620
|
data.checkForLoop = true
|
618
621
|
}
|
622
|
+
if (rebuildingTemplate) {
|
623
|
+
data.errors_ignore_contextual_priorities_non_existant_ops = true
|
624
|
+
}
|
619
625
|
let queries = query.split('\\n')
|
620
626
|
|
621
627
|
try {
|
@@ -694,7 +700,12 @@ const _process = async (config, query, { initializer, commandLineArgs, credentia
|
|
694
700
|
|
695
701
|
if (writeTests) {
|
696
702
|
const actual_config = getConfigForTest(config, testConfig)
|
697
|
-
|
703
|
+
const saveObjects = {...config.config.objects}
|
704
|
+
saveObjects.nameToUUID = {}
|
705
|
+
for (let km of config.configs) {
|
706
|
+
saveObjects.nameToUUID[km.name] = km.uuid
|
707
|
+
}
|
708
|
+
writeTest(testsFN, query, saveObjects, response.generated, response.paraphrases, response.responses, response.contexts, response.associations, response.metadata, actual_config, saveDeveloper, response.paraphrasesParenthesized, response.generatedParenthesized)
|
698
709
|
}
|
699
710
|
|
700
711
|
return response
|
@@ -760,7 +771,6 @@ const runTest = async (config, expected, { args, verbose, afterTest, testConfig,
|
|
760
771
|
testConfigName = testConfig.testModuleName
|
761
772
|
}
|
762
773
|
config.beforeQuery({ query: test, isModule: false, objects })
|
763
|
-
// config.resetMotivations()
|
764
774
|
try {
|
765
775
|
const result = await _process(config, test, { errorHandler, isTest: true })
|
766
776
|
result.query = test
|
@@ -778,12 +788,17 @@ const runTest = async (config, expected, { args, verbose, afterTest, testConfig,
|
|
778
788
|
delete expected_objects.nameToUUID
|
779
789
|
const actual_objects = sortJson(convertToStable(config.config.objects), { depth: 25 })
|
780
790
|
const failed_paraphrases = !matching(result.paraphrases, expected.paraphrases)
|
781
|
-
|
782
|
-
|
791
|
+
let failed_paraphrasesParenthesized = !matching(result.paraphrasesParenthesized, expected.paraphrasesParenthesized)
|
792
|
+
let failed_generatedParenthesized = !matching(result.generatedParenthesized, expected.generatedParenthesized)
|
783
793
|
const failed_responses = !matching(result.responses, expected.responses)
|
784
794
|
const failed_contexts = !matching(result.contexts, expected.contexts)
|
785
795
|
const failed_objects = !matching(actual_objects, expected_objects)
|
786
796
|
|
797
|
+
if (args.testNoParenthesized) {
|
798
|
+
failed_paraphrasesParenthesized = false
|
799
|
+
failed_generatedParenthesized = false
|
800
|
+
}
|
801
|
+
|
787
802
|
const pickEm = (getObjects) => {
|
788
803
|
const picked = {}
|
789
804
|
for (let prop of (testConfig.check || [])) {
|
@@ -809,6 +824,11 @@ const runTest = async (config, expected, { args, verbose, afterTest, testConfig,
|
|
809
824
|
}
|
810
825
|
return expected.objects.namespaced[expected.objects.nameToUUID[name]]
|
811
826
|
}
|
827
|
+
try {
|
828
|
+
sortJson(pickEm(expectedGetObjects), { depth: 25 })
|
829
|
+
} catch ( e ) {
|
830
|
+
debugger
|
831
|
+
}
|
812
832
|
const expected_checked = sortJson(pickEm(expectedGetObjects), { depth: 25 })
|
813
833
|
const actualGetObjects = (name) => {
|
814
834
|
if (!name) {
|
@@ -935,7 +955,6 @@ const runTests = async (config, testFile, juicyBits) => {
|
|
935
955
|
const saveTest = async (testFile, config, test, expected, testConfig, saveDeveloper) => {
|
936
956
|
config.rebuild()
|
937
957
|
const objects = getObjects(config.config.objects)(config.uuid)
|
938
|
-
//config.resetMotivations()
|
939
958
|
config.beforeQuery({ query: test, isModule: false, objects })
|
940
959
|
console.log(test)
|
941
960
|
const result = await _process(config, test, { isTest: true })
|
@@ -1118,10 +1137,11 @@ const defaultErrorHandler = async (error) => {
|
|
1118
1137
|
doErrorExit = true
|
1119
1138
|
}
|
1120
1139
|
|
1121
|
-
if (doErrorExit) {
|
1140
|
+
if (typeof runtime.process.exit == 'function' && doErrorExit) {
|
1122
1141
|
runtime.process.exit(-1)
|
1123
1142
|
}
|
1124
|
-
|
1143
|
+
|
1144
|
+
throw error
|
1125
1145
|
}
|
1126
1146
|
|
1127
1147
|
const defaultInnerProcess = (config, errorHandler, responses) => {
|
@@ -1142,6 +1162,37 @@ const defaultInnerProcess = (config, errorHandler, responses) => {
|
|
1142
1162
|
} else {
|
1143
1163
|
console.log('objects', runtime.util.inspect(config.get('objects'), { depth: Infinity, sorted: true }))
|
1144
1164
|
}
|
1165
|
+
|
1166
|
+
const pickEm = () => {
|
1167
|
+
const picked = {}
|
1168
|
+
const namespaced = config.get('objects')['namespaced']
|
1169
|
+
for (let prop of (config.testConfig.check || [])) {
|
1170
|
+
if (prop.km) {
|
1171
|
+
/*
|
1172
|
+
const objects = namespaced[prop.km]]
|
1173
|
+
picked[prop.km] = {}
|
1174
|
+
for (let p of c.testConfig.check) {
|
1175
|
+
if (p.km) {
|
1176
|
+
continue
|
1177
|
+
}
|
1178
|
+
picked[p] = objects[p]
|
1179
|
+
}
|
1180
|
+
*/
|
1181
|
+
console.log('TODO implement this if needed')
|
1182
|
+
} else {
|
1183
|
+
const objects = namespaced[config.uuid]
|
1184
|
+
picked[prop] = objects[prop]
|
1185
|
+
}
|
1186
|
+
}
|
1187
|
+
return picked
|
1188
|
+
}
|
1189
|
+
|
1190
|
+
const picked = pickEm()
|
1191
|
+
if (!_.isEmpty(picked)) {
|
1192
|
+
console.log('--- checked object properties ---')
|
1193
|
+
console.log(JSON.stringify(picked, null, 2))
|
1194
|
+
}
|
1195
|
+
|
1145
1196
|
console.log('--- The contexts are ----------')
|
1146
1197
|
console.log(JSON.stringify(sortJson(responses.contexts, { depth: 25 }), null, 2))
|
1147
1198
|
console.log('')
|
@@ -1207,7 +1258,7 @@ entodicton.knowledgeModule( {
|
|
1207
1258
|
`
|
1208
1259
|
*/
|
1209
1260
|
|
1210
|
-
const
|
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
|
@@ -1446,9 +1507,10 @@ const knowledgeModule = async ({
|
|
1446
1507
|
description: 'Entodicton knowledge module'
|
1447
1508
|
})
|
1448
1509
|
|
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
|
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
|
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
|
1510
|
+
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]]\' })'
|
1511
|
+
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]]\' })'
|
1512
|
+
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]]\' })'
|
1513
|
+
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
1514
|
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
1515
|
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
1516
|
|
@@ -1457,6 +1519,7 @@ const knowledgeModule = async ({
|
|
1457
1519
|
parser.add_argument('-t', '--test', { action: 'store_true', help: 'Run the tests. Create tests by running with the --query + --save flag' })
|
1458
1520
|
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
1521
|
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' })
|
1522
|
+
parser.add_argument('-tnp', '--testNoParenthesized', { action: 'store_true', help: 'Don\' check parenthesized differences for the tests' })
|
1460
1523
|
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
1524
|
// 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
1525
|
parser.add_argument('-rt', '--rebuildTemplate', { action: 'store_true', help: 'Force a template rebuild' })
|
@@ -1483,6 +1546,7 @@ const knowledgeModule = async ({
|
|
1483
1546
|
parser.add_argument('-da', '--debugAssociation', { help: helpDebugAssociation })
|
1484
1547
|
parser.add_argument('-dh', '--debugHierarchy', { help: helpDebugHierarchy })
|
1485
1548
|
parser.add_argument('-dp', '--debugPriority', { help: helpDebugPriority })
|
1549
|
+
parser.add_argument('-dcp', '--debugContextualPriority', { help: helpDebugContextualPriority })
|
1486
1550
|
parser.add_argument('-db', '--debugBridge', { help: helpDebugBridge })
|
1487
1551
|
parser.add_argument('-do', '--debugOperator', { help: helpDebugOperator })
|
1488
1552
|
|
@@ -1712,11 +1776,13 @@ const knowledgeModule = async ({
|
|
1712
1776
|
if (JSON.stringify(result.expected.paraphrases) !== JSON.stringify(result.actual.paraphrases)) {
|
1713
1777
|
hasError = true
|
1714
1778
|
}
|
1715
|
-
if (
|
1716
|
-
|
1717
|
-
|
1718
|
-
|
1719
|
-
|
1779
|
+
if (!args.testNoParenthesized) {
|
1780
|
+
if (JSON.stringify(result.expected.paraphrasesParenthesized) !== JSON.stringify(result.actual.paraphrasesParenthesized)) {
|
1781
|
+
hasError = true
|
1782
|
+
}
|
1783
|
+
if (JSON.stringify(result.expected.generatedParenthesized) !== JSON.stringify(result.actual.generatedParenthesized)) {
|
1784
|
+
hasError = true
|
1785
|
+
}
|
1720
1786
|
}
|
1721
1787
|
if (JSON.stringify(result.expected.responses) !== JSON.stringify(result.actual.responses)) {
|
1722
1788
|
hasError = true
|
@@ -1742,9 +1808,13 @@ const knowledgeModule = async ({
|
|
1742
1808
|
}
|
1743
1809
|
}
|
1744
1810
|
show('paraphrases', result.expected.paraphrases, result.actual.paraphrases)
|
1745
|
-
|
1811
|
+
if (!args.testNoParenthesized) {
|
1812
|
+
show('paraphrases parenthesized', result.expected.paraphrasesParenthesized, result.actual.paraphrasesParenthesized)
|
1813
|
+
}
|
1746
1814
|
show('responses', result.expected.responses, result.actual.responses)
|
1747
|
-
|
1815
|
+
if (!args.testNoParenthesized) {
|
1816
|
+
show('responses parenthesized', result.expected.generatedParenthesized, result.actual.generatedParenthesized)
|
1817
|
+
}
|
1748
1818
|
/*
|
1749
1819
|
if (JSON.stringify(result.expected.paraphrases) !== JSON.stringify(result.actual.paraphrases)) {
|
1750
1820
|
if (!headerShown) {
|
@@ -1918,7 +1988,7 @@ module.exports = {
|
|
1918
1988
|
w,
|
1919
1989
|
// submitBug,
|
1920
1990
|
ensureTestFile,
|
1921
|
-
|
1991
|
+
rebuildTemplate,
|
1922
1992
|
processContext,
|
1923
1993
|
processContexts,
|
1924
1994
|
runTests,
|
@@ -1935,3 +2005,4 @@ module.exports = {
|
|
1935
2005
|
flattens,
|
1936
2006
|
writeTest
|
1937
2007
|
}
|
2008
|
+
|
package/index.js
CHANGED