botium-core 1.13.7 → 1.13.9
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/dist/botium-cjs.js +214 -1497
- package/dist/botium-cjs.js.map +1 -1
- package/dist/botium-es.js +214 -1497
- package/dist/botium-es.js.map +1 -1
- package/package.json +24 -24
- package/src/scripting/Convo.js +42 -15
- package/src/scripting/MatchFunctions.js +3 -4
- package/src/scripting/ScriptingProvider.js +11 -15
- package/src/scripting/helper.js +61 -2
- package/src/scripting/logichook/asserter/JsonPathAsserter.js +7 -3
- package/src/scripting/logichook/asserter/WerAsserter.js +3 -2
- package/src/scripting/logichook/logichooks/SetScriptingMemoryLogicHook.js +1 -1
- package/test/convo/convos/applyscriptingmemoryinbegin.convo.txt +14 -0
- package/test/convo/fillAndApplyScriptingMemory.spec.js +20 -0
- package/test/scripting/asserters/convos/wer_threshold_wildcard_nok_float.yml +7 -0
- package/test/scripting/asserters/convos/wer_threshold_wildcard_nok_percentage.yml +7 -0
- package/test/scripting/asserters/convos/wer_threshold_wildcard_ok_float.yml +7 -0
- package/test/scripting/asserters/convos/wer_threshold_wildcard_ok_percentage.yml +7 -0
- package/test/scripting/asserters/jsonpathAsserter.spec.js +90 -3
- package/test/scripting/asserters/werAsserter.spec.js +41 -0
- package/test/scripting/matching/matchingmode.spec.js +82 -0
- package/test/scripting/scriptingModificator.spec.js +2 -0
- package/test/scripting/scriptingmemory/convosPartial/buy.convo.txt +7 -0
- package/test/scripting/scriptingmemory/convosPartial/product.scriptingmemory.txt +2 -0
- package/test/scripting/scriptingmemory/convosPartial/sub1.pconvo.txt +7 -0
- package/test/scripting/scriptingmemory/convosPartial/sub2.pconvo.txt +7 -0
- package/test/scripting/scriptingmemory/fillScriptingMemoryFromFile.spec.js +10 -1
|
@@ -68,4 +68,45 @@ describe('scripting.asserters.werAsserter', function () {
|
|
|
68
68
|
assert.equal(err.message, 'wer_threshold_nok/Line 2: assertion error - Line 2: Word Error Rate (50%) higher than accepted (10%)')
|
|
69
69
|
}
|
|
70
70
|
})
|
|
71
|
+
|
|
72
|
+
it('ok wildcard (percentage)', async function () {
|
|
73
|
+
this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convos', 'wer_threshold_wildcard_ok_percentage.yml'))
|
|
74
|
+
|
|
75
|
+
this.compiler.ExpandScriptingMemoryToConvos()
|
|
76
|
+
assert.equal(this.compiler.convos.length, 1)
|
|
77
|
+
await this.compiler.convos[0].Run(this.container)
|
|
78
|
+
})
|
|
79
|
+
it('ok wildcard (float)', async function () {
|
|
80
|
+
this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convos', 'wer_threshold_wildcard_ok_float.yml'))
|
|
81
|
+
|
|
82
|
+
this.compiler.ExpandScriptingMemoryToConvos()
|
|
83
|
+
assert.equal(this.compiler.convos.length, 1)
|
|
84
|
+
await this.compiler.convos[0].Run(this.container)
|
|
85
|
+
})
|
|
86
|
+
it('nok wildcard (percentage)', async function () {
|
|
87
|
+
this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convos', 'wer_threshold_wildcard_nok_percentage.yml'))
|
|
88
|
+
|
|
89
|
+
this.compiler.ExpandScriptingMemoryToConvos()
|
|
90
|
+
assert.equal(this.compiler.convos.length, 1)
|
|
91
|
+
|
|
92
|
+
try {
|
|
93
|
+
await this.compiler.convos[0].Run(this.container)
|
|
94
|
+
assert.fail('expected error')
|
|
95
|
+
} catch (err) {
|
|
96
|
+
assert.equal(err.message, 'wer_threshold_wildcard_nok/Line 2: assertion error - Line 2: Word Error Rate (33%) higher than accepted (1%)')
|
|
97
|
+
}
|
|
98
|
+
})
|
|
99
|
+
it('nok wildcard (float)', async function () {
|
|
100
|
+
this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convos', 'wer_threshold_wildcard_nok_float.yml'))
|
|
101
|
+
|
|
102
|
+
this.compiler.ExpandScriptingMemoryToConvos()
|
|
103
|
+
assert.equal(this.compiler.convos.length, 1)
|
|
104
|
+
|
|
105
|
+
try {
|
|
106
|
+
await this.compiler.convos[0].Run(this.container)
|
|
107
|
+
assert.fail('expected error')
|
|
108
|
+
} catch (err) {
|
|
109
|
+
assert.equal(err.message, 'wer_threshold_wildcard_nok/Line 2: assertion error - Line 2: Word Error Rate (75%) higher than accepted (40%)')
|
|
110
|
+
}
|
|
111
|
+
})
|
|
71
112
|
})
|
|
@@ -387,4 +387,86 @@ describe('scripting.matching.matchingmode', function () {
|
|
|
387
387
|
assert.isTrue(this.compiler.Match('test 123', 'tast 123'))
|
|
388
388
|
})
|
|
389
389
|
})
|
|
390
|
+
|
|
391
|
+
describe('wer.lowthreshold.wildcard (float)', function () {
|
|
392
|
+
beforeEach(async function () {
|
|
393
|
+
const myCaps = {
|
|
394
|
+
[Capabilities.PROJECTNAME]: 'matching.matchingmode',
|
|
395
|
+
[Capabilities.CONTAINERMODE]: echoConnector,
|
|
396
|
+
[Capabilities.SCRIPTING_MATCHING_MODE]: 'wer',
|
|
397
|
+
[Capabilities.SCRIPTING_MATCHING_MODE_ARGS]: [0.4]
|
|
398
|
+
}
|
|
399
|
+
const driver = new BotDriver(myCaps)
|
|
400
|
+
this.compiler = driver.BuildCompiler()
|
|
401
|
+
this.container = await driver.Build()
|
|
402
|
+
})
|
|
403
|
+
afterEach(async function () {
|
|
404
|
+
this.container && await this.container.Clean()
|
|
405
|
+
})
|
|
406
|
+
|
|
407
|
+
it('should not match because of low threshold', async function () {
|
|
408
|
+
assert.isFalse(this.compiler.Match('This is an example', '* that are * hot'))
|
|
409
|
+
})
|
|
410
|
+
})
|
|
411
|
+
describe('wer.lowthreshold.wildcard (percentage)', function () {
|
|
412
|
+
beforeEach(async function () {
|
|
413
|
+
const myCaps = {
|
|
414
|
+
[Capabilities.PROJECTNAME]: 'matching.matchingmode',
|
|
415
|
+
[Capabilities.CONTAINERMODE]: echoConnector,
|
|
416
|
+
[Capabilities.SCRIPTING_MATCHING_MODE]: 'wer',
|
|
417
|
+
[Capabilities.SCRIPTING_MATCHING_MODE_ARGS]: [10]
|
|
418
|
+
}
|
|
419
|
+
const driver = new BotDriver(myCaps)
|
|
420
|
+
this.compiler = driver.BuildCompiler()
|
|
421
|
+
this.container = await driver.Build()
|
|
422
|
+
})
|
|
423
|
+
afterEach(async function () {
|
|
424
|
+
this.container && await this.container.Clean()
|
|
425
|
+
})
|
|
426
|
+
|
|
427
|
+
it('should not match because of low threshold', async function () {
|
|
428
|
+
assert.isFalse(this.compiler.Match('This is an example', '* is * hot'))
|
|
429
|
+
})
|
|
430
|
+
})
|
|
431
|
+
|
|
432
|
+
describe('wer.highthreshold.wildcard (float)', function () {
|
|
433
|
+
beforeEach(async function () {
|
|
434
|
+
const myCaps = {
|
|
435
|
+
[Capabilities.PROJECTNAME]: 'matching.matchingmode',
|
|
436
|
+
[Capabilities.CONTAINERMODE]: echoConnector,
|
|
437
|
+
[Capabilities.SCRIPTING_MATCHING_MODE]: 'wer',
|
|
438
|
+
[Capabilities.SCRIPTING_MATCHING_MODE_ARGS]: [0.4]
|
|
439
|
+
}
|
|
440
|
+
const driver = new BotDriver(myCaps)
|
|
441
|
+
this.compiler = driver.BuildCompiler()
|
|
442
|
+
this.container = await driver.Build()
|
|
443
|
+
})
|
|
444
|
+
afterEach(async function () {
|
|
445
|
+
this.container && await this.container.Clean()
|
|
446
|
+
})
|
|
447
|
+
|
|
448
|
+
it('should match because of high threshold', async function () {
|
|
449
|
+
assert.isTrue(this.compiler.Match('this is an example', 'this is * sample'))
|
|
450
|
+
})
|
|
451
|
+
})
|
|
452
|
+
describe('wer.highthreshold.wildcard (percentage)', function () {
|
|
453
|
+
beforeEach(async function () {
|
|
454
|
+
const myCaps = {
|
|
455
|
+
[Capabilities.PROJECTNAME]: 'matching.matchingmode',
|
|
456
|
+
[Capabilities.CONTAINERMODE]: echoConnector,
|
|
457
|
+
[Capabilities.SCRIPTING_MATCHING_MODE]: 'wer',
|
|
458
|
+
[Capabilities.SCRIPTING_MATCHING_MODE_ARGS]: [30]
|
|
459
|
+
}
|
|
460
|
+
const driver = new BotDriver(myCaps)
|
|
461
|
+
this.compiler = driver.BuildCompiler()
|
|
462
|
+
this.container = await driver.Build()
|
|
463
|
+
})
|
|
464
|
+
afterEach(async function () {
|
|
465
|
+
this.container && await this.container.Clean()
|
|
466
|
+
})
|
|
467
|
+
|
|
468
|
+
it('should match because of high threshold', async function () {
|
|
469
|
+
assert.isTrue(this.compiler.Match('this is an example', 'this is another *'))
|
|
470
|
+
})
|
|
471
|
+
})
|
|
390
472
|
})
|
|
@@ -20,6 +20,7 @@ describe('scriptingModificator.assertions', function () {
|
|
|
20
20
|
]
|
|
21
21
|
},
|
|
22
22
|
scriptingMemory: {},
|
|
23
|
+
container: {},
|
|
23
24
|
botMsg: {
|
|
24
25
|
buttons: [
|
|
25
26
|
{
|
|
@@ -47,6 +48,7 @@ describe('scriptingModificator.assertions', function () {
|
|
|
47
48
|
]
|
|
48
49
|
},
|
|
49
50
|
scriptingMemory: {},
|
|
51
|
+
container: {},
|
|
50
52
|
botMsg: {
|
|
51
53
|
nlp: {
|
|
52
54
|
intent: { name: 'test1' }
|
|
@@ -9,7 +9,7 @@ const echoConnector = ({ queueBotSays }) => {
|
|
|
9
9
|
const response = `You said: ${msg.messageText.replace('forcereplace1', 'OUTPUT1').replace('forcereplace2', 'OUTPUT2')}`
|
|
10
10
|
const botMsg = {
|
|
11
11
|
sender: 'bot',
|
|
12
|
-
sourceData: msg.sourceData,
|
|
12
|
+
sourceData: msg.sourceData || { request: msg.messageText },
|
|
13
13
|
messageText: response
|
|
14
14
|
}
|
|
15
15
|
queueBotSays(botMsg)
|
|
@@ -289,6 +289,15 @@ describe('scripting.scriptingmemory.fillingScriptingMemoryFromFile', function ()
|
|
|
289
289
|
this.compiler.ExpandScriptingMemoryToConvos()
|
|
290
290
|
assert.equal(this.compiler.convos.length, 1)
|
|
291
291
|
})
|
|
292
|
+
|
|
293
|
+
it('should replace scripting memory in partial convo', async function () {
|
|
294
|
+
this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convosPartial'))
|
|
295
|
+
this.compiler.ExpandScriptingMemoryToConvos()
|
|
296
|
+
this.compiler.ExpandConvos()
|
|
297
|
+
assert.equal(this.compiler.convos.length, 1)
|
|
298
|
+
|
|
299
|
+
await this.compiler.convos[0].Run(this.container)
|
|
300
|
+
})
|
|
292
301
|
})
|
|
293
302
|
|
|
294
303
|
describe('memoryenabled.originalkept', function () {
|