fix(exam_pkg): v2补题去重与final已有题干交叉去重
补题阶段仅和exclude_stems去重,未检查final中已有题干, 可能补出重复题目。修复:收集final题干+exclude_stems合并传入 _deduplicate_questions,多题型补题时逐轮累积排除列表。
This commit is contained in:
@@ -1300,12 +1300,21 @@ def generate_questions_structured_v2(
|
||||
|
||||
if shortage_types:
|
||||
logger.info(f" [v2] 补题: 缺少题型 {dict(shortage_types)}")
|
||||
# 收集 final 中已有题干,补题时一并排除
|
||||
existing_stems = [q.get('content', {}).get('stem', '') for q in final if q.get('content', {}).get('stem')]
|
||||
combined_exclude = list(exclude_stems or []) + existing_stems
|
||||
|
||||
for q_type, shortage in shortage_types.items():
|
||||
logger.info(f" 补充 {q_type} {shortage} 道...")
|
||||
extra = generator._makeup_questions(chunks, q_type, shortage, difficulty, document_name)
|
||||
# 补题也需去重
|
||||
extra_deduped = _deduplicate_questions(extra, exclude_stems=exclude_stems)
|
||||
# 补题需与已有题目 + 跨调用排除列表一起去重
|
||||
extra_deduped = _deduplicate_questions(extra, exclude_stems=combined_exclude)
|
||||
final.extend(extra_deduped[:shortage])
|
||||
# 将新补的题干也加入排除列表,防止后续题型补出重复
|
||||
for q in extra_deduped:
|
||||
stem = q.get('content', {}).get('stem', '')
|
||||
if stem:
|
||||
combined_exclude.append(stem)
|
||||
|
||||
# 补题后重新统计
|
||||
type_counts = defaultdict(int)
|
||||
|
||||
Reference in New Issue
Block a user