Fix: linter complaints
This commit is contained in:
@@ -47,7 +47,6 @@ func isStopWord(word string) bool {
|
|||||||
func detectPhrases(query string) []string {
|
func detectPhrases(query string) []string {
|
||||||
words := strings.Fields(strings.ToLower(query))
|
words := strings.Fields(strings.ToLower(query))
|
||||||
var phrases []string
|
var phrases []string
|
||||||
|
|
||||||
for i := 0; i < len(words)-1; i++ {
|
for i := 0; i < len(words)-1; i++ {
|
||||||
word1 := strings.Trim(words[i], ".,!?;:'\"()[]{}")
|
word1 := strings.Trim(words[i], ".,!?;:'\"()[]{}")
|
||||||
word2 := strings.Trim(words[i+1], ".,!?;:'\"()[]{}")
|
word2 := strings.Trim(words[i+1], ".,!?;:'\"()[]{}")
|
||||||
@@ -70,7 +69,6 @@ func detectPhrases(query string) []string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return phrases
|
return phrases
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,7 +120,6 @@ func areSlugsAdjacent(slug1, slug2 string) bool {
|
|||||||
if prefix1 != prefix2 {
|
if prefix1 != prefix2 {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
batch1, chunk1, ok1 := parseSlugIndices(slug1)
|
batch1, chunk1, ok1 := parseSlugIndices(slug1)
|
||||||
batch2, chunk2, ok2 := parseSlugIndices(slug2)
|
batch2, chunk2, ok2 := parseSlugIndices(slug2)
|
||||||
if !ok1 || !ok2 {
|
if !ok1 || !ok2 {
|
||||||
@@ -843,7 +840,6 @@ func (r *RAG) GenerateQueryVariations(query string) []string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return variations
|
return variations
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -297,7 +297,6 @@ relative term as it was still a few kilometers away.
|
|||||||
|
|
||||||
The clan house was made of brick and conformed to an older style of architecture. Nearly everyone knew about this mansion and its clock tower. It stood tall over the neighboring mansions and rumor had it that you could see the whole capital from the top. It
|
The clan house was made of brick and conformed to an older style of architecture. Nearly everyone knew about this mansion and its clock tower. It stood tall over the neighboring mansions and rumor had it that you could see the whole capital from the top. It
|
||||||
spoke to this clan’s renown and history that they were able to get away with building something that dwarfed the mansions of the nobility.`
|
spoke to this clan’s renown and history that they were able to get away with building something that dwarfed the mansions of the nobility.`
|
||||||
|
|
||||||
chunks := []*models.VectorRow{
|
chunks := []*models.VectorRow{
|
||||||
{
|
{
|
||||||
Slug: "kjv_bible.epub_1786_0",
|
Slug: "kjv_bible.epub_1786_0",
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ func TestRealBiblicalQuery(t *testing.T) {
|
|||||||
t.Fatalf("failed to create RAG instance: %v", err)
|
t.Fatalf("failed to create RAG instance: %v", err)
|
||||||
}
|
}
|
||||||
t.Cleanup(func() { rag.Destroy() })
|
t.Cleanup(func() { rag.Destroy() })
|
||||||
|
|
||||||
query := "bald prophet and two she bears"
|
query := "bald prophet and two she bears"
|
||||||
results, err := rag.Search(query, 30)
|
results, err := rag.Search(query, 30)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -95,7 +94,6 @@ func TestRealQueryVariations(t *testing.T) {
|
|||||||
t.Fatalf("failed to create RAG instance: %v", err)
|
t.Fatalf("failed to create RAG instance: %v", err)
|
||||||
}
|
}
|
||||||
t.Cleanup(func() { rag.Destroy() })
|
t.Cleanup(func() { rag.Destroy() })
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
query string
|
query string
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ func TestDetectPhrases(t *testing.T) {
|
|||||||
expect: []string{},
|
expect: []string{},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
got := detectPhrases(tt.query)
|
got := detectPhrases(tt.query)
|
||||||
if len(got) != len(tt.expect) {
|
if len(got) != len(tt.expect) {
|
||||||
@@ -73,7 +72,6 @@ func TestCountPhraseMatches(t *testing.T) {
|
|||||||
expect: 2, // "she bears" and "bald prophet"
|
expect: 2, // "she bears" and "bald prophet"
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
got := countPhraseMatches(tt.text, tt.query)
|
got := countPhraseMatches(tt.text, tt.query)
|
||||||
if got != tt.expect {
|
if got != tt.expect {
|
||||||
@@ -119,7 +117,6 @@ func TestAreSlugsAdjacent(t *testing.T) {
|
|||||||
expect: true, // sequential batches with same chunk index are adjacent
|
expect: true, // sequential batches with same chunk index are adjacent
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
got := areSlugsAdjacent(tt.slug1, tt.slug2)
|
got := areSlugsAdjacent(tt.slug1, tt.slug2)
|
||||||
if got != tt.expect {
|
if got != tt.expect {
|
||||||
@@ -141,7 +138,6 @@ func TestParseSlugIndices(t *testing.T) {
|
|||||||
{"file_abc_def", 0, 0, false},
|
{"file_abc_def", 0, 0, false},
|
||||||
{"file_123_456_extra", 456, 0, false}, // regex matches last two numbers
|
{"file_123_456_extra", 456, 0, false}, // regex matches last two numbers
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
batch, chunk, ok := parseSlugIndices(tt.slug)
|
batch, chunk, ok := parseSlugIndices(tt.slug)
|
||||||
if ok != tt.wantOk {
|
if ok != tt.wantOk {
|
||||||
|
|||||||
@@ -162,7 +162,6 @@ func (p ProviderSQL) ListFiles() ([]string, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer rows.Close()
|
defer rows.Close()
|
||||||
|
|
||||||
var allFiles []string
|
var allFiles []string
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var filename string
|
var filename string
|
||||||
|
|||||||
Reference in New Issue
Block a user