wingbot 3.53.2 → 3.53.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.53.2",
3
+ "version": "3.53.4",
4
4
  "description": "Enterprise Messaging Bot Conversation Engine",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/AiMatching.js CHANGED
@@ -504,22 +504,31 @@ class AiMatching {
504
504
  ? (tot + (entity.end - entity.start))
505
505
  : null
506
506
  ), 0);
507
+ const textLength = req.text().trim().length;
507
508
 
508
- let finalScore = (baseScore - handicap)
509
- * (this.multiMatchGain ** countOfAdditionalItems);
509
+ const useHandicap = textLength <= matchedEntitiesTextLength
510
+ ? Math.max(-this.redundantEntityHandicap, baseScore - 1)
511
+ : handicap;
510
512
 
511
- const textLength = req.text().length;
513
+ let finalScore = (baseScore - useHandicap)
514
+ * (this.multiMatchGain ** countOfAdditionalItems);
512
515
 
513
516
  if (matchedEntitiesTextLength && textLength) {
514
517
  const remainingScore = Math.max(0, Math.min(1, finalScore) - (
515
518
  this._ai.confidence + this.redundantEntityHandicap
516
519
  ));
517
520
 
518
- finalScore -= (matchedEntitiesTextLength / textLength) * remainingScore;
521
+ const remainingTextLen = (textLength - matchedEntitiesTextLength);
522
+ const minus = (remainingTextLen / textLength) * remainingScore;
523
+
524
+ // eslint-disable-next-line max-len,object-curly-newline
525
+ // console.log({ minus, matchedEntitiesTextLength, textLength, remainingScore })
526
+
527
+ finalScore -= minus;
519
528
  }
520
529
 
521
- // eslint-disable-next-line no-console,max-len,object-curly-newline
522
- // console.log({ finalScore, rule, baseScore, score, allOptional, entities, reqEntities, matchedEntitiesTextLength, countOfAdditionalItems });
530
+ // eslint-disable-next-line max-len,object-curly-newline
531
+ // console.log({ countOfAdditionalItems, multiMatch: this.multiMatchGain ** countOfAdditionalItems, handicap, useHandicap, finalScore, rule, baseScore, score, allOptional, entities, reqEntities, matchedEntitiesTextLength });
523
532
 
524
533
  if (finalScore <= 0) {
525
534
  return null;
@@ -603,7 +612,7 @@ class AiMatching {
603
612
  : (x) => x
604
613
  );
605
614
 
606
- // eslint-disable-next-line no-console,max-len,object-curly-newline
615
+ // eslint-disable-next-line max-len,object-curly-newline
607
616
  // console.log({ wantedEntities, entitiesScore, handicap, matched, minScore, requestIntent });
608
617
 
609
618
  const allOptional = wantedEntities.every((e) => e.optional
@@ -618,7 +627,7 @@ class AiMatching {
618
627
 
619
628
  const score = Math.round((scoreWithHandicap * multiMatchGain) * 10000) / 10000;
620
629
 
621
- // eslint-disable-next-line no-console,max-len,object-curly-newline
630
+ // eslint-disable-next-line max-len,object-curly-newline
622
631
  // console.log({ IMS: score, normalizedScore, scoreWithHandicap, multiMatchGain, wantedEntities });
623
632
 
624
633
  return {
@@ -738,7 +747,7 @@ class AiMatching {
738
747
  }
739
748
  }
740
749
 
741
- // eslint-disable-next-line no-console,max-len
750
+ // eslint-disable-next-line max-len
742
751
  // console.log({ wantedEntities, sum, handicap, rl: requestEntities.length, ml: matched.length });
743
752
 
744
753
  // @todo - neni mozne, by doslo k negativnimu handicapu
package/src/Router.js CHANGED
@@ -14,9 +14,7 @@ function defaultPathContext () {
14
14
  return { globalIntentsMeta: {}, path: '/*' };
15
15
  }
16
16
 
17
- /**
18
- * @typedef {true|false|null|undefined|-1|void} RoutingInstruction
19
- */
17
+ /** @typedef {true|false|null|undefined|number|void} RoutingInstruction */
20
18
 
21
19
  /**
22
20
  * @callback PostBackDataCallback