wingbot 3.46.4 → 3.47.1
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 +1 -1
- package/src/ConversationTester.js +52 -10
package/package.json
CHANGED
|
@@ -35,6 +35,7 @@ const DEFAULT_TEXT_THRESHOLD = 0.8;
|
|
|
35
35
|
* @prop {string} text
|
|
36
36
|
* @prop {string} action
|
|
37
37
|
* @prop {string} intent
|
|
38
|
+
* @prop {number} [rowNum]
|
|
38
39
|
*/
|
|
39
40
|
|
|
40
41
|
/**
|
|
@@ -562,10 +563,36 @@ class ConversationTester {
|
|
|
562
563
|
score: 0, intent: { intent: '-', score: 0 }, aboveConfidence: false, meta: null, action: null
|
|
563
564
|
}] = actions;
|
|
564
565
|
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
566
|
+
// textCase.rowNum?
|
|
567
|
+
|
|
568
|
+
const report = (error, ok = false) => {
|
|
569
|
+
let o = [
|
|
570
|
+
textCase.text.padEnd(longestText, ' '),
|
|
571
|
+
(winner.intent ? winner.intent.score : 0).toFixed(2),
|
|
572
|
+
winner.intent ? winner.intent.intent : '-'
|
|
573
|
+
].join('\t');
|
|
574
|
+
|
|
575
|
+
if (ok || !error) {
|
|
576
|
+
if (error) {
|
|
577
|
+
o += ` | ${error}`;
|
|
578
|
+
}
|
|
579
|
+
return { ok, o };
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
let err = error;
|
|
583
|
+
|
|
584
|
+
const prefix = typeof textCase.rowNum === 'number'
|
|
585
|
+
? ` > FAILED on row ${textCase.rowNum}: `.padEnd(23, ' ')
|
|
586
|
+
: ' > FAILED: ';
|
|
587
|
+
|
|
588
|
+
if (Array.isArray(err)) {
|
|
589
|
+
err = err.join('\n ');
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
o += `\n${prefix}${err}\n`;
|
|
593
|
+
|
|
594
|
+
return { ok, o };
|
|
595
|
+
};
|
|
569
596
|
|
|
570
597
|
if (actions.length === 0) {
|
|
571
598
|
return report('no NLP result');
|
|
@@ -576,25 +603,40 @@ class ConversationTester {
|
|
|
576
603
|
}
|
|
577
604
|
|
|
578
605
|
if (textCase.intent && winner.intent.intent !== textCase.intent) {
|
|
579
|
-
return report(
|
|
606
|
+
return report([
|
|
607
|
+
'intent mismatch',
|
|
608
|
+
`✓ expected: ${textCase.intent}`,
|
|
609
|
+
`✗ actual: ${winner.intent.intent || '-'}`
|
|
610
|
+
]);
|
|
580
611
|
}
|
|
581
612
|
|
|
582
613
|
if (textCase.appId) {
|
|
583
|
-
|
|
584
614
|
if (!winner.meta || `${winner.meta.targetAppId}` !== `${textCase.appId}`) {
|
|
585
|
-
return report(
|
|
615
|
+
return report([
|
|
616
|
+
'target appId mismatch',
|
|
617
|
+
`✓ expected: ${textCase.appId}`,
|
|
618
|
+
`✗ actual: ${(winner.meta && winner.meta.targetAppId) || `action[ ${winner.action || '*'} ]`}`
|
|
619
|
+
]);
|
|
586
620
|
}
|
|
587
621
|
|
|
588
622
|
if (textCase.action && !actionMatches(`${winner.meta.targetAction}`, `${textCase.action}`)) {
|
|
589
|
-
return report(
|
|
623
|
+
return report([
|
|
624
|
+
'target action mismatch',
|
|
625
|
+
`✓ expected: ${textCase.action}`,
|
|
626
|
+
`✗ actual: ${winner.meta.targetAction || '-'}`
|
|
627
|
+
]);
|
|
590
628
|
}
|
|
591
629
|
|
|
592
630
|
} else if (textCase.action && !actionMatches(`${winner.action}`, `${textCase.action}`)) {
|
|
593
|
-
return report(
|
|
631
|
+
return report([
|
|
632
|
+
'action mismatch',
|
|
633
|
+
`✓ expected: ${textCase.action}`,
|
|
634
|
+
`✗ actual: ${winner.action || '-'}`
|
|
635
|
+
]);
|
|
594
636
|
}
|
|
595
637
|
|
|
596
638
|
if (!textCase.action && !textCase.appId && !textCase.intent) {
|
|
597
|
-
return report(
|
|
639
|
+
return report(winner.action, true);
|
|
598
640
|
}
|
|
599
641
|
|
|
600
642
|
return { ok: true, o: null };
|