mirror of
https://github.com/fumiama/jieba.git
synced 2026-06-08 18:40:24 +08:00
removed unnecessary MarshalBinary/UnmarshalBinary method
This commit is contained in:
29
trie.go
29
trie.go
@@ -1,7 +1,6 @@
|
||||
package jiebago
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/md5"
|
||||
"encoding/gob"
|
||||
"fmt"
|
||||
@@ -19,34 +18,6 @@ type trie struct {
|
||||
Freq map[string]float64
|
||||
}
|
||||
|
||||
func (t trie) MarshalBinary() ([]byte, error) {
|
||||
var b bytes.Buffer
|
||||
enc := gob.NewEncoder(&b)
|
||||
err := enc.Encode(t.Total)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = enc.Encode(t.Freq)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b.Bytes(), nil
|
||||
}
|
||||
|
||||
func (t *trie) UnmarshalBinary(data []byte) error {
|
||||
b := bytes.NewBuffer(data)
|
||||
dec := gob.NewDecoder(b)
|
||||
err := dec.Decode(&t.Total)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = dec.Decode(&t.Freq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *trie) load(dictFileName string) error {
|
||||
dictFilePath, err := DictPath(dictFileName)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user