MCPcopy Create free account
hub / github.com/cogentcore/core / AddWord

Method AddWord

spell/spell.go:173–188  ·  view source on GitHub ↗

AddWord adds given word to the User dictionary

(word string)

Source from the content-addressed store, hash-verified

171
172// AddWord adds given word to the User dictionary
173func (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
191func (sp *SpellData) DeleteWord(word string) {

Callers

nothing calls this directly

Calls 7

OpenUserCheckMethod · 0.95
SaveUserMethod · 0.95
LockMethod · 0.65
UnlockMethod · 0.65
IsZeroMethod · 0.45
NowMethod · 0.45
SubMethod · 0.45

Tested by

no test coverage detected