(db *gorm.DB)
| 29 | var cache tfidfCache |
| 30 | |
| 31 | func loadVectorCache(db *gorm.DB) { |
| 32 | postings := query.Init(db).All() |
| 33 | idx := buldIndex(postings) |
| 34 | |
| 35 | cache.index = idx |
| 36 | cache.vector = make(map[string]map[string]float64) |
| 37 | |
| 38 | for account := range idx.Docs { |
| 39 | cache.vector[account] = tfidf(account, idx) |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | func ClearCache() { |
| 44 | cache = tfidfCache{} |