From bd359c76fe5f9086f4f15b58ff75c6565c0928de Mon Sep 17 00:00:00 2001 From: tk1024 Date: Sun, 22 Mar 2026 21:42:44 +0900 Subject: [PATCH] =?UTF-8?q?test:=20allowLowConfidence=20=E3=83=A2=E3=83=BC?= =?UTF-8?q?=E3=83=89=E3=81=AE=20accuracy=20=E3=83=AC=E3=83=9D=E3=83=BC?= =?UTF-8?q?=E3=83=88=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 各カテゴリで通常モードと allowLowConfidence モードの両方の 正答率を計測するようにした。 Co-Authored-By: Claude Opus 4.6 (1M context) --- test/helper.ts | 58 +++++++++++++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 22 deletions(-) diff --git a/test/helper.ts b/test/helper.ts index 09b8330..928d3b6 100644 --- a/test/helper.ts +++ b/test/helper.ts @@ -52,10 +52,38 @@ async function ensureLexicon(): Promise { return false; } +function runAccuracyReport( + suiteName: string, + cases: TestCase[], + mode: "normal" | "lowConfidence", +): void { + let correct = 0; + let wrong = 0; + let unsplit = 0; + + const opts = mode === "lowConfidence" ? { allowLowConfidence: true } : {}; + + for (const tc of cases) { + const result = split(tc.input, opts); + if (result.sei === tc.sei && result.mei === tc.mei) { + correct++; + } else if (result.mei === "") { + unsplit++; + } else { + wrong++; + } + } + + const total = correct + wrong + unsplit; + const label = mode === "lowConfidence" ? `${suiteName} [lowConf]` : suiteName; + console.log( + `${label}: ${correct}/${total} correct (${((correct / total) * 100).toFixed(1)}%), ${wrong} wrong, ${unsplit} unsplit` + ); +} + /** * Run a data-driven test suite from a TSV file using the bundled dictionary. - * Uses locally generated data if available, otherwise falls back to the - * published npm package (seimei-split). + * Tests both normal mode and allowLowConfidence mode. */ export function runTsvTest(suiteName: string, tsvPath: string): void { describe(suiteName, () => { @@ -97,28 +125,14 @@ export function runTsvTest(suiteName: string, tsvPath: string): void { } }); - it("reports accuracy", () => { + it("reports accuracy (normal)", () => { if (!available) return; + runAccuracyReport(suiteName, cases, "normal"); + }); - let correct = 0; - let wrong = 0; - let unsplit = 0; - - for (const tc of cases) { - const result = split(tc.input); - if (result.sei === tc.sei && result.mei === tc.mei) { - correct++; - } else if (result.mei === "") { - unsplit++; - } else { - wrong++; - } - } - - const total = correct + wrong + unsplit; - console.log( - `${suiteName}: ${correct}/${total} correct (${((correct / total) * 100).toFixed(1)}%), ${wrong} wrong, ${unsplit} unsplit` - ); + it("reports accuracy (allowLowConfidence)", () => { + if (!available) return; + runAccuracyReport(suiteName, cases, "lowConfidence"); }); }); }