This commit is contained in:
lila 2026-07-06 13:09:30 +02:00
parent cc89f0c75c
commit afd28d934e
26 changed files with 2103 additions and 427 deletions

View file

@ -0,0 +1,23 @@
import fs from "fs";
import path from "path";
/**
* Checks if a JSON file for the given word exists AND contains enriched data.
* Returns false for skeleton files (missing senses array).
*/
export function isWordProcessed(word: string, outputDir: string): boolean {
const targetFilePath = path.join(outputDir, `${word}.json`);
if (!fs.existsSync(targetFilePath)) {
return false;
}
try {
const content = fs.readFileSync(targetFilePath, "utf-8");
const data = JSON.parse(content) as Record<string, unknown>;
return Array.isArray(data["senses"]) && data["senses"].length > 0;
} catch (_error: unknown) {
// Corrupted file => treat as not processed
return false;
}
}