lila/data-pipeline/utils/create-base-json.ts
2026-07-06 14:27:47 +02:00

27 lines
694 B
TypeScript

import fs from "fs";
import path from "path";
import { LANG_MAP, POS_MAP } from "../config/constants.js";
/**
* Creates the base JSON file with word, language, and pos.
* No logging — the orchestrator handles all console output.
*/
export function createBaseJson(
word: string,
outputDir: string,
rawLanguage: string,
rawPos: string,
): void {
const targetFilePath = path.join(outputDir, `${word}.json`);
const dbLanguage = LANG_MAP[rawLanguage] || rawLanguage;
const dbPos = POS_MAP[rawPos] || rawPos;
const initialData = { word, language: dbLanguage, pos: dbPos };
fs.writeFileSync(
targetFilePath,
JSON.stringify(initialData, null, 2),
"utf-8",
);
}