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

Only checking real words

Not every token is a word to spell-check - an all-caps acronym like "NASA" is not a typo. Today you teach the checker to skip acronyms so it stops flagging things that are spelled fine on purpose.

The goal

Skip all-uppercase multi-letter tokens so acronyms are never flagged as misspellings.

Start here - the target
TO DO
Scenario: Acronyms are not checked
Givena Checker over a dictionary containing "the"
WhenCheck("NASA teh") is called
Thenit returns one Issue, for "teh" (corrected to "the")
And"NASA" produces no Issue, because an all-uppercase word of two or more letters is treated as an acronym
Background

A checker that flags NASA, HTML, and PDF on every page is annoying and wrong - those are not misspellings, they are acronyms, deliberately all-caps. A cheap, effective rule catches most of them: a token that is entirely upper-case and at least two letters long is almost certainly an initialism, not a typo, so the checker skips it before ever consulting the dictionary.

This is the first real judgment the tool makes about what counts as a word to check, and it is deliberately conservative - it only exempts a narrow, obvious class, leaving I and ordinary Capitalized or lower-case words fully checked. Real checkers extend this idea with more skip rules (URLs, code, numbers with units), but the principle is the same: filter out the tokens that are not prose words before spending effort correcting them. The next lesson turns to where a flagged word is, in human terms.

Make it work
// before flagging a token, decide if it is even checkable
func isCheckable(word string) bool {
// an all-upper-case token of length >= 2 is an acronym - skip it
// (single letters like "I" and ordinary words stay checkable)
}
CheckpointDONE
Acronyms are left alone while ordinary words are still checked. Commit and stop here.