Skip to main content

Module vocabulary

Module vocabulary 

Source
Expand description

Read-only Vim word-list parsing and immutable last-good vocabulary snapshots.

A vocabulary source is the user’s own word list. It marks a word as correct, recognized or rare, which protects the word when it is typed, or as wrong (forbidden): a forbidden typed word loses its protection, and a forbidden candidate is never written automatically. A source carries no frequency, so membership can stop a correction but never justify one.

Vocabulary::parse reads a Vim .add list line by line, as Vim reads its spellfile; Vocabulary::parse_words reads the words a user taught the OS spell checker, one per line. An entry’s form decides which cases of the word it matches:

entry         rule              matches              does not match
hello         lowercase         hello Hello HELLO    hElLo
iPhone        cased             iPhone IPHONE        iphone Iphone
Exact/=       exact (`=`)       Exact                exact EXACT

Across the entries that match a word, forbidden (!) wins, then recognized, then rare (?). A source is parsed whole before anything sees it: a bad line is skipped and counted, and a file that cannot be a word list is rejected with a ParseError. A Snapshot publishes only a successful parse, as one immutable Arc, so a reader keeps the vocabulary it started with and a failed candidate leaves the last good one in place.

Structs§

Snapshot
Atomically replaceable immutable vocabulary, initially missing rather than silently empty.
Vocabulary
Parsed personal entries. Region declarations and flags are validated but not kept, so lookup is locale-neutral. Entries are grouped by lowercase form, so a lookup compares case rules within one group.

Enums§

Membership
Personal vocabulary membership, without invented corpus frequency.
ParseError
Content-free whole-candidate rejection; a failed parse never publishes a partial list.

Constants§

MAX_SOURCE_BYTES
Largest source, in bytes, that either parser accepts.

Functions§

lowercase
Lowercase the EN/RU letters and keep every other UTF-16 unit; no locale or Unicode case mapping is applied.
uppercase
Uppercase the EN/RU letters and keep every other UTF-16 unit; no locale or Unicode case mapping is applied.