m2geval / javascript /awesome-gpt4o-images_function_bench.jsonl
Tswatery's picture
Add files using upload-large-folder tool
b29a38b verified
{"repo_name": "awesome-gpt4o-images", "file_name": "/awesome-gpt4o-images/gen-tool/src/index.js", "inference_info": {"prefix_code": "import fs from 'fs';\nimport path from 'path';\nimport { fileURLToPath } from 'url';\nimport Mustache from 'mustache';\nimport yaml from 'js-yaml';\nimport langs from './i18n/lang.js';\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\nconst args = process.argv.slice(2);\nconst args_lang = args.find(arg => arg.startsWith('--lang='));\nconst lang = args_lang ? args_lang.split('=')[1] : 'zh';\nconst t = langs[lang];\n\n// read all case files\nconst caseDirs = fs.readdirSync(path.join(__dirname, '../../cases'));\nconst numericDirs = caseDirs.filter(dir => !isNaN(dir));\nlet cases = numericDirs.map(", "suffix_code": ");\n// Sort cases in descending order by case number\ncases.sort((a, b) => b.case_no - a.case_no);\n\n// render cases\nconst case_template = fs.readFileSync(path.join(__dirname, '../templates/case.md'), 'utf8');\nlet cases_contents = '';\nfor (const c of cases) {\n const source_links = c.source_links.length === 1\n ? `[${t.source_link_caption}](${c.source_links[0].url})`\n : c.source_links.map((link, i) => `[${t.source_link_caption}${i + 1}](${link.url})`).join(' | ');\n\n cases_contents += Mustache.render(case_template, {\n case_no: c.case_no,\n t: t,\n title: lang === 'zh' ? c.title : c.title_en,\n author: c.author,\n author_link: c.author_link,\n source_links: source_links,\n image: c.image,\n alt_text: lang === 'zh' ? c.alt_text.trim() : c.alt_text_en.trim(),\n attribution: c.attribution,\n prompt: lang === 'zh' ? c.prompt.trim() : c.prompt_en.trim(),\n prompt_note: lang === 'zh' ? c.prompt_note.trim() : c.prompt_note_en.trim(),\n reference_note: lang === 'zh' ? c.reference_note.trim() : c.reference_note_en.trim(),\n submitter: c.submitter,\n submitter_link: c.submitter_link,\n }) + '\\n';\n}\n\n// Data for the README template\nconst data = {\n 't': t,\n 'cases': cases.map(c => ({\n case_no: c.case_no,\n title: lang === 'zh' ? c.title : c.title_en,\n author: c.author,\n })),\n 'header': fs.readFileSync(path.join(__dirname, '../templates', lang, 'header.md'), 'utf8'),\n 'table-of-contents': fs.readFileSync(path.join(__dirname, '../templates', lang, 'table-of-contents.md'), 'utf8'),\n 'gpt4o-intro': fs.readFileSync(path.join(__dirname, '../templates', lang, 'gpt4o-intro.md'), 'utf8'),\n 'cases-contents': cases_contents,\n 'tools-intro': fs.readFileSync(path.join(__dirname, '../templates', lang, 'tools-intro.md'), 'utf8'),\n 'prompting-tips': fs.readFileSync(path.join(__dirname, '../templates', lang, 'prompting-tips.md'), 'utf8'),\n 'how-to-contribute': fs.readFileSync(path.join(__dirname, '../templates', lang, 'how-to-contribute.md'), 'utf8'),\n 'acknowledgements': fs.readFileSync(path.join(__dirname, '../templates', lang, 'acknowledgements.md'), 'utf8'),\n 'star-history': fs.readFileSync(path.join(__dirname, '../templates', lang, 'star-history.md'), 'utf8')\n};\n\n// Render the README template\nconst readmeTemplate = fs.readFileSync(path.join(__dirname, '../templates/README.md.md'), 'utf8');\nconst renderedReadme = Mustache.render(readmeTemplate, data);\n\n// Write the rendered README\nconst filename = lang === 'zh' ? 'README.md' : 'README_en.md';\nfs.writeFileSync(path.join(__dirname, '../..', filename), renderedReadme);\nconsole.log(`${filename} generated successfully`);\n", "middle_code": "dir => {\n const caseNumber = parseInt(dir);\n const casePath = path.join(__dirname, '../../cases', dir, 'case.yml');\n const caseData = yaml.load(fs.readFileSync(casePath, 'utf8'));\n const attributionPath = path.join(__dirname, '../../cases', dir, 'ATTRIBUTION.yml');\n const attributionData = yaml.load(fs.readFileSync(attributionPath, 'utf8'));\n return {\n case_no: caseNumber,\n ...caseData,\n attribution: attributionData\n };\n}", "code_description": null, "fill_type": "FUNCTION_TYPE", "language_type": "javascript", "sub_task_type": null}, "context_code": [["/awesome-gpt4o-images/gen-tool/src/i18n/lang.js", "const langs = {\n 'zh': {\n 'colon': ':',\n 'case_caption': '案例',\n 'case_toc_caption': '案例目录',\n 'prompt_caption': '提示词',\n 'source_link_caption': '原文链接',\n 'prompt_note_caption': '注意:',\n 'reference_note_caption': '需上传参考图片:',\n 'submitter_caption': '案例提交:',\n 'return_to_cases_toc_caption': '返回案例目录',\n },\n 'en': {\n 'colon': ': ',\n 'case_caption': 'Case',\n 'case_toc_caption': 'Cases Directory',\n 'prompt_caption': 'Prompt',\n 'source_link_caption': 'Source Link',\n 'prompt_note_caption': 'Note:',\n 'reference_note_caption': 'Reference Image Required:',\n 'submitter_caption': 'Submitter:',\n 'return_to_cases_toc_caption': 'Back to Cases Directory',\n },\n};\n\nexport default langs;\n"]], "task_instance_info": {"created_time": "2025-08-20 23:56:38", "created_task_model": "DeepSeek-R1", "function_skeleton": "dir => {}", "code_description": "This code segment functions to: Process numeric directories by loading associated configuration files, extract structured data from multiple sources, and aggregate metadata and content references into standardized objects for subsequent template rendering."}, "inference_content": {"inference_model": "DeepSeek-R1", "inference_result": "```javascript\n[TASK_BEGIN]\ndir => {\n const casePath = path.join(__dirname, '../../cases', dir, 'case.yml');\n try {\n const fileContent = fs.readFileSync(casePath, 'utf8');\n const caseData = yaml.load(fileContent);\n return { ...caseData, case_no: parseInt(dir, 10) };\n } catch (e) {\n console.error(`Error processing case ${dir}: ${e.message}`);\n return null;\n }\n}\n[TASK_END]\n```", "inference_time": "2025-08-20 23-57-29"}, "editdistance_info": {"edit_distance": 28.7037, "calculate_time": "2025-08-20 23:57:29", "true_code_clean": "dir => {\n const caseNumber = parseInt(dir);\n const casePath = path.join(__dirname, '../../cases', dir, 'case.yml');\n const caseData = yaml.load(fs.readFileSync(casePath, 'utf8'));\n const attributionPath = path.join(__dirname, '../../cases', dir, 'ATTRIBUTION.yml');\n const attributionData = yaml.load(fs.readFileSync(attributionPath, 'utf8'));\n return {\n case_no: caseNumber,\n ...caseData,\n attribution: attributionData\n };\n}", "predict_code_clean": "dir => {\n const casePath = path.join(__dirname, '../../cases', dir, 'case.yml');\n try {\n const fileContent = fs.readFileSync(casePath, 'utf8');\n const caseData = yaml.load(fileContent);\n return { ...caseData, case_no: parseInt(dir, 10) };\n } catch (e) {\n console.error(`Error processing case ${dir}: ${e.message}`);\n return null;\n }\n}"}}