theprogrammablemind 7.5.8-beta.4 → 7.5.8-beta.41
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 +125 -53
- package/index.js +1 -0
- package/package.json +1 -1
- package/src/config.js +432 -213
- package/src/flatten.js +9 -1
- 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)) {
|
@@ -574,7 +577,7 @@ const setupProcessB = ({ config, initializer, allowDelta=false } = {}) => {
|
|
574
577
|
}
|
575
578
|
|
576
579
|
// instance template
|
577
|
-
const
|
580
|
+
const loadInstance = (config, instance) => {
|
578
581
|
const transitoryMode = global.transitoryMode
|
579
582
|
global.transitoryMode = false
|
580
583
|
const { /* data, generators, semantics, */ hierarchy } = setupProcessB({ config })
|
@@ -584,15 +587,15 @@ const processInstance = (config, instance) => {
|
|
584
587
|
if (results.extraConfig) {
|
585
588
|
// config.addInternal(results, useOldVersion = true, skipObjects = false, includeNamespaces = true, allowNameToBeNull = false)
|
586
589
|
// config.addInternal(config.template.queries[i], { handleCalculatedProps: true } )
|
587
|
-
config.addInternal(instance.template.queries[i], { handleCalculatedProps: true } )
|
590
|
+
config.addInternal(instance.template.queries[i], { addFirst: true, 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,8 @@ entodicton.knowledgeModule( {
|
|
1207
1258
|
`
|
1208
1259
|
*/
|
1209
1260
|
|
1210
|
-
|
1261
|
+
// loadTemplate BuiltTemplate
|
1262
|
+
const rebuildTemplate = async ({ config, target, template, errorHandler = defaultErrorHandler }) => {
|
1211
1263
|
const accumulators = {
|
1212
1264
|
resultss: [],
|
1213
1265
|
fragments: [],
|
@@ -1231,8 +1283,6 @@ const build = async ({ config, target, template, errorHandler = defaultErrorHand
|
|
1231
1283
|
if (property == 'fragments') {
|
1232
1284
|
global.transitoryMode = true
|
1233
1285
|
}
|
1234
|
-
// greg32
|
1235
|
-
// config.addInternal( query )
|
1236
1286
|
if (hierarchy) {
|
1237
1287
|
for (let edge of hierarchy) {
|
1238
1288
|
if (Array.isArray(edge)) {
|
@@ -1244,7 +1294,7 @@ const build = async ({ config, target, template, errorHandler = defaultErrorHand
|
|
1244
1294
|
}
|
1245
1295
|
|
1246
1296
|
try {
|
1247
|
-
const results = await _process(config, query.query, {initializer})
|
1297
|
+
const results = await _process(config, query.query, {initializer, rebuildingTemplate: true})
|
1248
1298
|
if (config.config.debug) {
|
1249
1299
|
// TODO pass in the error handler like the other ones
|
1250
1300
|
defaultInnerProcess(config, defaultErrorHandler, results)
|
@@ -1274,6 +1324,12 @@ const build = async ({ config, target, template, errorHandler = defaultErrorHand
|
|
1274
1324
|
// it will just get added to the config
|
1275
1325
|
const extraConfig = queryOrExtraConfig
|
1276
1326
|
console.log('config', extraConfig)
|
1327
|
+
try {
|
1328
|
+
config.addInternal(_.cloneDeep(extraConfig), { handleCalculatedProps: true } )
|
1329
|
+
} catch ( e ) {
|
1330
|
+
const where = extraConfig.where ? ` ${extraConfig.where}` : ''
|
1331
|
+
throw new Error(`Error processing extra config${where}: ${e.stack}}`)
|
1332
|
+
}
|
1277
1333
|
accumulators[property].push({ extraConfig: true, ...extraConfig })
|
1278
1334
|
await looper(queries)
|
1279
1335
|
}
|
@@ -1349,9 +1405,15 @@ const knowledgeModule = async ({
|
|
1349
1405
|
beforeTests = () => {},
|
1350
1406
|
afterTests = () => {},
|
1351
1407
|
beforeTest = () => {},
|
1352
|
-
afterTest = () => {}
|
1408
|
+
afterTest = () => {},
|
1409
|
+
...rest
|
1353
1410
|
} = {}) => {
|
1354
1411
|
|
1412
|
+
const unknownArgs = Object.keys(rest)
|
1413
|
+
if (unknownArgs.length > 0) {
|
1414
|
+
throw new Error(`Unknown arguments to knowledgeModule: ${unknownArgs.join()}`)
|
1415
|
+
}
|
1416
|
+
|
1355
1417
|
config.beforeQuery = beforeQuery
|
1356
1418
|
config.beforeTests = beforeTests
|
1357
1419
|
config.afterTests = afterTests
|
@@ -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
|
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
|
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 (
|
1716
|
-
|
1717
|
-
|
1718
|
-
|
1719
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
2004
|
+
loadInstance,
|
1934
2005
|
gs,
|
1935
2006
|
flattens,
|
1936
2007
|
writeTest
|
1937
2008
|
}
|
2009
|
+
|
package/index.js
CHANGED