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.
Files changed (70) hide show
  1. package/dist/botium-cjs.js +262 -88
  2. package/dist/botium-cjs.js.map +1 -1
  3. package/dist/botium-es.js +262 -88
  4. package/dist/botium-es.js.map +1 -1
  5. package/package.json +19 -19
  6. package/src/helpers/RetryHelper.js +3 -2
  7. package/src/scripting/CompilerXlsx.js +1 -0
  8. package/src/scripting/MatchFunctions.js +3 -1
  9. package/src/scripting/ScriptingMemory.js +41 -2
  10. package/src/scripting/ScriptingProvider.js +164 -56
  11. package/src/scripting/helper.js +2 -0
  12. package/src/scripting/logichook/asserter/BotRepliesConsumedAsserter.js +1 -1
  13. package/src/scripting/logichook/asserter/BotRepliesUnconsumedCountAsserter.js +1 -1
  14. package/src/scripting/logichook/asserter/ButtonsAsserter.js +1 -1
  15. package/src/scripting/logichook/asserter/ButtonsCountAsserter.js +1 -1
  16. package/src/scripting/logichook/asserter/ButtonsCountRecAsserter.js +1 -1
  17. package/src/scripting/logichook/asserter/CardsAsserter.js +1 -1
  18. package/src/scripting/logichook/asserter/CardsCountAsserter.js +1 -1
  19. package/src/scripting/logichook/asserter/CardsCountRecAsserter.js +1 -1
  20. package/src/scripting/logichook/asserter/EntitiesAsserter.js +1 -1
  21. package/src/scripting/logichook/asserter/EntityContentAsserter.js +2 -2
  22. package/src/scripting/logichook/asserter/EntityValuesAsserter.js +1 -1
  23. package/src/scripting/logichook/asserter/FormsAsserter.js +1 -1
  24. package/src/scripting/logichook/asserter/IntentAsserter.js +3 -3
  25. package/src/scripting/logichook/asserter/IntentConfidenceAsserter.js +4 -4
  26. package/src/scripting/logichook/asserter/IntentUniqueAsserter.js +2 -2
  27. package/src/scripting/logichook/asserter/JsonPathAsserter.js +5 -5
  28. package/src/scripting/logichook/asserter/JsonPathCountAsserter.js +2 -2
  29. package/src/scripting/logichook/asserter/MediaAsserter.js +1 -1
  30. package/src/scripting/logichook/asserter/MediaCountAsserter.js +1 -1
  31. package/src/scripting/logichook/asserter/MediaCountRecAsserter.js +1 -1
  32. package/src/scripting/logichook/asserter/PauseAsserter.js +1 -1
  33. package/src/scripting/logichook/asserter/ResponseLengthAsserter.js +3 -2
  34. package/src/scripting/logichook/asserter/TextContainsAllAsserter.js +2 -1
  35. package/src/scripting/logichook/asserter/TextContainsAllICAsserter.js +2 -1
  36. package/src/scripting/logichook/asserter/TextContainsAnyAsserter.js +1 -0
  37. package/src/scripting/logichook/asserter/TextContainsAnyICAsserter.js +2 -1
  38. package/src/scripting/logichook/asserter/TextEqualsAnyAsserter.js +2 -1
  39. package/src/scripting/logichook/asserter/TextEqualsAnyICAsserter.js +2 -1
  40. package/src/scripting/logichook/asserter/TextRegexpAllAsserter.js +2 -1
  41. package/src/scripting/logichook/asserter/TextRegexpAllICAsserter.js +2 -1
  42. package/src/scripting/logichook/asserter/TextRegexpAnyAsserter.js +1 -0
  43. package/src/scripting/logichook/asserter/TextRegexpAnyICAsserter.js +2 -1
  44. package/src/scripting/logichook/asserter/TextWildcardAllAsserter.js +2 -1
  45. package/src/scripting/logichook/asserter/TextWildcardAllICAsserter.js +2 -1
  46. package/src/scripting/logichook/asserter/TextWildcardAnyAsserter.js +1 -0
  47. package/src/scripting/logichook/asserter/TextWildcardAnyICAsserter.js +2 -1
  48. package/src/scripting/logichook/asserter/TextWildcardExactAllAsserter.js +2 -1
  49. package/src/scripting/logichook/asserter/TextWildcardExactAllICAsserter.js +2 -1
  50. package/src/scripting/logichook/asserter/TextWildcardExactAnyAsserter.js +1 -0
  51. package/src/scripting/logichook/asserter/TextWildcardExactAnyICAsserter.js +2 -1
  52. package/src/scripting/logichook/asserter/WerAsserter.js +10 -8
  53. package/src/scripting/logichook/userinput/MediaInput.js +2 -1
  54. package/test/compiler/compilercsv.spec.js +9 -2
  55. package/test/compiler/convos/csv/utterances_variable_row_len.csv +1 -1
  56. package/test/convo/fillAndApplyScriptingMemory.spec.js +64 -4
  57. package/test/convo/transcript.spec.js +15 -6
  58. package/test/scripting/asserters/convos/{wer_threshold_nok.yml → wer_threshold_nok_float.yml} +0 -0
  59. package/test/scripting/asserters/convos/wer_threshold_nok_percentage.yml +7 -0
  60. package/test/scripting/asserters/convos/{wer_threshold_ok.yml → wer_threshold_ok_float.yml} +0 -0
  61. package/test/scripting/asserters/convos/wer_threshold_ok_percentage.yml +7 -0
  62. package/test/scripting/asserters/entityContentAsserter.spec.js +2 -7
  63. package/test/scripting/asserters/intentAsserter.spec.js +1 -1
  64. package/test/scripting/asserters/intentConfidenceAsserter.spec.js +3 -7
  65. package/test/scripting/asserters/jsonpathAsserter.spec.js +1 -1
  66. package/test/scripting/asserters/werAsserter.spec.js +25 -5
  67. package/test/scripting/matching/matchingmode.spec.js +42 -2
  68. package/test/scripting/scriptingModificator.spec.js +1 -2
  69. package/test/scripting/scriptingProvider.spec.js +156 -4
  70. 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 = 'CardsCountAsserter'
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 = 'CardsCountRecAsserter'
11
+ this.name = 'Cards Count (recursive) Asserter'
12
12
  }
