// Quick script to convert old vocabulary format to new language-agnostic format const fs = require('fs'); function convertVocabularyFormat(inputFile, outputFile) { let content = fs.readFileSync(inputFile, 'utf8'); // Pattern to match: word: "translation", const pattern = /(\s+)(\w+|"[^"]*"): "([^"]*)",?/g; content = content.replace(pattern, (match, indent, word, translation) => { // Determine word type based on translation or word let type = "noun"; // Default if (translation.includes("的") && !translation.includes(";")) type = "adjective"; if (word.includes(" ")) type = "phrase"; return `${indent}${word}: { user_language: "${translation}", type: "${type}" },`; }); fs.writeFileSync(outputFile, content); console.log(`Converted ${inputFile} to ${outputFile}`); } // Convert the sbs file convertVocabularyFormat( 'js/content/sbs-level-7-8-new.js', 'js/content/sbs-level-7-8-new-converted.js' );