Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

score: clean up debug output #663

Merged
merged 1 commit into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions contentprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ func (p *contentProvider) chunkMatchScore(secs []DocumentSection, m *ChunkMatch,
maxScore := &debugScore{}

addScore := func(what string, s float64) {
if debug {
if s != 0 && debug {
score.what += fmt.Sprintf("%s:%.2f, ", what, s)
}
score.score += s
Expand Down Expand Up @@ -568,7 +568,7 @@ func (p *contentProvider) chunkMatchScore(secs []DocumentSection, m *ChunkMatch,
}

if debug {
maxScore.what = fmt.Sprintf("score:%f <- %s", maxScore.score, strings.TrimRight(maxScore.what, ", "))
maxScore.what = fmt.Sprintf("score:%.2f <- %s", maxScore.score, strings.TrimSuffix(maxScore.what, ", "))
}

return maxScore.score, maxScore.what
Expand All @@ -584,7 +584,7 @@ func (p *contentProvider) matchScore(secs []DocumentSection, m *LineMatch, langu
maxScore := &debugScore{}

addScore := func(what string, s float64) {
if debug {
if s != 0 && debug {
score.what += fmt.Sprintf("%s:%.2f, ", what, s)
}
score.score += s
Expand Down
6 changes: 5 additions & 1 deletion eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
const maxUInt16 = 0xffff

func (m *FileMatch) addScore(what string, s float64, debugScore bool) {
if debugScore {
if s != 0 && debugScore {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about this. s==0 means that we actually found a symbol kind but didn't give it a score, no? This seems useful to show because it points to gap in our scoring. How else would we figure out such a gap just by looking at the debug output?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my other or making us default to a factor of 1 for unknown symbols

m.Debug += fmt.Sprintf("%s:%.2f, ", what, s)
}
m.Score += s
Expand Down Expand Up @@ -466,6 +466,10 @@ func (d *indexData) scoreFile(fileMatch *FileMatch, doc uint32, mt matchTree, kn
md := d.repoMetaData[d.repos[doc]]
fileMatch.addScore("doc-order", scoreFileOrderFactor*(1.0-float64(doc)/float64(len(d.boundaries))), opts.DebugScore)
fileMatch.addScore("repo-rank", scoreRepoRankFactor*float64(md.Rank)/maxUInt16, opts.DebugScore)

if opts.DebugScore {
fileMatch.Debug = strings.TrimSuffix(fileMatch.Debug, ", ")
}
}

// scoreFileUsingBM25 computes a score for the file match using an approximation to BM25, the most common scoring
Expand Down
Loading