词光 · Word Atlas — Illustrated IELTS vocabulary with 7,298 words, UK/US audio and FSRS review. Open-source app + CC BY 4.0 dataset.
TypeScript chinesedatasetenglish-learningflashcardsfsrsieltslanguage-learningpwareactspaced-repetitionvocabularywebgl
import assert from "node:assert/strict";
import { test } from "node:test";
import { gap, normalize, splitHighlight, splitPair } from "./text";
test("highlights the headword and common inflections", () => {
assert.deepEqual(splitHighlight("Training with a friend motivates me.", "motivate")?.[1], "motivates");
assert.deepEqual(splitHighlight("She studied hard.", "study")?.[1], "studied");
assert.deepEqual(splitHighlight("We got a day off today.", "day off")?.[1], "day off");
assert.equal(splitHighlight("Nothing here.", "salt"), null);
});
test("does not match inside longer unrelated words", () => {
assert.equal(splitHighlight("The cartoon was funny.", "art"), null);
});
test("gaps the sentence for cloze questions", () => {
const g = gap("I refused the extra money as a matter of principle.", "principle");
assert.equal(g?.hidden, "principle");
assert.equal(g?.after, ".");
});
test("normalizes typography from mobile keyboards", () => {
assert.equal(normalize(" Don’t "), "don't");
assert.deepEqual(splitPair("in principle|原则上"), { en: "in principle", zh: "原则上" });
});