mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
fix: remove async from block score calculation
This commit is contained in:
parent
5ead99c41d
commit
aeee39249c
@ -434,13 +434,13 @@ describe('BlockService', () => {
|
||||
describe('calculateBlockScore', () => {
|
||||
const nlpPenaltyFactor = 0.9;
|
||||
it('should calculate the correct NLP score for a block', async () => {
|
||||
const score = await blockService.calculateBlockScore(
|
||||
const score = blockService.calculateBlockScore(
|
||||
mockNlpPatternsSetOne,
|
||||
mockNlpEntitiesSetOne,
|
||||
mockNlpCacheMap,
|
||||
nlpPenaltyFactor,
|
||||
);
|
||||
const score2 = await blockService.calculateBlockScore(
|
||||
const score2 = blockService.calculateBlockScore(
|
||||
mockNlpPatternsSetTwo,
|
||||
mockNlpEntitiesSetOne,
|
||||
mockNlpCacheMap,
|
||||
@ -453,13 +453,13 @@ describe('BlockService', () => {
|
||||
});
|
||||
|
||||
it('should calculate the correct NLP score for a block and apply penalties ', async () => {
|
||||
const score = await blockService.calculateBlockScore(
|
||||
const score = blockService.calculateBlockScore(
|
||||
mockNlpPatternsSetOne,
|
||||
mockNlpEntitiesSetOne,
|
||||
mockNlpCacheMap,
|
||||
nlpPenaltyFactor,
|
||||
);
|
||||
const score2 = await blockService.calculateBlockScore(
|
||||
const score2 = blockService.calculateBlockScore(
|
||||
mockNlpPatternsSetThree,
|
||||
mockNlpEntitiesSetOne,
|
||||
mockNlpCacheMap,
|
||||
@ -473,7 +473,7 @@ describe('BlockService', () => {
|
||||
|
||||
it('should return 0 if no matching entities are found', async () => {
|
||||
const nlpCacheMap: NlpCacheMap = new Map();
|
||||
const score = await blockService.calculateBlockScore(
|
||||
const score = blockService.calculateBlockScore(
|
||||
mockNlpPatternsSetTwo,
|
||||
mockNlpEntitiesSetOne,
|
||||
nlpCacheMap,
|
||||
|
@ -412,7 +412,7 @@ export class BlockService extends BaseService<
|
||||
const block = blocks[i];
|
||||
const patterns = matchedPatterns[i];
|
||||
// If compatible, calculate the NLP score for this block
|
||||
const nlpScore: number = await this.calculateBlockScore(
|
||||
const nlpScore: number = this.calculateBlockScore(
|
||||
patterns,
|
||||
nlp,
|
||||
nlpCacheMap,
|
||||
@ -445,12 +445,12 @@ export class BlockService extends BaseService<
|
||||
* @param nlpPenaltyFactor - A multiplier applied to scores when the pattern match type is 'entity'.
|
||||
* @returns A numeric score representing how well the block matches the given NLP context.
|
||||
*/
|
||||
async calculateBlockScore(
|
||||
calculateBlockScore(
|
||||
patterns: NlpPattern[],
|
||||
nlp: NLU.ParseEntities,
|
||||
nlpCacheMap: NlpCacheMap,
|
||||
nlpPenaltyFactor: number,
|
||||
): Promise<number> {
|
||||
): number {
|
||||
// Compute individual pattern scores using the cache
|
||||
const patternScores: number[] = patterns.map((pattern) => {
|
||||
const entityData = nlpCacheMap.get(pattern.entity);
|
||||
|
Loading…
Reference in New Issue
Block a user