wip
This commit is contained in:
parent
cc89f0c75c
commit
afd28d934e
26 changed files with 2103 additions and 427 deletions
41
data-pipeline/utils/create-base-json.ts
Normal file
41
data-pipeline/utils/create-base-json.ts
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
import fs from "fs";
|
||||
import path from "path";
|
||||
|
||||
const LANG_MAP: Record<string, string> = {
|
||||
english: "en",
|
||||
italian: "it",
|
||||
german: "de",
|
||||
french: "fr",
|
||||
spanish: "es",
|
||||
};
|
||||
|
||||
const POS_MAP: Record<string, string> = {
|
||||
nouns: "noun",
|
||||
verbs: "verb",
|
||||
adverbs: "adverb",
|
||||
adjectives: "adjective",
|
||||
};
|
||||
|
||||
/**
|
||||
* 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",
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue