feat(dict): every roadmap word is a card, tagged with its unit
The reworked app's learner model hangs off cards: recall evidence, the phase-review checklist, the practice set, and the gate's "words he has met". So every word a unit introduces has to be studiable — and 16 of the 371 were not. Eleven existed only as sentence chunks or dictionary rows outside the review deck, and five (봐 읽어 갔어 봤어 먹었어) nowhere at all. The build now marks exactly one reviewable lemma per roadmap word with the unit that introduces it. Where the deck has the word, its row is chosen deterministically (deck order, then source, then part of speech) — the artifact tagged whichever card came last, which put the evidence for 이, 눈 and 저 on the wrong meaning. The sixteen get a `curriculum` lemma of their own, glossed from the curated verb they conjugate (자 is "sleep", the 반말 of 자다 — not the dictionary's "ruler"), else from the sentence that uses them, else the dictionary. Lemmas also carry their topic, which the vocabulary filters need. dict:assert gains the guarantee: 371/371 roadmap words as one card each. Migration 7 adds the two columns; the rows arrive with the dictionary reload a changed build now triggers on its own. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -6,53 +6,53 @@
|
||||
"frequencyForms": 688129
|
||||
},
|
||||
"totals": {
|
||||
"lemmas": 30520,
|
||||
"surfaces": 43879
|
||||
"lemmas": 30536,
|
||||
"surfaces": 43895
|
||||
},
|
||||
"bands": [
|
||||
{
|
||||
"band": 0,
|
||||
"file": "band-0.json.gz",
|
||||
"lemmas": 801,
|
||||
"surfaces": 1176,
|
||||
"bytes": 21332,
|
||||
"sha256": "e631e95e0263995c23ee58a5a3ed7cadf11d7b10566449192d644ccb2be7fe04",
|
||||
"lemmas": 802,
|
||||
"surfaces": 1177,
|
||||
"bytes": 24358,
|
||||
"sha256": "ec95a68245700a6dd9aee519378b9d86713484efe888f8450578f5c9315a48c6",
|
||||
"reference": false
|
||||
},
|
||||
{
|
||||
"band": 1,
|
||||
"file": "band-1.json.gz",
|
||||
"lemmas": 1240,
|
||||
"surfaces": 2335,
|
||||
"bytes": 48215,
|
||||
"sha256": "f4ab15154ed2cefd0aa86346d874c6f3b54c8455e6c58f1b20cd83750b8402e0",
|
||||
"lemmas": 1246,
|
||||
"surfaces": 2341,
|
||||
"bytes": 48984,
|
||||
"sha256": "7f3aa9965d3c893efb3c6ffa96f68cce219b00c1bd146a9b847f4dbc25ec203b",
|
||||
"reference": false
|
||||
},
|
||||
{
|
||||
"band": 2,
|
||||
"file": "band-2.json.gz",
|
||||
"lemmas": 1450,
|
||||
"surfaces": 2590,
|
||||
"bytes": 54698,
|
||||
"sha256": "2a48e603909cd969423cc444cfac215e7a2e51c6129a80e0779cbeed0c81ebd1",
|
||||
"lemmas": 1456,
|
||||
"surfaces": 2596,
|
||||
"bytes": 55436,
|
||||
"sha256": "4420ee704d1e16de6d9e5e721b3e9656482f7fd9f7930b9276ca1a9299031532",
|
||||
"reference": false
|
||||
},
|
||||
{
|
||||
"band": 3,
|
||||
"file": "band-3.json.gz",
|
||||
"lemmas": 1972,
|
||||
"surfaces": 3373,
|
||||
"bytes": 72713,
|
||||
"sha256": "1b5bf666475b301930a99b2c23a8d7a9e585a3cbd40a4787feeebdf96e6ad2af",
|
||||
"lemmas": 1974,
|
||||
"surfaces": 3375,
|
||||
"bytes": 73309,
|
||||
"sha256": "64789873ede0cb9876fc01d45b89c144a69c28fa87bd6e7734d26936626a87b7",
|
||||
"reference": false
|
||||
},
|
||||
{
|
||||
"band": 4,
|
||||
"file": "band-4.json.gz",
|
||||
"lemmas": 2987,
|
||||
"surfaces": 4775,
|
||||
"bytes": 106990,
|
||||
"sha256": "a1ec6eb219b3b1c303c26296d47e5341329e9773b7a30432729288edbda91957",
|
||||
"lemmas": 2988,
|
||||
"surfaces": 4776,
|
||||
"bytes": 107822,
|
||||
"sha256": "ec8c31ddf5080f7a6f0a1c92ac4067e764815122d9bdc244bd6b717d8a228d5e",
|
||||
"reference": false
|
||||
},
|
||||
{
|
||||
@@ -60,8 +60,8 @@
|
||||
"file": "band-5.json.gz",
|
||||
"lemmas": 6963,
|
||||
"surfaces": 10347,
|
||||
"bytes": 245251,
|
||||
"sha256": "1f8576b0d5686b67aece0a5b7a2bf291e5680f3fb7f43ec95a49cf7839d5730d",
|
||||
"bytes": 247327,
|
||||
"sha256": "de9b3c2daec3d5086a5711e6384a7239036fb3fd9e69ce4bfeea89458698731d",
|
||||
"reference": false
|
||||
},
|
||||
{
|
||||
@@ -69,8 +69,8 @@
|
||||
"file": "band-6.json.gz",
|
||||
"lemmas": 15107,
|
||||
"surfaces": 19283,
|
||||
"bytes": 499732,
|
||||
"sha256": "f9e2ed69ddb4515192d6e24a8abe863656c993414f6e28948ef59d78c6d0056c",
|
||||
"bytes": 507133,
|
||||
"sha256": "2a893ac64e46af015db7a3a6a29043848284e989e3b92c6f026059d6c3f11d51",
|
||||
"reference": true
|
||||
}
|
||||
],
|
||||
|
||||
Binary file not shown.
@@ -177,6 +177,19 @@ export const MIGRATIONS: Migration[] = [
|
||||
`,
|
||||
run: rekeyLemmas,
|
||||
},
|
||||
{
|
||||
id: 7,
|
||||
name: "curriculum words are cards — a lemma knows its topic and the unit that introduces it",
|
||||
sql: /* sql */ `
|
||||
-- Reference data from the band files, like the rest of lemma: not
|
||||
-- synced, no updated_at. The build marks exactly one reviewable lemma
|
||||
-- per roadmap word with its unit. The rows arrive with the next band
|
||||
-- load, which a changed dictionary triggers on its own.
|
||||
ALTER TABLE lemma ADD COLUMN topic TEXT;
|
||||
ALTER TABLE lemma ADD COLUMN unit_id TEXT;
|
||||
CREATE INDEX IF NOT EXISTS lemma_unit ON lemma(unit_id);
|
||||
`,
|
||||
},
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@@ -385,6 +385,10 @@ export interface LemmaRow {
|
||||
gloss_ko: string;
|
||||
unit_band: number;
|
||||
source: string;
|
||||
/** The deck topic, or "수업 <unit> <name>" for a curriculum word. */
|
||||
topic?: string | null;
|
||||
/** Set on exactly one lemma per roadmap word: the unit that introduces it. */
|
||||
unit_id?: string | null;
|
||||
}
|
||||
|
||||
export interface SurfaceRow {
|
||||
@@ -414,10 +418,10 @@ export async function insertBand(
|
||||
surfaces: SurfaceRow[],
|
||||
): Promise<void> {
|
||||
await db.tx(async (tx) => {
|
||||
const lemmaChunk = chunkFor(9);
|
||||
const lemmaChunk = chunkFor(11);
|
||||
for (let i = 0; i < lemmas.length; i += lemmaChunk) {
|
||||
const slice = lemmas.slice(i, i + lemmaChunk);
|
||||
const values = slice.map(() => "(?,?,?,?,?,?,?,?,?)").join(",");
|
||||
const values = slice.map(() => "(?,?,?,?,?,?,?,?,?,?,?)").join(",");
|
||||
const params: Params = slice.flatMap((l) => [
|
||||
l.id,
|
||||
l.headword,
|
||||
@@ -428,10 +432,12 @@ export async function insertBand(
|
||||
l.gloss_ko,
|
||||
l.unit_band,
|
||||
l.source,
|
||||
l.topic ?? null,
|
||||
l.unit_id ?? null,
|
||||
]);
|
||||
await tx.run(
|
||||
`INSERT OR REPLACE INTO lemma
|
||||
(id, headword, pos, freq_rank, level, gloss_en, gloss_ko, unit_band, source)
|
||||
(id, headword, pos, freq_rank, level, gloss_en, gloss_ko, unit_band, source, topic, unit_id)
|
||||
VALUES ${values}`,
|
||||
params,
|
||||
);
|
||||
|
||||
@@ -20,6 +20,9 @@ export interface DeckEntry {
|
||||
pos: string;
|
||||
glossEn: string;
|
||||
source: string;
|
||||
topic: string | null;
|
||||
/** The unit that introduces this word, for a roadmap word's card. */
|
||||
unitId: string | null;
|
||||
card: Card | null;
|
||||
status: CardStatus;
|
||||
}
|
||||
@@ -44,7 +47,10 @@ function toCard(row: Record<string, unknown>): Card | null {
|
||||
*/
|
||||
// 'custom' is here so the learner's own words are reviewable like any
|
||||
// other — adding a word you cannot then study would be pointless.
|
||||
const REVIEWABLE = "('curated', 'sfx', 'grammar', 'custom')";
|
||||
// 'curriculum' is a roadmap word the curated deck does not hold (먹어, 봤어):
|
||||
// every word a unit introduces is a card, because the recall evidence and
|
||||
// the phase review both hang off one.
|
||||
const REVIEWABLE = "('curated', 'sfx', 'grammar', 'custom', 'curriculum')";
|
||||
const SENTENCE_SOURCE = "('sentence')";
|
||||
|
||||
export interface DeckOptions {
|
||||
@@ -63,7 +69,8 @@ function sourceClause(opts: DeckOptions): string {
|
||||
|
||||
export async function deck(db: Db, opts: DeckOptions = {}): Promise<DeckEntry[]> {
|
||||
const rows = await db.all<Record<string, unknown>>(
|
||||
`SELECT l.id AS lemmaId, l.headword, l.pos, l.gloss_en AS glossEn, l.source, ${CARD_COLUMNS}
|
||||
`SELECT l.id AS lemmaId, l.headword, l.pos, l.gloss_en AS glossEn, l.source,
|
||||
l.topic, l.unit_id AS unitId, ${CARD_COLUMNS}
|
||||
FROM lemma l LEFT JOIN card c ON c.lemma_id = l.id
|
||||
WHERE ${sourceClause(opts)}
|
||||
ORDER BY l.headword`,
|
||||
@@ -77,6 +84,8 @@ export async function deck(db: Db, opts: DeckOptions = {}): Promise<DeckEntry[]>
|
||||
pos: r.pos as string,
|
||||
glossEn: r.glossEn as string,
|
||||
source: r.source as string,
|
||||
topic: (r.topic as string | null) ?? null,
|
||||
unitId: (r.unitId as string | null) ?? null,
|
||||
card,
|
||||
status: statusOf(card),
|
||||
};
|
||||
|
||||
@@ -39,7 +39,8 @@ const SELECT_VIA_SURFACE = `
|
||||
/** Prefer a curated gloss, then a common word, then anything. */
|
||||
const RANKED = `
|
||||
ORDER BY CASE l.source WHEN 'curated' THEN 0 WHEN 'grammar' THEN 1
|
||||
WHEN 'sentence' THEN 2 WHEN 'sfx' THEN 3 ELSE 4 END,
|
||||
WHEN 'curriculum' THEN 2 WHEN 'sentence' THEN 3
|
||||
WHEN 'sfx' THEN 4 ELSE 5 END,
|
||||
l.freq_rank IS NULL, l.freq_rank`;
|
||||
|
||||
/**
|
||||
|
||||
@@ -80,7 +80,7 @@ async function readBandWords(db: Db, band: number, ceiling: number): Promise<str
|
||||
`SELECT DISTINCT headword FROM lemma
|
||||
WHERE unit_band <= ? AND unit_band < ?
|
||||
AND (freq_rank IS NOT NULL AND freq_rank <= ?
|
||||
OR source IN ('curated','grammar','sentence','sfx'))
|
||||
OR source IN ('curated','grammar','sentence','sfx','curriculum'))
|
||||
ORDER BY freq_rank IS NULL, freq_rank
|
||||
LIMIT ?`,
|
||||
[band, REFERENCE_BAND, ceiling, VOCAB_CAP * 3],
|
||||
|
||||
Reference in New Issue
Block a user