wingbot 3.68.2 → 3.68.4

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": "wingbot",
3
- "version": "3.68.2",
3
+ "version": "3.68.4",
4
4
  "description": "Enterprise Messaging Bot Conversation Engine",
5
5
  "main": "index.js",
6
6
  "type": "commonjs",
package/src/Ai.js CHANGED
@@ -282,6 +282,7 @@ class Ai {
282
282
  * @param {Function|string} [options.extractValue] - entity extractor
283
283
  * @param {boolean} [options.matchWholeWords] - match whole words at regular expression
284
284
  * @param {boolean} [options.replaceDiacritics] - keep diacritics when matching regexp
285
+ * @param {boolean} [options.caseSensitiveRegex] - make regex case sensitive
285
286
  * @param {string[]} [options.dependencies] - array of dependent entities
286
287
  * @param {boolean} [options.clearOverlaps] - let longer entities from NLP to replace entity
287
288
  * @returns {this}
@@ -58,6 +58,7 @@ const { iterateThroughWords } = require('../utils/ai');
58
58
  * @prop {Function|string} [extractValue] - entity extractor
59
59
  * @prop {boolean} [matchWholeWords] - match whole words at regular expression
60
60
  * @prop {boolean} [replaceDiacritics] - keep diacritics when matching regexp
61
+ * @prop {boolean} [options.caseSensitiveRegex] - make regex case sensitive
61
62
  * @prop {string[]} [dependencies] - array of dependent entities
62
63
  * @prop {boolean} [clearOverlaps] - let longer entities from NLP to replace entity
63
64
  */
@@ -576,6 +577,7 @@ class CustomEntityDetectionModel {
576
577
  * @param {boolean} [options.matchWholeWords] - match whole words at regular expression
577
578
  * @param {boolean} [options.replaceDiacritics] - replace diacritics when matching regexp
578
579
  * @param {string[]} [options.dependencies] - array of dependent entities
580
+ * @param {boolean} [options.caseSensitiveRegex] - make regex case sensitive
579
581
  */
580
582
  _regexpToDetector (regexp, options) {
581
583
  const { dependencies = [], extractValue = null } = options;
@@ -606,12 +608,16 @@ class CustomEntityDetectionModel {
606
608
  });
607
609
 
608
610
  if (options.matchWholeWords && !searchWithinWords) {
609
- replaced = `(?<=(^|[^a-z0-9\u00C0-\u017F]))${replaced}(?=([^a-z0-9\u00C0-\u017F]|$))`;
611
+ replaced = `(?<=(^|[^a-zA-Z0-9\u00C0-\u017F]))${replaced}(?=([^a-zA-Z0-9\u00C0-\u017F]|$))`;
610
612
  }
611
613
 
612
- const r = new RegExp(replaced, 'i');
613
- const lc = text.toLocaleLowerCase();
614
+ const r = new RegExp(replaced, options.caseSensitiveRegex ? '' : 'i');
615
+ const lc = options.caseSensitiveRegex
616
+ ? text
617
+ : text.toLocaleLowerCase();
618
+
614
619
  let matchText = lc;
620
+
615
621
  if (options.replaceDiacritics) {
616
622
  matchText = replaceDiacritics(matchText);
617
623
  }