From f96f37ab3684177e5147aad646e3239897dc4f3b Mon Sep 17 00:00:00 2001 From: Ben Boyter Date: Thu, 11 Jun 2020 12:31:31 +1000 Subject: [PATCH] confirm rankers produce different scores --- processor/result_ranker_test.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/processor/result_ranker_test.go b/processor/result_ranker_test.go index 531dd83..ddfb4dd 100644 --- a/processor/result_ranker_test.go +++ b/processor/result_ranker_test.go @@ -62,6 +62,32 @@ func TestRankResultsTFIDFComparison(t *testing.T) { } } +func TestRankResultsRankerComparison(t *testing.T) { + ml1 := map[string][][]int{} + ml1["example"] = [][]int{{1}, {2}, {3}} + + s := []*fileJob{ + { + MatchLocations: ml1, + Location: "/test/other.go", + Bytes: 12, + }, + } + + s = rankResultsTFIDF(2, s, calculateDocumentFrequency(s), true) + score1 := s[0].Score + + s = rankResultsTFIDF(2, s, calculateDocumentFrequency(s), false) + score2 := s[0].Score + + s = rankResultsBM25(2, s, calculateDocumentFrequency(s)) + score3 := s[0].Score + + if score1 == score2 || score1 == score3 || score2 == score3 { + t.Error("expected scores to be slightly different") + } +} + func TestRankResultsLocation(t *testing.T) { ml := map[string][][]int{} ml["test"] = [][]int{{1}, {2}, {3}}