fix: minor fixes

This commit is contained in:
Mohamed Marrouchi 2025-05-13 15:20:50 +01:00
parent 6e89192f88
commit 949fee281a
3 changed files with 33 additions and 2 deletions

View File

@ -326,6 +326,37 @@ describe('BaseNlpHelper', () => {
]);
});
it('should respect metadata stripDiacritics', () => {
const entity: NlpEntityFull = {
name: 'keyword',
values: [
{
value: 'word',
metadata: {
pattern: '".+"',
toLowerCase: true,
removeSpaces: true,
stripDiacritics: true,
},
},
],
} as NlpEntityFull;
const result = helper.extractPatternBasedSlots(
'The word "où" (where)',
entity,
);
expect(result).toEqual([
{
entity: 'keyword',
value: '"ou"',
start: 9,
end: 13,
confidence: 1,
},
]);
});
it('should return empty array if no values', () => {
const result = helper.extractPatternBasedSlots('test', {
name: 'noop',

View File

@ -321,7 +321,7 @@ export default abstract class BaseNlpHelper<
}
if (patternValue.metadata?.stripDiacritics) {
value = text.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
value = value.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
}
return {

View File

@ -35,7 +35,7 @@ const getDefaultNlpMetadata = (
): INlpMetadata => {
if (nlpEntity?.lookups.includes(LookupStrategy.pattern)) {
return {
pattern: "//",
pattern: "",
wordBoundary: true,
removeSpaces: false,
toLowerCase: false,