From eb0416faddce25fc72af76e8f770ed7a0258ae0e Mon Sep 17 00:00:00 2001 From: Ben Boyter Date: Thu, 11 Jun 2020 12:29:09 +1000 Subject: [PATCH] test to confirm tfidf work differently --- processor/result_ranker_test.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/processor/result_ranker_test.go b/processor/result_ranker_test.go index fe96edf..531dd83 100644 --- a/processor/result_ranker_test.go +++ b/processor/result_ranker_test.go @@ -39,6 +39,29 @@ func TestRankResultsTFIDFTraditional(t *testing.T) { } } +func TestRankResultsTFIDFComparison(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 + + if score1 == score2 { + t.Error("expected scores to be slightly different") + } +} + func TestRankResultsLocation(t *testing.T) { ml := map[string][][]int{} ml["test"] = [][]int{{1}, {2}, {3}}