buildKanjiTestfunction
The test: words to write in kanji, then different words to read.
The seed decides which words and in what order, so the test on paper is the test that was on screen
and a link sent to somebody is the same test. Each word is asked once, and a word whose reading does
not fit it (segmentWord says null) is left out. A list too short for two halves of different words
asks its words both ways rather than leave the second half short.
Import it
import { buildKanjiTest } from "@johnmorrisdotca/hikidashi/align";
Also exported from: @johnmorrisdotca/hikidashi
Definition
function buildKanjiTest(pool: readonly ReadWord[], { seed, count }: { seed: number; count: number; }): KanjiTest
Parameters
| Name | Type | Description |
|---|---|---|
pool | readonly ReadWord[] | The words to draw from, each with its reading. |
options | { seed: number; count: number; } |
|
Returns
KanjiTest
The writing half and the reading half, each up to count questions; both empty when no word of the pool
fits its reading.
Examples
import { buildKanjiTest } from "@johnmorrisdotca/hikidashi/align";
const pool = [
{ word: "食べる", reading: "たべる" }, { word: "水", reading: "みず" },
{ word: "学校", reading: "がっこう" }, { word: "形が合う", reading: "かたちがあう" },
];
const test = buildKanjiTest(pool, { seed: 7, count: 2 });
console.log(test.writing.map((one) => one.word), test.reading.map((one) => one.word));
console.log(JSON.stringify(buildKanjiTest(pool, { seed: 7, count: 2 })) === JSON.stringify(test));[ '学校', '水' ] [ '形が合う', '食べる' ]
trueWhat it prints (run when this page was built)