Skip to content

Commit

Permalink
Updating tests.
Browse files Browse the repository at this point in the history
Signed-off-by: jzonthemtn <[email protected]>
  • Loading branch information
jzonthemtn committed Dec 12, 2024
1 parent b9bf8ca commit c7691e7
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class DcgSearchMetricTest extends OpenSearchTestCase {

public void testCalculate() {

final int k = 5;
final int k = 10;
final List<Double> relevanceScores = List.of(1.0, 2.0, 3.0, 1.0, 2.0, 3.0, 1.0, 2.0, 3.0, 0.0);

final DcgSearchMetric dcgSearchMetric = new DcgSearchMetric(k, relevanceScores);
Expand All @@ -26,4 +26,16 @@ public void testCalculate() {

}

public void testCalculateAllZeros() {

final int k = 10;
final List<Double> relevanceScores = List.of(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);

final DcgSearchMetric dcgSearchMetric = new DcgSearchMetric(k, relevanceScores);
final double dcg = dcgSearchMetric.calculate();

assertEquals(0.0, dcg, 0.0);

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class NdcgSearchMetricTest extends OpenSearchTestCase {

public void testCalculate() {

final int k = 5;
final int k = 10;
final List<Double> relevanceScores = List.of(1.0, 2.0, 3.0, 1.0, 2.0, 3.0, 1.0, 2.0, 3.0, 0.0);

final NdcgSearchMetric ndcgSearchMetric = new NdcgSearchMetric(k, relevanceScores);
Expand All @@ -26,4 +26,16 @@ public void testCalculate() {

}

public void testCalculateAllZeros() {

final int k = 10;
final List<Double> relevanceScores = List.of(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);

final NdcgSearchMetric ndcgSearchMetric = new NdcgSearchMetric(k, relevanceScores);
final double ndcg = ndcgSearchMetric.calculate();

assertEquals(0.0, ndcg, 0.0);

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ public class PrecisionSearchMetricTest extends OpenSearchTestCase {

public void testCalculate() {

final int k = 5;
final int k = 10;
final double threshold = 1.0;
final List<Double> relevanceScores = List.of(1.0, 2.0, 3.0, 1.0, 2.0, 3.0, 1.0, 2.0, 3.0, 0.0);

final PrecisionSearchMetric precisionSearchMetric = new PrecisionSearchMetric(k, threshold, relevanceScores);
final double precision = precisionSearchMetric.calculate();

assertEquals(1.8, precision, 0.0);
assertEquals(0.9, precision, 0.0);

}

Expand Down

0 comments on commit c7691e7

Please sign in to comment.