Files
d365scm/analyze_question_types.py
2026-03-22 09:52:58 +08:00

81 lines
2.5 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import json
import re
with open('exam_data/questions_translated.json', 'r', encoding='utf-8') as f:
questions = json.load(f)
# 分类统计
yes_no_questions = [] # 判断题
single_choice = [] # 单选题
multi_choice = [] # 多选题
drag_drop_questions = [] # 拖拽题
order_questions = [] # 排序题
case_questions = [] # 特殊case题
for q in questions:
options = q['options']
answer = q['answer']
stem = q['stem'].lower()
stem_cn = q.get('stem_cn', '').lower()
# 判断题只有2个选项且是Yes/No类型
if len(options) == 2:
opt_texts = [opt['text'].lower() for opt in options]
if any('yes' in t for t in opt_texts) or any('no' in t for t in opt_texts):
yes_no_questions.append(q)
continue
# 拖拽题:包含 drag, drop 关键词
if 'drag' in stem or 'drop' in stem or '拖拽' in stem_cn or '拖放' in stem_cn:
drag_drop_questions.append(q)
continue
# 排序题:包含 order, sequence, arrange 关键词
if 'order' in stem or 'sequence' in stem or 'arrange' in stem or '排序' in stem_cn or '顺序' in stem_cn:
order_questions.append(q)
continue
# 特殊case题包含 case, scenario 关键词
if 'case ' in stem or 'scenario' in stem or '案例' in stem_cn or '场景' in stem_cn:
case_questions.append(q)
continue
# 根据答案长度判断单选/多选
if len(answer) == 1:
single_choice.append(q)
else:
multi_choice.append(q)
print("=" * 50)
print("题目类型统计:")
print("=" * 50)
print(f"总题目数: {len(questions)}")
print(f"判断题 (Yes/No): {len(yes_no_questions)}")
print(f"拖拽题 (Drag/Drop): {len(drag_drop_questions)}")
print(f"排序题 (Order/Sequence): {len(order_questions)}")
print(f"特殊Case题: {len(case_questions)}")
print(f"单选题: {len(single_choice)}")
print(f"多选题: {len(multi_choice)}")
print()
# 显示各类型示例
print("=" * 50)
print("拖拽题示例:")
print("=" * 50)
for q in drag_drop_questions[:2]:
print(f"Topic {q['topic']} - Q{q['question_num']}: {q['stem'][:100]}...")
print()
print("=" * 50)
print("排序题示例:")
print("=" * 50)
for q in order_questions[:2]:
print(f"Topic {q['topic']} - Q{q['question_num']}: {q['stem'][:100]}...")
print()
print("=" * 50)
print("特殊Case题示例:")
print("=" * 50)
for q in case_questions[:2]:
print(f"Topic {q['topic']} - Q{q['question_num']}: {q['stem'][:100]}...")