fix: apply PR review feedback

This commit is contained in:
Mohamed Marrouchi 2025-05-13 19:05:50 +01:00
parent e85084cd41
commit 82d6bc8d49
2 changed files with 8 additions and 9 deletions

View File

@ -313,20 +313,20 @@ export class BlockService extends BaseService<
// Filter NLP patterns match based on best guessed entities
return nlpPatterns.filter((patterns: NlpPattern[]) => {
return patterns.every((ev: NlpPattern) => {
if (ev.match === 'value') {
return patterns.every((p: NlpPattern) => {
if (p.match === 'value') {
return entities.find((e) => {
return (
e.entity === ev.entity &&
(e.value === ev.value || e.canonicalValue === ev.value)
e.entity === p.entity &&
(e.value === p.value || e.canonicalValue === p.value)
);
});
} else if (ev.match === 'entity') {
} else if (p.match === 'entity') {
return entities.find((e) => {
return e.entity === ev.entity;
return e.entity === p.entity;
});
} else {
this.logger.warn('Unknown NLP match type', ev);
this.logger.warn('Unknown NLP match type', p);
return false;
}
});

View File

@ -321,7 +321,7 @@ export default abstract class BaseNlpHelper<
}
if (nlpValue.metadata?.stripDiacritics) {
value = value.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
value = value.normalize('NFD').replace(/\p{Diacritic}/gu, '');
}
return {
@ -349,7 +349,6 @@ export default abstract class BaseNlpHelper<
*
* @param text - The input text from which to extract slot values.
* @param entities - An array of NlpEntityFull objects, each containing slot values and metadata.
* @param lookup - The lookup strategy to use: either `keywords` or `pattern`.
*
* @returns An array of `ParseEntity` objects containing the entity name, matched value, position, and confidence.
*/