wingbot 3.27.0-alpha.1 → 3.27.0-alpha.5
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
|
@@ -165,8 +165,9 @@ class CustomEntityDetectionModel {
|
|
|
165
165
|
]);
|
|
166
166
|
|
|
167
167
|
const cleanSubWordResults = subWordResults
|
|
168
|
-
.filter((regular) => regularResults
|
|
169
|
-
.some((e) => e.start < regular.end && e.end > regular.start
|
|
168
|
+
.filter((regular) => !regularResults
|
|
169
|
+
.some((e) => e.start < regular.end && e.end > regular.start
|
|
170
|
+
&& e.end >= regular.end && e.start <= regular.start));
|
|
170
171
|
|
|
171
172
|
subWord.push(...cleanSubWordResults);
|
|
172
173
|
|
|
@@ -352,18 +353,27 @@ class CustomEntityDetectionModel {
|
|
|
352
353
|
* @param {string} text
|
|
353
354
|
* @param {string} [singleEntity]
|
|
354
355
|
* @param {string[]} [expected]
|
|
355
|
-
* @param {DetectedEntity[]} [
|
|
356
|
+
* @param {DetectedEntity[]} [prevEnts] - previously detected entities to include
|
|
356
357
|
* @param {DetectedEntity[]} [subWord] - previously detected entities within words
|
|
357
358
|
* @returns {Promise<DetectedEntity[]>}
|
|
358
359
|
*/
|
|
359
|
-
async resolveEntities (text, singleEntity = null, expected = [],
|
|
360
|
+
async resolveEntities (text, singleEntity = null, expected = [], prevEnts = [], subWord = []) {
|
|
360
361
|
// mark unknown dependencies as resolved
|
|
361
362
|
const resolved = new Set(
|
|
362
363
|
this.getDependentEntities(false)
|
|
363
|
-
.map((entity) =>
|
|
364
|
+
.map((entity) => `@${entity.toUpperCase()}`)
|
|
364
365
|
);
|
|
365
366
|
|
|
366
367
|
let missing = Array.from(this._entityDetectors.keys());
|
|
368
|
+
const entities = prevEnts.map((e) => {
|
|
369
|
+
if (typeof e.text === 'string') {
|
|
370
|
+
return e;
|
|
371
|
+
}
|
|
372
|
+
return {
|
|
373
|
+
...e,
|
|
374
|
+
text: text.substring(e.start, e.end)
|
|
375
|
+
};
|
|
376
|
+
});
|
|
367
377
|
|
|
368
378
|
while (missing.length !== 0) {
|
|
369
379
|
let detect = [];
|
|
@@ -539,19 +549,15 @@ class CustomEntityDetectionModel {
|
|
|
539
549
|
|
|
540
550
|
if (typeof extractValue === 'function') {
|
|
541
551
|
value = extractValue(match, useEntities);
|
|
542
|
-
} else if (typeof extractValue === 'string' || dependencies.length
|
|
552
|
+
} else if (typeof extractValue === 'string' || dependencies.length > 0) {
|
|
543
553
|
const entityName = typeof extractValue === 'string'
|
|
544
554
|
? extractValue
|
|
545
555
|
: dependencies[0];
|
|
546
556
|
|
|
547
557
|
const entity = this._entityByDependency(useEntities, entityName);
|
|
548
558
|
value = entity ? entity.value : null;
|
|
549
|
-
} else if (entities.length === 0) {
|
|
550
|
-
[value] = match;
|
|
551
559
|
} else {
|
|
552
|
-
value =
|
|
553
|
-
[e.entity]: e.value
|
|
554
|
-
}), {});
|
|
560
|
+
[value] = match;
|
|
555
561
|
}
|
|
556
562
|
|
|
557
563
|
return {
|