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

fix: don't modify candidates #773

Merged
merged 1 commit into from
May 1, 2024
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
4 changes: 2 additions & 2 deletions build/scoring_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ func TestBM25(t *testing.T) {
query: &query.Substring{Pattern: "example"},
content: exampleJava,
language: "Java",
// keyword-score:1.63 (sum-tf: 6.00, length-ratio: 2.00)
wantScore: 1.63,
// keyword-score:1.69 (sum-tf: 7.00, length-ratio: 2.00)
wantScore: 1.69,
Copy link
Member

Choose a reason for hiding this comment

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

Wondering why I didn't catch this 🤦

Copy link
Member Author

Choose a reason for hiding this comment

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

Should we add more info to the debug message? We could print the term frequency map instead of sum-tf. This wouldn't have helped for this test case, because we are just searching for one term, but for a more complex query it might be easier to debug.

}, {
// Matches only on content
fileName: "example.java",
Expand Down
4 changes: 2 additions & 2 deletions contentprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func (p *contentProvider) findOffset(filename bool, r uint32) uint32 {
// returned by the API it needs to be copied.
func (p *contentProvider) fillMatches(ms []*candidateMatch, numContextLines int, language string, debug bool) []LineMatch {
var filenameMatches []*candidateMatch
contentMatches := ms[:0]
contentMatches := make([]*candidateMatch, 0, len(ms))

for _, m := range ms {
if m.fileName {
Expand Down Expand Up @@ -194,7 +194,7 @@ func (p *contentProvider) fillMatches(ms []*candidateMatch, numContextLines int,
// returned by the API it needs to be copied.
func (p *contentProvider) fillChunkMatches(ms []*candidateMatch, numContextLines int, language string, debug bool) []ChunkMatch {
var filenameMatches []*candidateMatch
contentMatches := ms[:0]
contentMatches := make([]*candidateMatch, 0, len(ms))

for _, m := range ms {
if m.fileName {
Expand Down
Loading