1
0
mirror of https://github.com/fumiama/jieba.git synced 2026-06-05 00:32:51 +08:00

added a new interface for caching

This commit is contained in:
Wang Bin
2015-03-28 15:49:32 +08:00
parent e11060513c
commit 79adffe328
5 changed files with 69 additions and 40 deletions

View File

@@ -9,6 +9,8 @@ import (
"sort"
)
const cacheNameFormat = "jieba.%x.cache"
var (
// Word/Tag Map load from user dictionary
UserWordTagTab = make(map[string]string)
@@ -57,6 +59,10 @@ func (j *Jieba) AddEntry(entry *Entry) {
j.Add(entry.Word, entry.Freq)
}
func (j *Jieba) CacheNameFormat() string {
return cacheNameFormat
}
func (j *Jieba) Add(word string, freq float64) {
j.Freq[word] = freq
j.Total += freq