Skip to content

Commit

Permalink
fix IT test
Browse files Browse the repository at this point in the history
Signed-off-by: Samuel Herman <[email protected]>
  • Loading branch information
sam-herman committed Oct 19, 2023
1 parent 10b5646 commit 266a34b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public float combine(final float[] scores) {
float sumOfWeights = 0;
for (int indexOfSubQuery = 0; indexOfSubQuery < scores.length; indexOfSubQuery++) {
float score = scores[indexOfSubQuery];
if (score != 0.0) {
if (score >= 0.0) {
float weight = scoreCombinationUtil.getWeightForSubQuery(weights, indexOfSubQuery);
score = score * weight;
combinedScore += score;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,10 @@ public void testComplexQuery_withZScoreNormalization() {
}

assertEquals(2, scores.size());
// since it's z-score normalized we would expect 1 , -1 to be the corresponding score, by design when there are only two results with z score
// furthermore the combination logic with weights should make it doc1Score: (1 * w1 + 0.98 * w2)/(w1 + w2), -1 * w2/w2
// by design when there are only two results with z score since it's z-score normalized we would expect 1 , -1 to be the corresponding score,
// furthermore the combination logic with weights should make it doc1Score: (1 * w1 + 0.98 * w2)/(w1 + w2), doc2Score: -1 ~ 0
assertEquals(0.9999, scores.get(0).floatValue(), DELTA_FOR_SCORE_ASSERTION);
assertEquals(-1 , scores.get(1).floatValue(), DELTA_FOR_SCORE_ASSERTION);
assertEquals(0 , scores.get(1).floatValue(), DELTA_FOR_SCORE_ASSERTION);

// verify that scores are in desc order
assertTrue(IntStream.range(0, scores.size() - 1).noneMatch(idx -> scores.get(idx) < scores.get(idx + 1)));
Expand Down

0 comments on commit 266a34b

Please sign in to comment.