1
0
mirror of https://github.com/fumiama/jieba.git synced 2026-06-11 12:20:24 +08:00

small code refactor

This commit is contained in:
Wang Bin
2015-02-04 14:47:59 +08:00
parent c3dce0d4a1
commit 0f7c56b4ef
5 changed files with 20 additions and 19 deletions

View File

@@ -15,6 +15,8 @@ import (
"strings"
)
var T *Trie
type Trie struct {
Nodes mapset.Set
MinFreq float64
@@ -181,7 +183,7 @@ func addWord(word string, freq float64, tag string) {
if len(tag) > 0 {
UserWordTagTab[word] = strings.TrimSpace(tag)
}
trie.addWord(word, freq)
T.addWord(word, freq)
}
func LoadUserDict(filePath string) error {
@@ -210,3 +212,8 @@ func LoadUserDict(filePath string) error {
return scanner.Err()
}
func SetDictionary(dict_path string) (err error) {
T, err = newTrie(dict_path)
return
}