AddWord adds given word to the User dictionary
(word string)
| 171 | |
| 172 | // AddWord adds given word to the User dictionary |
| 173 | func (sp *SpellData) AddWord(word string) { |
| 174 | if sp.learnTime.IsZero() { |
| 175 | sp.OpenUserCheck() // be sure we have latest before learning! |
| 176 | } |
| 177 | sp.mu.Lock() |
| 178 | lword := strings.ToLower(word) |
| 179 | sp.model.AddWord(lword) |
| 180 | sp.learnTime = time.Now() |
| 181 | sint := sp.learnTime.Sub(sp.openTime) / time.Second |
| 182 | sp.mu.Unlock() |
| 183 | |
| 184 | if sp.UserFile != "" && sint > SaveAfterLearnIntervalSecs { |
| 185 | sp.SaveUser() |
| 186 | // log.Printf("spell.LearnWord: saved updated model after %d seconds\n", sint) |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | // DeleteWord removes word from dictionary, in case accidentally added |
| 191 | func (sp *SpellData) DeleteWord(word string) { |