botium-core 1.13.4 → 1.13.6
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 +262 -88
- package/dist/botium-cjs.js.map +1 -1
- package/dist/botium-es.js +262 -88
- package/dist/botium-es.js.map +1 -1
- package/package.json +19 -19
- package/src/helpers/RetryHelper.js +3 -2
- package/src/scripting/CompilerXlsx.js +1 -0
- package/src/scripting/MatchFunctions.js +3 -1
- package/src/scripting/ScriptingMemory.js +41 -2
- package/src/scripting/ScriptingProvider.js +164 -56
- package/src/scripting/helper.js +2 -0
- package/src/scripting/logichook/asserter/BotRepliesConsumedAsserter.js +1 -1
- package/src/scripting/logichook/asserter/BotRepliesUnconsumedCountAsserter.js +1 -1
- package/src/scripting/logichook/asserter/ButtonsAsserter.js +1 -1
- package/src/scripting/logichook/asserter/ButtonsCountAsserter.js +1 -1
- package/src/scripting/logichook/asserter/ButtonsCountRecAsserter.js +1 -1
- package/src/scripting/logichook/asserter/CardsAsserter.js +1 -1
- package/src/scripting/logichook/asserter/CardsCountAsserter.js +1 -1
- package/src/scripting/logichook/asserter/CardsCountRecAsserter.js +1 -1
- package/src/scripting/logichook/asserter/EntitiesAsserter.js +1 -1
- package/src/scripting/logichook/asserter/EntityContentAsserter.js +2 -2
- package/src/scripting/logichook/asserter/EntityValuesAsserter.js +1 -1
- package/src/scripting/logichook/asserter/FormsAsserter.js +1 -1
- package/src/scripting/logichook/asserter/IntentAsserter.js +3 -3
- package/src/scripting/logichook/asserter/IntentConfidenceAsserter.js +4 -4
- package/src/scripting/logichook/asserter/IntentUniqueAsserter.js +2 -2
- package/src/scripting/logichook/asserter/JsonPathAsserter.js +5 -5
- package/src/scripting/logichook/asserter/JsonPathCountAsserter.js +2 -2
- package/src/scripting/logichook/asserter/MediaAsserter.js +1 -1
- package/src/scripting/logichook/asserter/MediaCountAsserter.js +1 -1
- package/src/scripting/logichook/asserter/MediaCountRecAsserter.js +1 -1
- package/src/scripting/logichook/asserter/PauseAsserter.js +1 -1
- package/src/scripting/logichook/asserter/ResponseLengthAsserter.js +3 -2
- package/src/scripting/logichook/asserter/TextContainsAllAsserter.js +2 -1
- package/src/scripting/logichook/asserter/TextContainsAllICAsserter.js +2 -1
- package/src/scripting/logichook/asserter/TextContainsAnyAsserter.js +1 -0
- package/src/scripting/logichook/asserter/TextContainsAnyICAsserter.js +2 -1
- package/src/scripting/logichook/asserter/TextEqualsAnyAsserter.js +2 -1
- package/src/scripting/logichook/asserter/TextEqualsAnyICAsserter.js +2 -1
- package/src/scripting/logichook/asserter/TextRegexpAllAsserter.js +2 -1
- package/src/scripting/logichook/asserter/TextRegexpAllICAsserter.js +2 -1
- package/src/scripting/logichook/asserter/TextRegexpAnyAsserter.js +1 -0
- package/src/scripting/logichook/asserter/TextRegexpAnyICAsserter.js +2 -1
- package/src/scripting/logichook/asserter/TextWildcardAllAsserter.js +2 -1
- package/src/scripting/logichook/asserter/TextWildcardAllICAsserter.js +2 -1
- package/src/scripting/logichook/asserter/TextWildcardAnyAsserter.js +1 -0
- package/src/scripting/logichook/asserter/TextWildcardAnyICAsserter.js +2 -1
- package/src/scripting/logichook/asserter/TextWildcardExactAllAsserter.js +2 -1
- package/src/scripting/logichook/asserter/TextWildcardExactAllICAsserter.js +2 -1
- package/src/scripting/logichook/asserter/TextWildcardExactAnyAsserter.js +1 -0
- package/src/scripting/logichook/asserter/TextWildcardExactAnyICAsserter.js +2 -1
- package/src/scripting/logichook/asserter/WerAsserter.js +10 -8
- package/src/scripting/logichook/userinput/MediaInput.js +2 -1
- package/test/compiler/compilercsv.spec.js +9 -2
- package/test/compiler/convos/csv/utterances_variable_row_len.csv +1 -1
- package/test/convo/fillAndApplyScriptingMemory.spec.js +64 -4
- package/test/convo/transcript.spec.js +15 -6
- package/test/scripting/asserters/convos/{wer_threshold_nok.yml → wer_threshold_nok_float.yml} +0 -0
- package/test/scripting/asserters/convos/wer_threshold_nok_percentage.yml +7 -0
- package/test/scripting/asserters/convos/{wer_threshold_ok.yml → wer_threshold_ok_float.yml} +0 -0
- package/test/scripting/asserters/convos/wer_threshold_ok_percentage.yml +7 -0
- package/test/scripting/asserters/entityContentAsserter.spec.js +2 -7
- package/test/scripting/asserters/intentAsserter.spec.js +1 -1
- package/test/scripting/asserters/intentConfidenceAsserter.spec.js +3 -7
- package/test/scripting/asserters/jsonpathAsserter.spec.js +1 -1
- package/test/scripting/asserters/werAsserter.spec.js +25 -5
- package/test/scripting/matching/matchingmode.spec.js +42 -2
- package/test/scripting/scriptingModificator.spec.js +1 -2
- package/test/scripting/scriptingProvider.spec.js +156 -4
- package/test/scripting/utteranceexpansion/associateByIndex.spec.js +15 -15
|
@@ -8,7 +8,7 @@ const _cardsCount = ({ botMsg }) => {
|
|
|
8
8
|
module.exports = class CardsCountAsserter extends BaseCountAsserter {
|
|
9
9
|
constructor (context, caps = {}) {
|
|
10
10
|
super(context, caps, 'Cards')
|
|
11
|
-
this.name = '
|
|
11
|
+
this.name = 'Cards Count Asserter'
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
async _getCount (argv) { return _cardsCount(argv) }
|
|
@@ -8,7 +8,7 @@ const _cardsCount = ({ botMsg }) => {
|
|
|
8
8
|
module.exports = class CardsCountRecAsserter extends BaseCountAsserter {
|
|
9
9
|
constructor (context, caps = {}) {
|
|
10
10
|
super(context, caps, 'Cards')
|
|
11
|
-
this.name = '
|
|
11
|
+
this.name = 'Cards Count (recursive) Asserter'
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
async _getCount (argv) { return _cardsCount(argv) }
|
|
@@ -6,12 +6,12 @@ module.exports = class EntityContentAsserter {
|
|
|
6
6
|
constructor (context, caps = {}) {
|
|
7
7
|
this.context = context
|
|
8
8
|
this.caps = caps
|
|
9
|
-
this.name = '
|
|
9
|
+
this.name = 'NLU Entity Content Asserter'
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
assertConvoStep ({ convo, convoStep, args, botMsg }) {
|
|
13
13
|
if (!args || args.length < 2) {
|
|
14
|
-
return Promise.reject(new BotiumError(`${convoStep.stepTag}:
|
|
14
|
+
return Promise.reject(new BotiumError(`${convoStep.stepTag}: ${this.name} Missing argument`,
|
|
15
15
|
{
|
|
16
16
|
type: 'asserter',
|
|
17
17
|
subtype: 'wrong parameters',
|
|
@@ -6,7 +6,7 @@ module.exports = class EntityValuesAsserter {
|
|
|
6
6
|
constructor (context, caps = {}) {
|
|
7
7
|
this.context = context
|
|
8
8
|
this.caps = caps
|
|
9
|
-
this.name = '
|
|
9
|
+
this.name = 'NLU Entity Values Asserter'
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
assertConvoStep ({ convo, convoStep, args, botMsg }) {
|
|
@@ -5,12 +5,12 @@ module.exports = class IntentAsserter {
|
|
|
5
5
|
constructor (context, caps = {}) {
|
|
6
6
|
this.context = context
|
|
7
7
|
this.caps = caps
|
|
8
|
-
this.name = '
|
|
8
|
+
this.name = 'NLU Intent Asserter'
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
assertConvoStep ({ convo, convoStep, args, botMsg }) {
|
|
12
12
|
if (!args || args.length < 1) {
|
|
13
|
-
return Promise.reject(new BotiumError(`${convoStep.stepTag}:
|
|
13
|
+
return Promise.reject(new BotiumError(`${convoStep.stepTag}: ${this.name} Missing argument`,
|
|
14
14
|
{
|
|
15
15
|
type: 'asserter',
|
|
16
16
|
subtype: 'wrong parameters',
|
|
@@ -20,7 +20,7 @@ module.exports = class IntentAsserter {
|
|
|
20
20
|
))
|
|
21
21
|
}
|
|
22
22
|
if (args.length > 1) {
|
|
23
|
-
return Promise.reject(new BotiumError(`${convoStep.stepTag}:
|
|
23
|
+
return Promise.reject(new BotiumError(`${convoStep.stepTag}: ${this.name} Too much arguments "${args}"`,
|
|
24
24
|
{
|
|
25
25
|
type: 'asserter',
|
|
26
26
|
subtype: 'wrong parameters',
|
|
@@ -17,12 +17,12 @@ module.exports = class IntentConfidenceAsserter {
|
|
|
17
17
|
throw Error(`IntentConfidenceAsserter Excepted minimum is not valid ${this.globalExpectedMinimum}`)
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
this.name = '
|
|
20
|
+
this.name = 'NLU Intent Confidence Asserter'
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
assertConvoStep ({ convo, convoStep, args, botMsg, isGlobal }) {
|
|
24
24
|
if (args.length > 1) {
|
|
25
|
-
return Promise.reject(new BotiumError(`${convoStep.stepTag}:
|
|
25
|
+
return Promise.reject(new BotiumError(`${convoStep.stepTag}: ${this.name} Too much arguments "${args}"`,
|
|
26
26
|
{
|
|
27
27
|
type: 'asserter',
|
|
28
28
|
subtype: 'wrong parameters',
|
|
@@ -35,7 +35,7 @@ module.exports = class IntentConfidenceAsserter {
|
|
|
35
35
|
const hasLocalExpectedMinimum = args && args.length
|
|
36
36
|
|
|
37
37
|
if (!this.hasGlobalExpectedMinimum && !hasLocalExpectedMinimum) {
|
|
38
|
-
return Promise.reject(new BotiumError(`${convoStep.stepTag}:
|
|
38
|
+
return Promise.reject(new BotiumError(`${convoStep.stepTag}: NLU Intent Confidence Asserter configured neither global, nor local`,
|
|
39
39
|
{
|
|
40
40
|
type: 'asserter',
|
|
41
41
|
subtype: 'wrong parameters',
|
|
@@ -53,7 +53,7 @@ module.exports = class IntentConfidenceAsserter {
|
|
|
53
53
|
if (hasLocalExpectedMinimum) {
|
|
54
54
|
expectedMinimum = Number(args[0])
|
|
55
55
|
if (parseInt(expectedMinimum, 10) !== expectedMinimum) {
|
|
56
|
-
return Promise.reject(new BotiumError(`${convoStep.stepTag}:
|
|
56
|
+
return Promise.reject(new BotiumError(`${convoStep.stepTag}: NLU Intent Confidence Asserter Wrong argument. It must be integer "${args[0]}"`,
|
|
57
57
|
{
|
|
58
58
|
type: 'asserter',
|
|
59
59
|
subtype: 'wrong parameters',
|
|
@@ -5,13 +5,13 @@ module.exports = class IntentUniqueAsserter {
|
|
|
5
5
|
constructor (context, caps = {}) {
|
|
6
6
|
this.context = context
|
|
7
7
|
this.caps = caps
|
|
8
|
-
this.name = '
|
|
8
|
+
this.name = 'NLU Intent Unique Asserter'
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
assertConvoStep ({ convo, convoStep, args, botMsg }) {
|
|
12
12
|
if (args.length > 0) {
|
|
13
13
|
return Promise.reject(new BotiumError(
|
|
14
|
-
`${convoStep.stepTag}:
|
|
14
|
+
`${convoStep.stepTag}: ${this.name} Too much argument "${args}"`,
|
|
15
15
|
{
|
|
16
16
|
type: 'asserter',
|
|
17
17
|
subtype: 'wrong parameters',
|
|
@@ -10,7 +10,7 @@ module.exports = class JsonPathAsserter {
|
|
|
10
10
|
this.context = context
|
|
11
11
|
this.caps = caps
|
|
12
12
|
this.globalArgs = globalArgs
|
|
13
|
-
this.name = context.ref || '
|
|
13
|
+
this.name = context.ref || 'JsonPath Asserter'
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
assertNotConvoStep (params) {
|
|
@@ -24,7 +24,7 @@ module.exports = class JsonPathAsserter {
|
|
|
24
24
|
_getConfig (convoStep, args) {
|
|
25
25
|
if (this.globalArgs && this.globalArgs.path) {
|
|
26
26
|
if (args && args.length > 1) {
|
|
27
|
-
throw new BotiumError(`${convoStep.stepTag}:
|
|
27
|
+
throw new BotiumError(`${convoStep.stepTag}: ${this.name} 0 or 1 arguments expected "${toString(args)}"`,
|
|
28
28
|
{
|
|
29
29
|
type: 'asserter',
|
|
30
30
|
subtype: 'wrong parameters',
|
|
@@ -44,7 +44,7 @@ module.exports = class JsonPathAsserter {
|
|
|
44
44
|
if (_.has(this.globalArgs, 'argCount')) {
|
|
45
45
|
const argCount = this.globalArgs.argCount
|
|
46
46
|
if (argCount === 0 && args && args.length > 0) {
|
|
47
|
-
throw new BotiumError(`${convoStep.stepTag}:
|
|
47
|
+
throw new BotiumError(`${convoStep.stepTag}: ${this.name} ${argCount} arguments expected "${toString(args)}"`,
|
|
48
48
|
{
|
|
49
49
|
type: 'asserter',
|
|
50
50
|
subtype: 'wrong parameters',
|
|
@@ -56,7 +56,7 @@ module.exports = class JsonPathAsserter {
|
|
|
56
56
|
}
|
|
57
57
|
)
|
|
58
58
|
} else if (!args || args.length !== argCount) {
|
|
59
|
-
throw new BotiumError(`${convoStep.stepTag}:
|
|
59
|
+
throw new BotiumError(`${convoStep.stepTag}: ${this.name} ${argCount} arguments expected "${toString(args)}"`,
|
|
60
60
|
{
|
|
61
61
|
type: 'asserter',
|
|
62
62
|
subtype: 'wrong parameters',
|
|
@@ -75,7 +75,7 @@ module.exports = class JsonPathAsserter {
|
|
|
75
75
|
}
|
|
76
76
|
} else {
|
|
77
77
|
if (!args || args.length === 0 || args.length > 2) {
|
|
78
|
-
throw new BotiumError(`${convoStep.stepTag}:
|
|
78
|
+
throw new BotiumError(`${convoStep.stepTag}: ${this.name} 1 or 2 arguments expected "${toString(args)}"`,
|
|
79
79
|
{
|
|
80
80
|
type: 'asserter',
|
|
81
81
|
subtype: 'wrong parameters',
|
|
@@ -11,7 +11,7 @@ const _jsonPathCount = ({ botMsg, args }) => {
|
|
|
11
11
|
module.exports = class JsonPathCountAsserter extends BaseCountAsserter {
|
|
12
12
|
constructor (context, caps = {}) {
|
|
13
13
|
super(context, caps, 'JsonPath', 1)
|
|
14
|
-
this.name = '
|
|
14
|
+
this.name = 'JsonPath Count Asserter'
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
async _getCount (argv) { return _jsonPathCount(argv) }
|
|
@@ -20,7 +20,7 @@ module.exports = class JsonPathCountAsserter extends BaseCountAsserter {
|
|
|
20
20
|
const { args, convoStep } = argv
|
|
21
21
|
|
|
22
22
|
if (!args || args.length < 1 || args.length > 2) {
|
|
23
|
-
throw new BotiumError(`${convoStep.stepTag}:
|
|
23
|
+
throw new BotiumError(`${convoStep.stepTag}: ${this.name} 1 or 2 arguments expected "${args}"`,
|
|
24
24
|
{
|
|
25
25
|
type: 'asserter',
|
|
26
26
|
subtype: 'wrong parameters',
|
|
@@ -8,7 +8,7 @@ const _mediaCount = ({ botMsg }) => {
|
|
|
8
8
|
module.exports = class MediaCountAsserter extends BaseCountAsserter {
|
|
9
9
|
constructor (context, caps = {}) {
|
|
10
10
|
super(context, caps, 'Media')
|
|
11
|
-
this.name = '
|
|
11
|
+
this.name = 'Media Attachment Count Asserter'
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
async _getCount (argv) { return _mediaCount(argv) }
|
|
@@ -8,7 +8,7 @@ const _mediaCount = ({ botMsg }) => {
|
|
|
8
8
|
module.exports = class MediaCountRecAsserter extends BaseCountAsserter {
|
|
9
9
|
constructor (context, caps = {}) {
|
|
10
10
|
super(context, caps, 'Media')
|
|
11
|
-
this.name = '
|
|
11
|
+
this.name = 'Media Count (recursive) Asserter'
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
async _getCount (argv) { return _mediaCount(argv) }
|
|
@@ -12,6 +12,7 @@ module.exports = class ResponseLengthAsserter {
|
|
|
12
12
|
if (globalArgs && globalArgs.maximumCount) {
|
|
13
13
|
this.globalMaximumCount = Number(globalArgs.maximumCount)
|
|
14
14
|
}
|
|
15
|
+
this.name = 'Response Length Asserter'
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
assertConvoStep ({ convo, convoStep, args, botMsg }) {
|
|
@@ -32,7 +33,7 @@ module.exports = class ResponseLengthAsserter {
|
|
|
32
33
|
return Promise.reject(new BotiumError(`${convoStep.stepTag}: Expected maximum response count ${checkCount}, found ${botMsg.messageText.length}`,
|
|
33
34
|
{
|
|
34
35
|
type: 'asserter',
|
|
35
|
-
source:
|
|
36
|
+
source: this.name,
|
|
36
37
|
context: {
|
|
37
38
|
constructor: {
|
|
38
39
|
globalArgs: this.globalArgs
|
|
@@ -57,7 +58,7 @@ module.exports = class ResponseLengthAsserter {
|
|
|
57
58
|
return Promise.reject(new BotiumError(`${convoStep.stepTag}: Expected maximum response length ${checkLength} characters, found ${textToCheck.length}`,
|
|
58
59
|
{
|
|
59
60
|
type: 'asserter',
|
|
60
|
-
source:
|
|
61
|
+
source: this.name,
|
|
61
62
|
context: {
|
|
62
63
|
constructor: {
|
|
63
64
|
globalArgs: this.globalArgs
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
const BaseTextAsserter = require('./BaseTextAsserter')
|
|
2
2
|
const MatchFunctions = require('../../MatchFunctions')
|
|
3
3
|
|
|
4
|
-
module.exports = class
|
|
4
|
+
module.exports = class TextContainsAllAsserter extends BaseTextAsserter {
|
|
5
5
|
constructor (context, caps = {}) {
|
|
6
6
|
super(context, caps, MatchFunctions.include(false), 'all')
|
|
7
|
+
this.name = 'Text Contains All Asserter'
|
|
7
8
|
}
|
|
8
9
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
const BaseTextAsserter = require('./BaseTextAsserter')
|
|
2
2
|
const MatchFunctions = require('../../MatchFunctions')
|
|
3
3
|
|
|
4
|
-
module.exports = class
|
|
4
|
+
module.exports = class TextContainsAllICAsserter extends BaseTextAsserter {
|
|
5
5
|
constructor (context, caps = {}) {
|
|
6
6
|
super(context, caps, MatchFunctions.include(true), 'all')
|
|
7
|
+
this.name = 'Text Contains All (ignore case) Asserter'
|
|
7
8
|
}
|
|
8
9
|
}
|
|
@@ -4,5 +4,6 @@ const MatchFunctions = require('../../MatchFunctions')
|
|
|
4
4
|
module.exports = class TextContainsAnyAsserter extends BaseTextAsserter {
|
|
5
5
|
constructor (context, caps = {}) {
|
|
6
6
|
super(context, caps, MatchFunctions.include(false), 'any')
|
|
7
|
+
this.name = 'Text Contains Any Asserter'
|
|
7
8
|
}
|
|
8
9
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
const BaseTextAsserter = require('./BaseTextAsserter')
|
|
2
2
|
const MatchFunctions = require('../../MatchFunctions')
|
|
3
3
|
|
|
4
|
-
module.exports = class
|
|
4
|
+
module.exports = class TextContainsAnyICAsserter extends BaseTextAsserter {
|
|
5
5
|
constructor (context, caps = {}) {
|
|
6
6
|
super(context, caps, MatchFunctions.include(true), 'any')
|
|
7
|
+
this.name = 'Text Contains Any (ignore case) Asserter'
|
|
7
8
|
}
|
|
8
9
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
const BaseTextAsserter = require('./BaseTextAsserter')
|
|
2
2
|
const MatchFunctions = require('../../MatchFunctions')
|
|
3
3
|
|
|
4
|
-
module.exports = class
|
|
4
|
+
module.exports = class TextEqualsAnyAsserter extends BaseTextAsserter {
|
|
5
5
|
constructor (context, caps = {}) {
|
|
6
6
|
super(context, caps, MatchFunctions.equals(false), 'any', true)
|
|
7
|
+
this.name = 'Text Equals Any Asserter'
|
|
7
8
|
}
|
|
8
9
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
const BaseTextAsserter = require('./BaseTextAsserter')
|
|
2
2
|
const MatchFunctions = require('../../MatchFunctions')
|
|
3
3
|
|
|
4
|
-
module.exports = class
|
|
4
|
+
module.exports = class TextEqualsAnyICAsserter extends BaseTextAsserter {
|
|
5
5
|
constructor (context, caps = {}) {
|
|
6
6
|
super(context, caps, MatchFunctions.equals(true), 'any', true)
|
|
7
|
+
this.name = 'Text Equals Any (ignore case) Asserter'
|
|
7
8
|
}
|
|
8
9
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
const BaseTextAsserter = require('./BaseTextAsserter')
|
|
2
2
|
const MatchFunctions = require('../../MatchFunctions')
|
|
3
3
|
|
|
4
|
-
module.exports = class
|
|
4
|
+
module.exports = class TextRegexpAllAsserter extends BaseTextAsserter {
|
|
5
5
|
constructor (context, caps = {}) {
|
|
6
6
|
super(context, caps, MatchFunctions.regexp(false), 'all')
|
|
7
|
+
this.name = 'Text Regexp All Asserter'
|
|
7
8
|
}
|
|
8
9
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
const BaseTextAsserter = require('./BaseTextAsserter')
|
|
2
2
|
const MatchFunctions = require('../../MatchFunctions')
|
|
3
3
|
|
|
4
|
-
module.exports = class
|
|
4
|
+
module.exports = class TextRegexpAllICAsserter extends BaseTextAsserter {
|
|
5
5
|
constructor (context, caps = {}) {
|
|
6
6
|
super(context, caps, MatchFunctions.regexp(true), 'all')
|
|
7
|
+
this.name = 'Text Regexp All (ignore all) Asserter'
|
|
7
8
|
}
|
|
8
9
|
}
|
|
@@ -4,5 +4,6 @@ const MatchFunctions = require('../../MatchFunctions')
|
|
|
4
4
|
module.exports = class TextRegexpAnyAsserter extends BaseTextAsserter {
|
|
5
5
|
constructor (context, caps = {}) {
|
|
6
6
|
super(context, caps, MatchFunctions.regexp(false), 'any')
|
|
7
|
+
this.name = 'Text Regexp Any Asserter'
|
|
7
8
|
}
|
|
8
9
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
const BaseTextAsserter = require('./BaseTextAsserter')
|
|
2
2
|
const MatchFunctions = require('../../MatchFunctions')
|
|
3
3
|
|
|
4
|
-
module.exports = class
|
|
4
|
+
module.exports = class TextRegexpAnyICAsserter extends BaseTextAsserter {
|
|
5
5
|
constructor (context, caps = {}) {
|
|
6
6
|
super(context, caps, MatchFunctions.regexp(true), 'any')
|
|
7
|
+
this.name = 'Text Regexp Any (ignore case) Asserter'
|
|
7
8
|
}
|
|
8
9
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
const BaseTextAsserter = require('./BaseTextAsserter')
|
|
2
2
|
const MatchFunctions = require('../../MatchFunctions')
|
|
3
3
|
|
|
4
|
-
module.exports = class
|
|
4
|
+
module.exports = class TextWildcardAllAsserter extends BaseTextAsserter {
|
|
5
5
|
constructor (context, caps = {}) {
|
|
6
6
|
super(context, caps, MatchFunctions.wildcard(false), 'all')
|
|
7
|
+
this.name = 'Text Wildcard All Asserter'
|
|
7
8
|
}
|
|
8
9
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
const BaseTextAsserter = require('./BaseTextAsserter')
|
|
2
2
|
const MatchFunctions = require('../../MatchFunctions')
|
|
3
3
|
|
|
4
|
-
module.exports = class
|
|
4
|
+
module.exports = class TextWildcardAllICAsserter extends BaseTextAsserter {
|
|
5
5
|
constructor (context, caps = {}) {
|
|
6
6
|
super(context, caps, MatchFunctions.wildcard(true), 'all')
|
|
7
|
+
this.name = 'Text Wildcard All (ignore case) Asserter'
|
|
7
8
|
}
|
|
8
9
|
}
|
|
@@ -4,5 +4,6 @@ const MatchFunctions = require('../../MatchFunctions')
|
|
|
4
4
|
module.exports = class TextWildcardAnyAsserter extends BaseTextAsserter {
|
|
5
5
|
constructor (context, caps = {}) {
|
|
6
6
|
super(context, caps, MatchFunctions.wildcard(false), 'any')
|
|
7
|
+
this.name = 'Text Wildcard Any Asserter'
|
|
7
8
|
}
|
|
8
9
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
const BaseTextAsserter = require('./BaseTextAsserter')
|
|
2
2
|
const MatchFunctions = require('../../MatchFunctions')
|
|
3
3
|
|
|
4
|
-
module.exports = class
|
|
4
|
+
module.exports = class TextWildcardAnyICAsserter extends BaseTextAsserter {
|
|
5
5
|
constructor (context, caps = {}) {
|
|
6
6
|
super(context, caps, MatchFunctions.wildcard(true), 'any')
|
|
7
|
+
this.name = 'Text Wildcard Any (ignore case) Asserter'
|
|
7
8
|
}
|
|
8
9
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
const BaseTextAsserter = require('./BaseTextAsserter')
|
|
2
2
|
const MatchFunctions = require('../../MatchFunctions')
|
|
3
3
|
|
|
4
|
-
module.exports = class
|
|
4
|
+
module.exports = class TextWildcardExactAllAsserter extends BaseTextAsserter {
|
|
5
5
|
constructor (context, caps = {}) {
|
|
6
6
|
super(context, caps, MatchFunctions.wildcardExact(false), 'all')
|
|
7
|
+
this.name = 'Text Wildcard Exact All Asserter'
|
|
7
8
|
}
|
|
8
9
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
const BaseTextAsserter = require('./BaseTextAsserter')
|
|
2
2
|
const MatchFunctions = require('../../MatchFunctions')
|
|
3
3
|
|
|
4
|
-
module.exports = class
|
|
4
|
+
module.exports = class TextWildcardExactAllICAsserter extends BaseTextAsserter {
|
|
5
5
|
constructor (context, caps = {}) {
|
|
6
6
|
super(context, caps, MatchFunctions.wildcardExact(true), 'all')
|
|
7
|
+
this.name = 'Text Wildcard Exact All (ignore) Asserter'
|
|
7
8
|
}
|
|
8
9
|
}
|
|
@@ -4,5 +4,6 @@ const MatchFunctions = require('../../MatchFunctions')
|
|
|
4
4
|
module.exports = class TextWildcardExactAnyAsserter extends BaseTextAsserter {
|
|
5
5
|
constructor (context, caps = {}) {
|
|
6
6
|
super(context, caps, MatchFunctions.wildcardExact(false), 'any')
|
|
7
|
+
this.name = 'Text Wildcard Exact Any Asserter'
|
|
7
8
|
}
|
|
8
9
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
const BaseTextAsserter = require('./BaseTextAsserter')
|
|
2
2
|
const MatchFunctions = require('../../MatchFunctions')
|
|
3
3
|
|
|
4
|
-
module.exports = class
|
|
4
|
+
module.exports = class TextWildcardExactAnyICAsserter extends BaseTextAsserter {
|
|
5
5
|
constructor (context, caps = {}) {
|
|
6
6
|
super(context, caps, MatchFunctions.wildcardExact(true), 'any')
|
|
7
|
+
this.name = 'Text Wildcard Exact Any (ignore case) Asserter'
|
|
7
8
|
}
|
|
8
9
|
}
|
|
@@ -6,12 +6,12 @@ module.exports = class WerAsserter {
|
|
|
6
6
|
constructor (context, caps = {}) {
|
|
7
7
|
this.context = context
|
|
8
8
|
this.caps = caps
|
|
9
|
-
this.name = '
|
|
9
|
+
this.name = 'Word Error Rate Asserter'
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
assertConvoStep ({ convo, convoStep, args, botMsg }) {
|
|
13
13
|
if (!args || args.length < 1) {
|
|
14
|
-
return Promise.reject(new BotiumError(`${convoStep.stepTag}:
|
|
14
|
+
return Promise.reject(new BotiumError(`${convoStep.stepTag}: ${this.name} - no argument given`,
|
|
15
15
|
{
|
|
16
16
|
type: 'asserter',
|
|
17
17
|
subtype: 'wrong parameters',
|
|
@@ -21,7 +21,7 @@ module.exports = class WerAsserter {
|
|
|
21
21
|
))
|
|
22
22
|
}
|
|
23
23
|
if (args.length > 2) {
|
|
24
|
-
return Promise.reject(new BotiumError(`${convoStep.stepTag}:
|
|
24
|
+
return Promise.reject(new BotiumError(`${convoStep.stepTag}: ${this.name} - too many arguments "${args}"`,
|
|
25
25
|
{
|
|
26
26
|
type: 'asserter',
|
|
27
27
|
subtype: 'wrong parameters',
|
|
@@ -32,12 +32,14 @@ module.exports = class WerAsserter {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
const utterance = args[0]
|
|
35
|
-
const threshold = args[1]
|
|
35
|
+
const threshold = ([',', '.'].find(p => `${args[1]}`.includes(p)) ? parseFloat(args[1]) : parseInt(args[1]) / 100).toFixed(2)
|
|
36
36
|
|
|
37
|
-
const wer = speechScorer.wordErrorRate(botMsg.messageText, utterance)
|
|
37
|
+
const wer = speechScorer.wordErrorRate(botMsg.messageText, utterance).toFixed(2)
|
|
38
38
|
if (wer > threshold) {
|
|
39
|
+
const _toPercent = (s) => `${(s * 100).toFixed(0)}%`
|
|
40
|
+
|
|
39
41
|
return Promise.reject(new BotiumError(
|
|
40
|
-
`${convoStep.stepTag}: Word
|
|
42
|
+
`${convoStep.stepTag}: Word Error Rate (${_toPercent(wer)}) higher than accepted (${_toPercent(threshold)})`,
|
|
41
43
|
{
|
|
42
44
|
type: 'asserter',
|
|
43
45
|
source: this.name,
|
|
@@ -47,8 +49,8 @@ module.exports = class WerAsserter {
|
|
|
47
49
|
}
|
|
48
50
|
},
|
|
49
51
|
cause: {
|
|
50
|
-
expected:
|
|
51
|
-
actual:
|
|
52
|
+
expected: `<=${_toPercent(threshold)}`,
|
|
53
|
+
actual: `${_toPercent(wer)}`
|
|
52
54
|
}
|
|
53
55
|
}
|
|
54
56
|
))
|
|
@@ -15,8 +15,15 @@ const buildContext = () => {
|
|
|
15
15
|
AddConvos: (c) => {
|
|
16
16
|
result.convos = result.convos.concat(c)
|
|
17
17
|
},
|
|
18
|
-
AddUtterances: (
|
|
19
|
-
|
|
18
|
+
AddUtterances: (utteranceStructsToAdd) => {
|
|
19
|
+
for (const utteranceStructToAdd of utteranceStructsToAdd) {
|
|
20
|
+
const existing = result.utterances.find(entry => entry.name === utteranceStructToAdd.name)
|
|
21
|
+
if (existing) {
|
|
22
|
+
existing.utterances = existing.utterances.concat(utteranceStructToAdd.utterances)
|
|
23
|
+
} else {
|
|
24
|
+
result.utterances.push(utteranceStructToAdd)
|
|
25
|
+
}
|
|
26
|
+
}
|
|
20
27
|
},
|
|
21
28
|
convos: [],
|
|
22
29
|
utterances: []
|