fix: enforce typing

This commit is contained in:
MohamedAliBouhaouala
2025-04-24 19:17:38 +01:00
parent e9e3184b49
commit 0ce7894628
2 changed files with 8 additions and 3 deletions

View File

@@ -363,7 +363,7 @@ describe('BlockService', () => {
});
describe('matchBestNLP', () => {
const nlpPenaltyFactor = 2;
const nlpPenaltyFactor = 0.95;
it('should return the block with the highest NLP score', async () => {
jest
.spyOn(nlpEntityService, 'getNlpMap')
@@ -417,7 +417,7 @@ describe('BlockService', () => {
// Restore the spy after the test
calculateBlockScoreSpy.mockRestore();
// Assert that the block with the highest NLP score is selected
expect(bestBlock).toEqual(mockModifiedNlpBlock);
expect(bestBlock).toEqual(mockNlpBlock);
});
it('should return undefined if no blocks match or the list is empty', async () => {

View File

@@ -215,7 +215,12 @@ export class BlockService extends BaseService<
);
// Retrieve Nlu Penalty Factor from global settings
const nluPenaltyFactor = await this.getDefaultNluPenaltyFactor();
const nluPenaltyFactor: number =
await this.getDefaultNluPenaltyFactor();
if (nluPenaltyFactor < 0 || nluPenaltyFactor > 1) {
throw new Error('Penalty Factor must be between 0 and 1.');
}
// Proceed with matching the best NLP block
if (matchesWithPatterns.length > 0) {