13
13
 
14
14
  async _getCount (argv) { return _cardsCount(argv) }
@@ -6,7 +6,7 @@ module.exports = class EntitiesAsserter {
6
6
  constructor (context, caps = {}) {
7
7
  this.context = context
8
8
  this.caps = caps
9
- this.name = 'EntitiesAsserter'
9
+ this.name = 'NLU Entities Asserter'
10
10
  }
11
11
 
12
12
  assertConvoStep ({ convo, convoStep, args, botMsg }) {
@@ -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 = 'EntityContentAsserter'
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}: EntityContentAsserter Missing argument`,
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 = 'EntityValuesAsserter'
9
+ this.name = 'NLU Entity Values Asserter'
10
10
  }
11
11
 
12
12
  assertConvoStep ({ convo, convoStep, args, botMsg }) {
@@ -4,7 +4,7 @@ module.exports = class FormsAsserter {
4
4
  constructor (context, caps = {}) {
5
5
  this.context = context
6
6
  this.caps = caps
7
- this.name = 'FormsAsserter'
7
+ this.name = 'Form Elements Asserter'
8
8
  }
9
9
 
10
10
  _formTextsFromCardsRecursive (cards) {
@@ -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 = 'IntentAsserter'
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}: IntentAsserter Missing argument`,
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}: IntentAsserter Too much argument "${args}"`,
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 = 'IntentConfidenceAsserter'
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}: IntentConfidenceAsserter Too much arguments "${args}"`,
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}: IntentConfidenceAsserter configured neither global, nor local`,
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}: IntentConfidenceAsserter Wrong argument. It must be integer "${args[0]}"`,
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 = 'IntentUniqueAsserter'
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}: IntentUniqueAsserter Too much argument "${args}"`,
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 || 'JsonPathAsserter'
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}: JsonPathAsserter 0 or 1 arguments expected "${toString(args)}"`,
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}: JsonPathAsserter ${argCount} arguments expected "${toString(args)}"`,
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}: JsonPathAsserter ${argCount} arguments expected "${toString(args)}"`,
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}: JsonPathAsserter 1 or 2 arguments expected "${toString(args)}"`,
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 = 'JsonPathCountAsserter'
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}: JsonPathCountAsserter 1 or 2 arguments expected "${args}"`,
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',
@@ -5,7 +5,7 @@ module.exports = class MediaAsserter {
5
5
  constructor (context, caps = {}) {
6
6
  this.context = context
7
7
  this.caps = caps
8
- this.name = 'MediaAsserter'
8
+ this.name = 'Media Attachment Asserter'
9
9
  }
10
10
 
11
11
  _evalMedia (args, botMsg) {
@@ -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 = 'MediaCountAsserter'
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 = 'MediaCountRecAsserter'
11
+ this.name = 'Media Count (recursive) Asserter'
12
12
  }
13
13
 
14
14
  async _getCount (argv) { return _mediaCount(argv) }
@@ -4,7 +4,7 @@ module.exports = class PauseAsserter {
4
4
  constructor (context, caps = {}) {
5
5
  this.context = context
6
6
  this.caps = caps
7
- this.name = 'PauseAsserter'
7
+ this.name = 'Pause Asserter'
8
8
  }
9
9
 
10
10
  assertConvoBegin ({ convo, args }) {
@@ -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: 'ResponseCountAsserter',
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: 'ResponseLengthAsserter',
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 TextContainsAnyAsserter extends BaseTextAsserter {
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 TextContainsAnyAsserter extends BaseTextAsserter {
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 TextContainsAnyAsserter extends BaseTextAsserter {
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 TextExactAnyAsserter extends BaseTextAsserter {
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 TextEqualsAnyAsserter extends BaseTextAsserter {
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 TextRegexpAnyAsserter extends BaseTextAsserter {
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 TextRegexpAnyAsserter extends BaseTextAsserter {
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 TextRegexpAnyAsserter extends BaseTextAsserter {
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 TextWildcardAnyAsserter extends BaseTextAsserter {
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 TextWildcardAnyAsserter extends BaseTextAsserter {
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 TextWildcardAnyAsserter extends BaseTextAsserter {
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 TextWildcardExactAnyAsserter extends BaseTextAsserter {
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 TextWildcardExactAnyAsserter extends BaseTextAsserter {
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 TextWildcardExactAnyAsserter extends BaseTextAsserter {
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 = 'WerAsserter'
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}: WerAsserter Missing argument`,
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}: WerAsserter Too much argument "${args}"`,
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 error rate ${wer} > ${threshold} for ${utterance}`,
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: `Word error rate <= ${threshold}`,
51
- actual: `Word error rate = ${wer}`
52
+ expected: `<=${_toPercent(threshold)}`,
53
+ actual: `${_toPercent(wer)}`
52
54
  }
53
55
  }
54
56
  ))
@@ -165,7 +165,8 @@ module.exports = class MediaInput {
165
165
  mediaFiles.forEach(mf => {
166
166
  e.push({
167
167
  name: 'MEDIA',
168
- args: [mf]
168
+ args: [mf],
169
+ convoPostfix: _.last(mf.split('/'))
169
170
  })
170
171
  })
171
172
  } else {
@@ -15,8 +15,15 @@ const buildContext = () => {
15
15
  AddConvos: (c) => {
16
16
  result.convos = result.convos.concat(c)
17
17
  },
18
- AddUtterances: (u) => {
19
- result.utterances = result.utterances.concat(u)
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: []
@@ -1,3 +1,3 @@
1
- variable_row_len,goodbye, sdf, sdf, sdf,
1
+ variable_row_len,goodbye, col1, col2, col3,
2
2
  hello,goodbye
3
3
  hi,,sd,fs d,f ,sdf ,ds, fsd,f ,sdf, sd,f sd, f,sd f,