feat: Update search.go to include debug logging for relevance scores

This commit is contained in:
Alex Wellnitz 2025-03-25 21:34:44 +01:00
parent 9b786a866a
commit 69b050fbd6

View File

@ -1,10 +1,12 @@
package search
import (
"fmt"
"math"
"sort"
"git.dev-null.rocks/alexohneander/gosearch/pkg/index"
"github.com/gofiber/fiber/v2/log"
)
// SearchResult stores the document and its relevance score.
@ -48,8 +50,8 @@ func scoreDoc(terms []string, doc string, index index.InvertedIndex, docFreq ind
tf := float64(index[term][doc])
idf := math.Log(float64(numDocs) / float64(docFreq[term]))
score += tf * idf
//fmt.Printf("Score: %f64 %f64 %f64\n", tf, idf, score)
}
log.Debug(fmt.Sprintf("Score: %f64", score))
return score
}