botium-core 1.13.10 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "botium-core",
3
- "version": "1.13.10",
3
+ "version": "1.13.11",
4
4
  "description": "The Selenium for Chatbots",
5
5
  "main": "index.js",
6
6
  "module": "dist/botium-es.js",
@@ -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, wordCount).map(subset => subset.join(' ')) // botMessageWordsSubsets.filter(subset => subset.length === wordCount).map(subset => subset.reverse().join(' '))
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
- console.log('lala', subsetPhraseFound)
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