Overlay 2.0 (#12)

This commit is contained in:
2026-03-01 02:36:51 -08:00
committed by GitHub
parent 45df3c466b
commit 44c7761c7c
397 changed files with 15139 additions and 7127 deletions

View File

@@ -0,0 +1,22 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { extractLineVocabulary, isKanji } from './reducer';
test('isKanji follows canonical CJK ranges', () => {
assert.ok(isKanji('日'));
assert.ok(isKanji('𠀀'));
assert.ok(!isKanji('あ'));
assert.ok(!isKanji('a'));
});
test('extractLineVocabulary returns words and unique kanji', () => {
const result = extractLineVocabulary('hello 你好 猫');
assert.equal(result.words.length, 3);
assert.deepEqual(
new Set(result.words.map((entry) => `${entry.headword}/${entry.word}`)),
new Set(['hello/hello', '你好/你好', '猫/猫']),
);
assert.equal(result.words.every((entry) => entry.reading === ''), true);
assert.deepEqual(new Set(result.kanji), new Set(['你', '好', '猫']));
});