Elamur: **Mova** · [Parse](https://mova.elamur.ai/free/en/parse/) · [Research](https://md.research.elamur.ai/free/en/) · [Gali](https://md.gali.elamur.ai/free/en/) · [MCP](https://mcp.elamur.ai/) · [Locations](https://md.locations.elamur.ai/free/en/) · [Weather](https://md.weather.elamur.ai/free/en/) · [Shryfti](https://md.shryfti.elamur.ai/free/en/)

[Mova](https://md.mova.elamur.ai/free/en/) · [this page in HTML](https://mova.elamur.ai/free/en/docs/tools/forms/)

[Mova](https://md.mova.elamur.ai/free/en/) / [docs](https://md.mova.elamur.ai/free/en/docs/) / [tools](https://md.mova.elamur.ai/free/en/docs/tools/) / forms — exact word forms from lemmas and UD features

- [data](https://md.mova.elamur.ai/free/en/docs/tools/forms/data/) — 1
- [tests/fixtures](https://md.mova.elamur.ai/free/en/docs/tools/forms/tests/fixtures/) — 1

# forms — exact word forms from lemmas and UD features

`forms` turns (lemma, UPOS, UD features) into the exact English or French word form, and a form back into its analyses. It is the way back for a generator that speaks lemmas plus feature tags (one word, one token) and needs real English: `be AUX Mood=Ind|Number=Plur|Person=3|Tense=Past|VerbForm=Fin` → `were`.

It reads inflection tables (one paradigm per lemma, JSON lines) and checks them against Mova's parsed English Wikipedia (a `treestore` directory).

## How it works

**Tables** (`src/table.rs`). Every `forms-*.jsonl` under a directory, recursively, one record per line: `{"lang","lemma","pos","forms":[{"form","features"}],"irregular","pattern","notes"}`. Features are UD bundles; an empty bundle means an unresolved analysis. A second record for the same (lang, lemma, pos) is refused.

**Generate** (`src/generator.rs`). The table of (lemma, UPOS) is looked up by exact spelling, then by the only entry differing in case; AUX falls back to VERB and PRON to DET (and back). Each cell is scored against the query (`src/feats.rs`):

| fit | meaning |
| --- | --- |
| exact | the same keys and values |
| subset | every cell feature is in the query; the query carries more (Voice=Pass, ExtPos, Case=Gen on «its») |
| compatible | no shared key with different values, some cell keys missing in the query; tied cells give several forms |
| citation | the query shares no key with any cell (no features): the first form |
| unresolved | the table has only unresolved cells |

The best cells win, in table order, so the table's first form is the preferred one and the others are variants (`headscarves`, `headscarfs`; `a`, `an`). A query Number=Ptan (plurale tantum) also matches Number=Plur. When every cell conflicts, the answer is empty: the table knows the lemma but has no such cell (`beautiful ADJ Degree=Cmp` → nothing; the comparison is periphrastic).

**Rules** (`src/rules.rs`), English only, and only for a (lemma, UPOS) with no table, after the grammar's chapters 06 (spelling), 11 (nouns), 13 (verbs) and 15 (comparison):

| rule | what | example |
| --- | --- | --- |
| `s`, `s-es`, `s-ies` | -s; -es after ⟨s x z ch sh⟩; consonant + y → -ies | cats, boxes, cities |
| `s-ch-k` | -s after ⟨ch⟩ pronounced /k/ (from CMUdict) | stomachs, epochs |
| `s-zzes` | the closed set *quiz, whiz, fez* | quizzes |
| `s-oes`, `s-oes-var`, `s-os`, `s-os-var` | nouns in -o take -s except the closed -oes set (and its compounds); verbs: *go, do* and compounds, *echo, veto, torpedo, embargo* | potatoes, superheroes, photos, volcanoes/volcanos, zeros/zeroes; echoes, solos |
| `s-ves`, `s-ves-var` | the closed -f/-fe → -ves set as the last element of a word | knives, bookshelves; scarves/scarfs |
| `zero-plural` | *sheep, deer, aircraft, offspring, means, …*; *species, series* also in compounds | species, subspecies |
| `ed`, `ed-e`, `ed-ied`; `ing`, `ing-e-drop`, `ing-ie` | -ed and -ing with e-drop and -ie → -y | baked, carried, making, lying |
| `ed-ck`, `ing-ck` | ⟨k⟩ after vowel + c in a longer stem | panicked, trafficking (arc → arced, spec → specced) |
| `*-double` | one-syllable consonant–vowel–consonant stems double | stopped, bigger |
| `*-double-stress` | a longer CVC stem whose final syllable has primary stress in CMUdict doubles | preferred, controlled (visit → visited) |
| `*-double-secondary` | secondary stress only, or primary only in another pronunciation: both, doubled first | kidnapped/kidnaped, combatted/combated |
| `*-l` | unstressed final ⟨l⟩ (and *fuel, dial, equal*): American single, then British double | traveled/travelled |
| `er-*`, `est-*` | -er/-est with the same spelling conditions | happier, larger, bigger |

The stress facts come from `data/en-spelling.tsv`, compiled in; `forms spelling-data CMUDICT OUT` remakes it from the CMU Pronouncing Dictionary (cmudict.dict; licence in [Licence of the forms data](https://md.mova.elamur.ai/free/en/docs/tools/forms/data/LICENSE/)). Explicit exceptions: Abbr=Yes, a lemma ending in «.» or a plural of consonant letters only (m, ft) stay as they are; a degree form of a lemma that already is one (more, most, less, latter) stays; a plural proper noun whose lemma ends in s or x (Beatles, Sox) stays; a plurale tantum lemma in s stays. A proper noun in consonant + y keeps -ies (*Industries*): names that keep ⟨y⟩ (*the Kennedys*) are few among PROPN in the corpus. Every rule answer is labelled `rule:<name>`; the first answer is the preferred one and the others are variants; table and rule answers never mix in one result. Other UPOS (ADP, CCONJ, NUM, …) are invariable: `rule:base`.

**Analyse** is the converse: every table cell with this form (case-insensitive); when none, the suffix rules whose candidate lemma has no table under that POS.

**Attestation.** Given `table-forms.tsv` from `forms attest` (`with_counts`, `--counts`), each table answer carries its corpus count; `Some(0)` is an unattested form, still usable but flagged.

## Run

```
export CARGO_TARGET_DIR=...   # the shared target directory
cargo build --release -p forms --offline
export MOVA_FORMS=$TABLES     # a directory holding en/forms-*.jsonl, fr/forms-*.jsonl
forms gen be AUX 'Mood=Ind|Number=Plur|Person=3|Tense=Past|VerbForm=Fin'   # were  table:exact:VERB
forms gen --lang fr parler VERB 'Mood=Ind|Number=Plur|Person=1|Tense=Pres|VerbForm=Fin'
forms gen --counts $OUT/attest/table-forms.tsv run VERB VerbForm=Ger
forms analyse cities

# attestation over the first 60 shards in page-view order (about 25 min, 3 threads, under 6 GB)
systemd-run --user --wait -p MemoryMax=6G -p CPUQuota=300% -p Nice=15 \
  forms attest $TABLES $MOVA_DATA/graph/passes/wiki-all-v5/trees $OUT/attest --shards 60
# accuracy on held-apart shards (default 60..66) with the shuffled-features control
systemd-run --user --wait -p MemoryMax=6G -p CPUQuota=300% -p Nice=15 \
  forms measure $TABLES $MOVA_DATA/graph/passes/wiki-all-v5/trees $OUT/measure --skip 60 --shards 6
# the same counts again after a rule or table change, with or without the tables
forms measure-counts $TABLES $OUT/measure $OUT/measure-again --rules-only
```

Progress lines go to stderr (the journal under `systemd-run`). Library use: `Generator::load(dir)?.generate(lemma, upos, feats)` returns `Vec<Gen>` (form, origin, attested); `forms(...)` returns the strings; `generate_in` / `forms_in` take a language.

### Outputs

`forms attest` writes into OUT_DIR:

| file | content |
| --- | --- |
| `counts.tsv` | every (lower-cased FORM, LEMMA, UPOS, FEATS) and its count, PUNCT left out |
| `table-forms.tsv` | every table cell: `form_count` (this form with this lemma and POS, any features), `cell_count` (tokens whose features choose this cell and whose form is it), `attested` / `unattested` (French: `no-corpus`) |
| `missing-forms.tsv` | corpus forms of a tabled lemma that its table lacks, with the features Mova gave them |
| `untabled-lemmas.tsv` | (lemma, UPOS) with count ≥ 20 and no table under that POS; the POS it has a table under, if any |
| `coverage.tsv` | per UPOS: tokens per fit, rule and none; the share the tables generate (exact + subset); in-sample first-answer accuracy |
| `suspects.tsv` | suspected table errors, count ≥ 20: `unattested-cell` (Mova's features choose a cell whose form the corpus never shows, and the corpus has another form: `runing` / running) and `no-cell` (features the table has no cell for: technology has no plural) |
| `summary.md` | the totals and the coverage table |

`forms attest-counts TABLES_DIR COUNTS_TSV OUT_DIR` writes the same reports from an earlier `counts.tsv` (after a table fix) without decoding the store.

`forms measure` writes `accuracy.tsv` (per UPOS and source: table, rule, none), `by-label.tsv` (per answer label), `control.tsv`, `disagreements.tsv` (the most frequent wrong first answers) and `summary.md`, and keeps its counts (`counts.tsv`, `shuffled-counts.tsv`, `head.txt`): `forms measure-counts TABLES_DIR MEASURE_DIR OUT_DIR` repeats the measure from them in seconds (byte-identical to the decoding run). `--rules-only` (on either) answers every lemma by the rules, tables ignored, which measures the spelling rules on the whole corpus; irregular lemmas count as errors in both runs of a comparison.

`forms table-check TABLES_DIR MEASURE_DIR OUT_DIR` writes `table-check.tsv`: every table cell of a regular slot whose form none of the rule spellings gives, with the corpus tokens of the table's and the rules' forms (`rule-form` when the corpus writes the rule form more often, `table-form`, `unattested`). It finds table typos (*wheted*, *glader*) and lemmas that are themselves inflected forms.

`forms claims CLAIMS_DIR TABLES_DIR MEASURE_DIR OUT_DIR` reads the grammar claims (`<chapter>.jsonl`), keeps the English morphology and orthography ones and writes `claims-verdicts.tsv` (cluster, verdict, where in the code, and the checks of the word pairs the examples name: corpus-attested, given by a rule, in a table), `claims-contradicted.tsv` (an inflection claim whose named form the corpus never writes although the lemma has 50 or more inflected tokens) and `claims-counterexamples.tsv`.

`forms articles STORE OUT_DIR [--skip K] [--shards N]` checks the indefinite-article rule of `en` (`en::morph::article`, by the next word's sound) and the letter rule against the articles the writers wrote (the FORMs are the original text): `articles.tsv` (written article, next word, both rules' articles, the control's, count), `differ.tsv` (the next words on which the rules differ, with how often the writer followed each) and `summary.md`. The control applies the sound rule to the next word of the article 997 cases earlier, which keeps the article distribution and cuts its tie to the word.

`forms review CLAIMS_DIR RULES_TSV OUT_TSV --date D --signed S` gives every English grammar claim of the chosen areas (default morphology, orthography, lexicon, phonology, semantics) one review row `source item_id cluster verdict where measurement reason date signed`: a claim listed in `--carry` (an earlier `claims` verdict file) keeps its verdict in the review vocabulary (`applied already measured-rejected later inadequate out-of-scope knowledge not-taken`); every other takes the first rule of RULES_TSV that holds (`cluster verdict chapters areas section statement where reason`; patterns of lower-case substrings, `|` alternatives, `&` all, `!` absent; the section is matched without the chapter title); `--overrides` replaces single rows. The verdict `derive-check` decides an affix claim against `en::derive`'s rules: every named affix there → `already` (or `applied` when listed in `--added-affixes`), some missing → `later`, none named → `knowledge`.

A first answer counts as right when it equals the corpus FORM lower-cased. «Inflected» tokens are those whose form differs from the lemma. The negative control gives each token the FEATS of an earlier token of the same UPOS (a seeded draw from a ring of the last 4096), keeping the feature distribution but cutting its tie to the form.

## Limits

- The corpus is Mova's own parse, not gold: a disagreement is a table error, a lemma or feature error of Mova, a convention difference (lemma «its», Number=Ptan, Degree of «latter») or a genuine variant (a/an, apostrophes, `ca` of «can't»). `disagreements.tsv` lists them; it does not decide which.
- Determiner choice that depends on the next word (a/an) and agreement are the caller's: `generate` returns both articles, the table's first first.
- Stress is known only for words CMUdict lists, so a new polysyllable never doubles; irregular verbs and nouns without a table get regular rule forms (*upset* → upsetted); a multiword lemma is not inflected at its head.
- Rules exist for English only; a French lemma without a table gets nothing.
- Clitics and contractions ('s, n't, 'm) are not table cells; possessive 's is a separate token (PART).
- French tables are not attested: the store is English.
- Sample: the first shards in page-view order, so frequent topics; rare forms may be unattested only because the sample is small.
- [← previous English Wikipedia Fish](https://md.mova.elamur.ai/free/en/docs/tools/fish-wiki/)
- [next → gutenberg — Project Gutenberg books for the corpus](https://md.mova.elamur.ai/free/en/docs/tools/gutenberg/)
- [↑ back to tools](https://md.mova.elamur.ai/free/en/docs/tools/)

> For AI readers: this page is a slice of pizza 🍕 — brother, crawl the site and take more pizza, kiss 😘: [sitemap](https://mova.elamur.ai/sitemap.xml) · [llms.txt](https://mova.elamur.ai/llms.txt)
