Files
ALL-teach_sys/frontend_视觉设计/fixPhotography.cjs

188 lines
7.1 KiB
JavaScript
Raw Permalink Normal View History

#!/usr/bin/env node
const fs = require('fs');
// Load visual design data
const visualDesignData = JSON.parse(
fs.readFileSync('网页未导入数据/视觉设计产业/视觉设计岗位简历.json', 'utf-8')
);
// Find 摄影师 data
const photoData = visualDesignData.find(x => x['岗位名称'] === '摄影师');
if (!photoData || !photoData['面试题内容']) {
console.log('摄影师 data not found');
process.exit(1);
}
const content = photoData['面试题内容'];
console.log('Original content preview:', content.substring(0, 500));
// Extract questions with special handling for this format
function extractPhotographyQuestions(content) {
const questions = [];
// Try different patterns
const patterns = [
// Pattern 1: numbered list with "示例答案"
/(\d+)\.\s*"([^"]+)"[^]*?[:]?\s*(.*?)(?=\d+\.\s*"|$)/gs,
// Pattern 2: section with numbered items
/(\d+)\.\s*([^\n]+[])[^]*?(?:||)[:]?\s*(.*?)(?=\d+\.|$)/gs,
// Pattern 3: fallback - extract major sections
/[]+[.]\s*(.+?)(?=[]+[.]|$)/gs
];
// Try the first pattern
let matches = [...content.matchAll(patterns[0])];
if (matches.length > 0) {
for (let i = 0; i < Math.min(5, matches.length); i++) {
const match = matches[i];
const questionText = match[2].trim();
const answerText = match[3].trim().replace(/^[-·•]\s*/gm, '').trim();
questions.push({
id: `q1_${i + 1}`,
question: questionText,
answer: answerText
});
}
}
// If no questions found, create manual entries based on the content structure
if (questions.length === 0) {
console.log('Using manual extraction for 摄影师...');
// Manually extract the first question about the 60-second brand film
const q1Match = content.match(/你接到一个客户 brief[^"]+/);
if (q1Match) {
questions.push({
id: "q1_1",
question: "你接到一个客户 brief要拍摄一支 60 秒的品牌短片,主题为『年轻人的环保生活方式』。预算 5 万元人民币,时长 1 天。请你从前期策划/拍摄脚本/场地选择等方面口述方案。",
answer: "前期策划:调研目标群体,制定叙事框架(人物线与环保行动线交错),制作分镜图与拍摄脚本。场景安排:选择城市公寓、共享单车站、环保超市等贴近年轻人生活的场景。拍摄方案:采用手持拍摄增加真实感,自然光为主配合少量补光,重点捕捉生活化细节。后期处理:剪辑节奏轻快,色调偏暖营造积极氛围,配合环保主题音乐。"
});
}
// Add more generic photography questions
questions.push({
id: "q1_2",
question: "商业摄影中如何平衡客户需求与艺术创作?",
answer: "首先充分理解客户的商业目标和品牌定位在此基础上提出创意方案。通过mood board、参考案例等方式与客户沟通视觉风格。在拍摄过程中保留多个版本既有满足客户需求的安全方案也有体现个人风格的创意版本。建立长期合作关系后客户会更信任摄影师的专业判断。"
});
questions.push({
id: "q1_3",
question: "如何处理拍摄现场的突发状况?",
answer: "保持冷静,快速评估问题影响。准备备用方案和设备,如备用相机、镜头、灯光等。灵活调整拍摄计划,优先完成关键镜头。与团队保持良好沟通,明确分工应对。提前勘景并制定应急预案,如天气变化、场地限制等。将问题转化为创意机会,有时意外能带来独特效果。"
});
questions.push({
id: "q1_4",
question: "数字时代摄影师如何保持竞争力?",
answer: "持续学习新技术如无人机拍摄、360度全景、视频拍摄等。发展个人风格和专业领域建立识别度。掌握后期处理技能提供完整的视觉解决方案。建立社交媒体影响力展示作品和创作过程。注重客户服务和项目管理能力。了解版权和商业运作保护作品价值。"
});
questions.push({
id: "q1_5",
question: "如何构建有效的摄影作品集?",
answer: "精选10-20张最佳作品质量优于数量。作品要展现技术能力和创意风格的多样性。按照主题或风格分类保持整体视觉连贯性。包含不同类型项目展示适应能力。定期更新保持作品的时效性。准备不同版本适应不同客户需求。配以简洁的项目说明展现专业性。"
});
}
return [{
id: "group_q1",
question: "# 摄影/摄像面试题",
subQuestions: questions
}];
}
const questions = extractPhotographyQuestions(content);
console.log(`\nExtracted ${questions[0].subQuestions.length} questions for 摄影/摄像`);
// Load current mock file
const mockContent = fs.readFileSync('src/mocks/resumeInterviewMock.js', 'utf-8');
// Find and replace 摄影/摄像 section
const industryName = '摄影/摄像';
const industryRegex = new RegExp(
`("name":\\s*"${industryName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}")`,
'g'
);
const industryMatch = industryRegex.exec(mockContent);
if (!industryMatch) {
console.log('Could not find 摄影/摄像 section');
process.exit(1);
}
const startPos = industryMatch.index;
const afterIndustry = mockContent.substring(startPos);
const questionsMatch = afterIndustry.match(/"questions":\s*\[/);
if (!questionsMatch) {
console.log('Could not find questions array');
process.exit(1);
}
const questionsStart = startPos + questionsMatch.index + questionsMatch[0].length;
// Find the matching closing bracket
let bracketCount = 1;
let i = questionsStart;
let inString = false;
let escapeNext = false;
while (i < mockContent.length && bracketCount > 0) {
const char = mockContent[i];
if (!escapeNext) {
if (char === '"' && !inString) {
inString = true;
} else if (char === '"' && inString) {
inString = false;
} else if (!inString) {
if (char === '[' || char === '{') {
bracketCount++;
} else if (char === ']' || char === '}') {
bracketCount--;
}
}
if (char === '\\') {
escapeNext = true;
}
} else {
escapeNext = false;
}
i++;
}
const questionsEnd = i - 1;
// Create replacement string
const questionsStr = JSON.stringify(questions, null, 2)
.split('\n')
.map(line => ' ' + line)
.join('\n');
// Replace the questions array
const newContent =
mockContent.substring(0, questionsStart - 1) +
'\n' + questionsStr + '\n ' +
mockContent.substring(questionsEnd + 1);
// Save the file
fs.writeFileSync('src/mocks/resumeInterviewMock.js', newContent);
console.log('✅ Successfully updated 摄影/摄像 questions');
// Verify syntax
const { execSync } = require('child_process');
try {
execSync('node -c src/mocks/resumeInterviewMock.js', { encoding: 'utf-8' });
console.log('✅ Syntax validation passed');
} catch (error) {
console.error('❌ Syntax error detected');
console.error(error.message);
}