Skip to content

Commit

Permalink
Match improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
umeshma committed Jan 31, 2025
1 parent 96e1cf9 commit 0e9f3c5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ts/packages/knowPro/src/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,22 +206,24 @@ export class TermsMatchExpr implements IQueryOpExpr<SemanticRefAccumulator> {
matchAccumulator: SemanticRefAccumulator,
queryTerm: QueryTerm,
): void {
matchAccumulator.addTermMatch(
const termMatches = new SemanticRefAccumulator(); // Future: pool these
termMatches.addTermMatch(
queryTerm.term,
index.lookupTerm(queryTerm.term.text),
);
if (queryTerm.relatedTerms && queryTerm.relatedTerms.length > 0) {
for (const relatedTerm of queryTerm.relatedTerms) {
// Related term matches count as matches for the queryTerm...
// BUT are scored with the score of the related term
matchAccumulator.addRelatedTermMatch(
termMatches.addRelatedTermMatch(
queryTerm.term,
relatedTerm,
index.lookupTerm(relatedTerm.text),
relatedTerm.score,
);
}
}
matchAccumulator.union(termMatches);
}
}

Expand Down

0 comments on commit 0e9f3c5

Please sign in to comment.