build-a-spell-checker / lesson-39.md
Lesson 39 · The spell-checking tool

A personal ignore list

Every user has words the dictionary lacks - names, jargon, project terms. Today you add a personal ignore list so the checker accepts words you mark, and stops flagging them.

The goal

Let the checker accept explicitly ignored words as correct, so they are never flagged.

Start here - the target
TO DO
Scenario: Ignored words are treated as known
Givena Checker over a dictionary containing "the", where Ignore("Zaphod") has been called
WhenCheck("Zaphod teh") is called
Thenit returns one Issue, for "teh" - "Zaphod" is accepted and not flagged
Andignoring is case-insensitive, so "zaphod" and "ZAPHOD" are also accepted
Background

No fixed dictionary fits every document - a novel has invented names, a codebase has identifiers, a field has jargon. Rather than force those into the main dictionary, a spell checker keeps a personal ignore list: words the user has marked as fine. Ignore("Zaphod") records the name, and from then on the checker treats it exactly like a known word - no flag, no suggestions.

The implementation reuses the same normalization as the dictionary, so ignoring is case-insensitive: mark Zaphod once and zaphod and ZAPHOD are all accepted. Conceptually the checkable test now has three outs - a token is left alone if it is an acronym, if the dictionary contains it, or if it has been ignored - and only what survives all three is flagged. This is the last feature the tool needs; the capstone puts everything together on a real passage.

Make it work
func (c *Checker) Ignore(word string) {
// remember normalize(word) in a personal set
}
// a token is skipped if the dictionary Contains it OR it is ignored
CheckpointDONE
The checker honors a personal ignore list of accepted words. Commit and stop here.