wingbot 3.27.0-alpha.4 → 3.27.2
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
package/src/BotApp.js
CHANGED
|
@@ -58,6 +58,14 @@ const { replaceDiacritics } = require('../utils');
|
|
|
58
58
|
|
|
59
59
|
/** @typedef {import('../Request')} Request */
|
|
60
60
|
|
|
61
|
+
function optionalWrap (l, r, content) {
|
|
62
|
+
const consistent = !l === !r;
|
|
63
|
+
if (consistent) {
|
|
64
|
+
return `(${content})`;
|
|
65
|
+
}
|
|
66
|
+
return `${l || ''}(${content})${r || ''}`;
|
|
67
|
+
}
|
|
68
|
+
|
|
61
69
|
class CustomEntityDetectionModel {
|
|
62
70
|
|
|
63
71
|
/**
|
|
@@ -165,8 +173,9 @@ class CustomEntityDetectionModel {
|
|
|
165
173
|
]);
|
|
166
174
|
|
|
167
175
|
const cleanSubWordResults = subWordResults
|
|
168
|
-
.filter((regular) => regularResults
|
|
169
|
-
.some((e) => e.start < regular.end && e.end > regular.start
|
|
176
|
+
.filter((regular) => !regularResults
|
|
177
|
+
.some((e) => e.start < regular.end && e.end > regular.start
|
|
178
|
+
&& e.end >= regular.end && e.start <= regular.start));
|
|
170
179
|
|
|
171
180
|
subWord.push(...cleanSubWordResults);
|
|
172
181
|
|
|
@@ -507,16 +516,16 @@ class CustomEntityDetectionModel {
|
|
|
507
516
|
return null;
|
|
508
517
|
}
|
|
509
518
|
|
|
510
|
-
let replaced = source.replace(
|
|
519
|
+
let replaced = source.replace(/(\()?@([A-Z0-9-]+)(\))?/g, (value, l, ent, r) => {
|
|
511
520
|
const matchingEntities = entities
|
|
512
|
-
.filter((e) =>
|
|
521
|
+
.filter((e) => e.entity.toUpperCase() === ent)
|
|
513
522
|
.map((e) => this._escapeRegex(e.text, options.replaceDiacritics));
|
|
514
523
|
|
|
515
524
|
if (matchingEntities.length === 0) {
|
|
516
|
-
return
|
|
525
|
+
return optionalWrap(l, r, `@${ent}`);
|
|
517
526
|
}
|
|
518
527
|
matchingEntities.sort((a, z) => z.length - a.length);
|
|
519
|
-
return
|
|
528
|
+
return optionalWrap(l, r, matchingEntities.join('|'));
|
|
520
529
|
});
|
|
521
530
|
|
|
522
531
|
if (options.matchWholeWords && !searchWithinWords) {
|