mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
fix: apply PR review feedback
This commit is contained in:
parent
e85084cd41
commit
82d6bc8d49
@ -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;
|
||||
}
|
||||
});
|
||||
|
@ -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.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user