mirror of
https://github.com/fumiama/jieba.git
synced 2026-06-30 00:50:30 +08:00
removed unnecessary MarshalBinary/UnmarshalBinary method
This commit is contained in:
29
trie.go
29
trie.go
@@ -1,7 +1,6 @@
|
|||||||
package jiebago
|
package jiebago
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
"encoding/gob"
|
"encoding/gob"
|
||||||
"fmt"
|
"fmt"
|
||||||
@@ -19,34 +18,6 @@ type trie struct {
|
|||||||
Freq map[string]float64
|
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 {
|
func (t *trie) load(dictFileName string) error {
|
||||||
dictFilePath, err := DictPath(dictFileName)
|
dictFilePath, err := DictPath(dictFileName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user