Skip to content

0015 — Refresh per-lexeme frequency from the public corpora

Status: done — 2026-09-13 Opened: 2026-09-10 · Area: language module (lexeme catalog, ordering policy) Reopen trigger: the first curated or minted word set whose members have no frequency_wcpm matters to a learner’s ordering (e.g. a new list, or English coverage — the predecessor’s frq covers 53k English words against 99k Chinese).

Phase 7 (plan R6) carries the predecessor’s metadata.frq words-per-million onto lang_lexeme.frequency_wcpm for 152,200 words. Words minted afterwards get null and score zero in the ordering policy, exactly as unranked words do. The values derive from the public SUBTLEX-CH and SUBTLEX-US corpora.

Done (2026-09-13): packages/db/scripts/refresh-lexeme-frequency.ts, script frequency:refresh, run once per language — bun run --cwd packages/db frequency:refresh --language zh --file <corpus> [--overwrite] [--dry-run]. It reads the PUBLISHED corpora rather than the predecessor’s copy of them, fills frequency_wcpm for matching lexemes, and never replaces a stored figure unless --overwrite says so. It publishes and mints nothing: a corpus word the catalog does not hold is simply unmatched.

The two source files, downloaded as published (not committed — they are not repository data):

The rules the job applies, each of them a decision about what a figure means:

  • The format is read from the header, never from a flag (Word + W.million → SUBTLEX-CH, Word + SUBTLWF → SUBTLEX-US), and columns are read by NAME. A corpus paired with the wrong --language is refused, exit 2, nothing written — each file is about exactly one language.
  • Duplicate graphs: the FIRST row wins. 388 SUBTLEX-CH rows name a graph an earlier row already named (377 of them a #-pinyin proper-name row after the word’s own); the file is sorted by W.million descending, so the first row is also the larger figure. Same rule as the Phase-7 carry’s “first frq row”.
  • Chinese matches graph exactly; English matches lower(graph) — SUBTLEX-US case is the dominant SURFACE case (What, No, I), not lexical, and the catalog deliberately does not fold case. Where the catalog holds both China and china, both receive the corpus figure for china.