first commit

This commit is contained in:
2026-03-21 09:12:47 +08:00
commit a1e76157c9
80 changed files with 506309 additions and 0 deletions

52
translate_questions.py Normal file
View File

@@ -0,0 +1,52 @@
#!/usr/bin/env python3
"""
翻译题目内容
"""
import json
import os
import re
def translate_text(text):
"""
翻译文本 - 使用简单的词典替换方式
这里提供一个框架实际翻译需要使用翻译API
"""
return text
def translate_questions(input_file, output_file):
"""
翻译所有题目
"""
with open(input_file, 'r', encoding='utf-8') as f:
questions = json.load(f)
translated_questions = []
for q in questions:
translated_q = {
'topic': q['topic'],
'question_num': q['question_num'],
'stem_en': q['stem'],
'stem_cn': translate_text(q['stem']),
'options': [],
'answer': q['answer']
}
for opt in q['options']:
translated_q['options'].append({
'label': opt['label'],
'text_en': opt['text'],
'text_cn': translate_text(opt['text'])
})
translated_questions.append(translated_q)
with open(output_file, 'w', encoding='utf-8') as f:
json.dump(translated_questions, f, ensure_ascii=False, indent=2)
print(f"翻译完成,保存到: {output_file}")
if __name__ == '__main__':
input_file = '/Users/duguoyou/D365/exam_data/questions.json'
output_file = '/Users/duguoyou/D365/exam_data/questions_translated.json'
translate_questions(input_file, output_file)