-
Notifications
You must be signed in to change notification settings - Fork 232
Update: update Dict init use nil not Load, rm unused test #202
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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() | ||
| } | ||
|
|
||
|
|
@@ -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
|
||
|
|
||
|
|
@@ -256,7 +256,6 @@ func (seg *Segmenter) LoadTFIDFDict(files []*types.LoadDictFile) error { | |
| if !seg.SkipLog { | ||
| log.Println("Gse dictionary loaded finished.") | ||
| } | ||
|
|
||
| return nil | ||
| } | ||
|
|
||
|
|
@@ -278,7 +277,6 @@ func (seg *Segmenter) GetIdfPath(files ...string) []string { | |
| ) | ||
|
|
||
| files = append(files, dictPath) | ||
|
|
||
| return files | ||
| } | ||
|
|
||
|
|
@@ -297,7 +295,6 @@ func (seg *Segmenter) LoadCorpusAverLen(files ...string) (corpusTotal float64, e | |
| } | ||
|
|
||
| corpusTotal = corpusTotal / float64(len(filePaths)) | ||
|
|
||
| return | ||
| } | ||
|
|
||
|
|
@@ -309,7 +306,6 @@ func (seg *Segmenter) GetCorpusPath(files ...string) []string { | |
| ) | ||
|
|
||
| files = append(files, dictPath) | ||
|
|
||
| return files | ||
| } | ||
|
|
||
|
|
@@ -335,7 +331,6 @@ func (seg *Segmenter) ReadCorpus(file string) (corpusAverLen float64, err error) | |
| corpusLength += float64(utf8.RuneCountInString(line)) | ||
| } | ||
| corpusAverLen = corpusLength / corpusNumber | ||
|
|
||
| return | ||
| } | ||
|
|
||
|
|
@@ -347,7 +342,6 @@ func (seg *Segmenter) GetTfIdfPath(files ...string) []string { | |
| ) | ||
|
|
||
| files = append(files, dictPath) | ||
|
|
||
| return files | ||
| } | ||
|
|
||
|
|
||
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Segmenterstill exposes theLoad boolfield (see segmenter.go), butLoadDictno longer uses it to decide whether to (re)initialize. This silently changes behavior for any callers that relied onseg.Load = falseto force a fresh dictionary/init (and it leavesLoadeffectively unused). Either remove/deprecate theLoadfield and update callers/tests accordingly, or keep backward-compatible behavior by honoring!seg.Loadhere (and keepingLoadin sync when initializing/emptying).