mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
fix: minor fixes
This commit is contained in:
parent
6e89192f88
commit
949fee281a
@ -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',
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -35,7 +35,7 @@ const getDefaultNlpMetadata = (
|
||||
): INlpMetadata => {
|
||||
if (nlpEntity?.lookups.includes(LookupStrategy.pattern)) {
|
||||
return {
|
||||
pattern: "//",
|
||||
pattern: "",
|
||||
wordBoundary: true,
|
||||
removeSpaces: false,
|
||||
toLowerCase: false,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user