mirror of
https://github.com/fumiama/jieba.git
synced 2026-06-12 05:00:24 +08:00
added tests for dictionary.go, fixed a small bug
This commit is contained in:
@@ -16,6 +16,10 @@ type Dictionary struct {
|
||||
sync.RWMutex
|
||||
}
|
||||
|
||||
func New() *Dictionary {
|
||||
return &Dictionary{freqMap: make(map[string]float64)}
|
||||
}
|
||||
|
||||
func (d *Dictionary) addToken(token Token) {
|
||||
d.freqMap[token.text] = token.frequency
|
||||
d.total += token.frequency
|
||||
@@ -84,6 +88,8 @@ func (d *Dictionary) loadDictionary(fileName string, isUserDictionary bool) erro
|
||||
|
||||
if !isUserDictionary && len(d.freqMap) > 0 {
|
||||
d.freqMap = make(map[string]float64)
|
||||
d.total = 0.0
|
||||
d.logTotal = 0.0
|
||||
}
|
||||
for scanner.Scan() {
|
||||
line = scanner.Text()
|
||||
|
||||
Reference in New Issue
Block a user