Euspell
Docs

Lexicon format

The lexicon is version-controlled as source CSVs and compiled to JavaScript maps at build time. Four columns describe each word; a three-digit encoding ties them together.

The source CSV

ColumnTypeNotes
WordstringSource spelling; proper nouns may be mixed-case
PoSstringPipe-separated CLAWS7 tags, e.g. NN2|VVZ
EncodingstringThree-digit code; 000 = unchanged
euspellingstringPipe-separated new spellings; [] = unchanged
data/euspell_lexicon.csv
Word,PoS,Encoding,euspelling
night,NN1|NNT1|VV0,101,niht
aahs,NN2|VVZ,012,aahs|aahz
does,NN2|VDZ,202,does|duz

Abbreviations, contractions, and phrases share the same four-column shape in their own files. Contractions add a wrinkle: the PoS field encodes a sequence of grammatical words (spaces separate positions, pipes separate alternative analyses).

All four are in the repository, and they are the only lexicon files edited by hand: euspell_lexicon.csv, abbreviations, contractions, and phrases.

The compiled form

build/compile-lexicon.js turns each CSV into an auto-generated JS module — a Map keyed by lowercase word:

dist/lexicon.js — generated, do not edit
export const data = new Map([
  ['aahs', { pos: ['NN2', 'VVZ'], encoding: 12, spellings: ['aahs', 'aahz'] }],
  // …~205000 entries
]);
Lookup contract
Lookups are always lowercase (lexicon.get(word.toLowerCase())). The encoding is stored as an integer and compared as one (entry.encoding >= 200). matchCase()restores the original word's ALL-CAPS, Title Case, or lowercase afterwards.

CLAWS7 tags — the relevant subset

Part-of-speech tags come from the CLAWS7 tagset. The ones that drive disambiguation:

TagMeaningExample
VV0Base-form verbread, run, go
VVZ3rd-singular presentreads, runs, goes
VVDPast tenseread, ran, went
VVNPast participleread, run, gone
VVGPresent participlereading, running
NN1Singular common nounbass, lead, wind
NN2Plural common nounbows, tears, winds
JJAdjectivebeloved, blessed

Full reference: ucrel.lancs.ac.uk/claws7tags.html

After editing a CSV

Nothing reads the CSVs at runtime. Every tool loads the compiled dist/ modules, so an edit to a CSV changes nothing until it is recompiled — which is what these commands are for, in a checkout of the repository:

npm run build:lexicon  # data/*.csv → dist/*.js — after any lexicon edit
npm run build          # the above, plus the Rollup content bundle
npm run gen:svm        # only if the NN2|VVZ training data changed

dist/lexicon.js is deliberately absent from the repository: it is a generated artifact, rebuilt on demand rather than committed. The retrained model, by contrast, is committed, at src/disambig/vvz-svm.js, so that a build needs no Python.