Skip to content
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
14 changes: 4 additions & 10 deletions dict_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ func (seg *Segmenter) LoadDictMap(dict []map[string]string) error {
// When a participle appears both in the user dictionary and
// in the `common dictionary`, the `user dictionary` is given priority.
func (seg *Segmenter) LoadDict(files ...string) error {
if !seg.Load {
if seg.Dict == nil {
seg.Dict = NewDict()
seg.Load = true
// seg.Load = true
seg.Init()
}
Comment on lines +154 to 158

Copilot AI Mar 2, 2026

Copy link

Choose a reason for hiding this comment

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

Segmenter still exposes the Load bool field (see segmenter.go), but LoadDict no longer uses it to decide whether to (re)initialize. This silently changes behavior for any callers that relied on seg.Load = false to force a fresh dictionary/init (and it leaves Load effectively unused). Either remove/deprecate the Load field and update callers/tests accordingly, or keep backward-compatible behavior by honoring !seg.Load here (and keeping Load in sync when initializing/emptying).

Copilot uses AI. Check for mistakes.

Expand Down Expand Up @@ -221,9 +221,9 @@ func (seg *Segmenter) LoadDict(files ...string) error {

// LoadTFIDFDict load tfidf dict for cal tfidf & bm25
func (seg *Segmenter) LoadTFIDFDict(files []*types.LoadDictFile) error {
if !seg.Load {
if seg.Dict == nil {
seg.Dict = NewDict()
seg.Load = true
// seg.Load = true
seg.Init()
}
Comment on lines +224 to 228

Copilot AI Mar 2, 2026

Copy link

Choose a reason for hiding this comment

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

The commented-out // seg.Load = true suggests Load state is still expected to exist, but LoadTFIDFDict no longer updates or checks it. Please either remove this dead/commented code and the Load field entirely, or restore consistent state management (honor !seg.Load and set it true after init) to avoid confusing/partially-removed API behavior.

Copilot uses AI. Check for mistakes.

Expand Down Expand Up @@ -256,7 +256,6 @@ func (seg *Segmenter) LoadTFIDFDict(files []*types.LoadDictFile) error {
if !seg.SkipLog {
log.Println("Gse dictionary loaded finished.")
}

return nil
}

Expand All @@ -278,7 +277,6 @@ func (seg *Segmenter) GetIdfPath(files ...string) []string {
)

files = append(files, dictPath)

return files
}

Expand All @@ -297,7 +295,6 @@ func (seg *Segmenter) LoadCorpusAverLen(files ...string) (corpusTotal float64, e
}

corpusTotal = corpusTotal / float64(len(filePaths))

return
}

Expand All @@ -309,7 +306,6 @@ func (seg *Segmenter) GetCorpusPath(files ...string) []string {
)

files = append(files, dictPath)

return files
}

Expand All @@ -335,7 +331,6 @@ func (seg *Segmenter) ReadCorpus(file string) (corpusAverLen float64, err error)
corpusLength += float64(utf8.RuneCountInString(line))
}
corpusAverLen = corpusLength / corpusNumber

return
}

Expand All @@ -347,7 +342,6 @@ func (seg *Segmenter) GetTfIdfPath(files ...string) []string {
)

files = append(files, dictPath)

return files
}

Expand Down
14 changes: 0 additions & 14 deletions dict_util_test.go

This file was deleted.

2 changes: 1 addition & 1 deletion gse.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (

const (
// Version get the gse version
Version = "v0.80.2.705, Green Lake!"
Version = "v1.0.1.705, Green Lake!"

// minTokenFrequency = 2 // only read tokens with frequency >= 2 from the dictionary
)
Expand Down
Loading