botium-core 1.13.9 → 1.13.11
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 +16 -10
- package/dist/botium-cjs.js.map +1 -1
- package/dist/botium-es.js +37 -31
- package/dist/botium-es.js.map +1 -1
- package/package.json +1 -1
- package/src/scripting/ScriptingProvider.js +2 -2
- package/src/scripting/helper.js +6 -2
package/package.json
CHANGED
|
@@ -261,7 +261,7 @@ module.exports = class ScriptingProvider {
|
|
|
261
261
|
}))
|
|
262
262
|
const globalAsserter = Object.values(this.globalAsserter)
|
|
263
263
|
.filter(a => a[asserterType])
|
|
264
|
-
.map(a => p(this.retryHelperAsserter, () => a[asserterType]({ convo, convoStep, scriptingMemory, args: [], isGlobal: true, ...rest })))
|
|
264
|
+
.map(a => p(this.retryHelperAsserter, () => a[asserterType]({ convo, convoStep, scriptingMemory, container, args: [], isGlobal: true, ...rest })))
|
|
265
265
|
|
|
266
266
|
const allPromises = [...convoAsserter, ...globalAsserter]
|
|
267
267
|
if (this.caps[Capabilities.SCRIPTING_ENABLE_MULTIPLE_ASSERT_ERRORS]) {
|
|
@@ -298,7 +298,7 @@ module.exports = class ScriptingProvider {
|
|
|
298
298
|
|
|
299
299
|
const globalPromises = Object.values(this.globalLogicHook)
|
|
300
300
|
.filter(l => l[hookType])
|
|
301
|
-
.map(l => p(this.retryHelperLogicHook, () => l[hookType]({ convo, convoStep, scriptingMemory, args: [], isGlobal: true, ...rest })))
|
|
301
|
+
.map(l => p(this.retryHelperLogicHook, () => l[hookType]({ convo, convoStep, scriptingMemory, container, args: [], isGlobal: true, ...rest })))
|
|
302
302
|
|
|
303
303
|
const allPromises = [...convoStepPromises, ...globalPromises]
|
|
304
304
|
if (allPromises.length > 0) return Promise.all(allPromises).then(() => true)
|
package/src/scripting/helper.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const _ = require('lodash')
|
|
2
2
|
const isJSON = require('is-json')
|
|
3
3
|
const speechScorer = require('word-error-rate')
|
|
4
|
+
const debug = require('debug')('botium-core-scripting-helper')
|
|
4
5
|
|
|
5
6
|
const { E_SCRIPTING_MEMORY_COLUMN_MODE } = require('../Enums')
|
|
6
7
|
|
|
@@ -561,7 +562,7 @@ const calculateWer = (str, pattern) => {
|
|
|
561
562
|
continue
|
|
562
563
|
}
|
|
563
564
|
const wordCount = wildcardPart.split(' ').length
|
|
564
|
-
const subsetPhrases = _getSubsets(botMessageWords,
|
|
565
|
+
const subsetPhrases = _getSubsets(botMessageWords, Math.min(wordCount, botMessageWords.length)).map(subset => subset.join(' '))
|
|
565
566
|
let subsetPhraseFound = null
|
|
566
567
|
for (const subsetPhrase of subsetPhrases) {
|
|
567
568
|
const localWer = speechScorer.wordErrorRate(subsetPhrase, wildcardPart).toFixed(2)
|
|
@@ -570,7 +571,9 @@ const calculateWer = (str, pattern) => {
|
|
|
570
571
|
wer = localWer
|
|
571
572
|
}
|
|
572
573
|
}
|
|
573
|
-
|
|
574
|
+
if (_.isNil(subsetPhraseFound)) {
|
|
575
|
+
throw new Error('Word Error Asserter: Something went wrong here, please try to modify your assertion!')
|
|
576
|
+
}
|
|
574
577
|
errors.push(_getErrors(_getWords(wildcardPart), _getWords(subsetPhraseFound)))
|
|
575
578
|
}
|
|
576
579
|
let errCount = 0
|
|
@@ -579,6 +582,7 @@ const calculateWer = (str, pattern) => {
|
|
|
579
582
|
errCount += err.filter(err => err === true).length
|
|
580
583
|
allCount += err.length
|
|
581
584
|
}
|
|
585
|
+
debug(`Word Error Rate Asserter - Compared Bot Message '${botMessage}' / '${utt}': ${(errCount / allCount).toFixed(2)}`)
|
|
582
586
|
return (errCount / allCount).toFixed(2)
|
|
583
587
|
}
|
|
584
588
|
|