in yourbench/utils/parsing_engine.py [0:0]
def normalize_open_ended(pair: dict[str, Any]) -> Optional[dict[str, Any]]:
"""
Ensures open-ended questions are valid.
Returns None if the entry should be skipped.
"""
pair = dict(pair) # defensive copy
mode = pair.get("question_mode", "").strip().lower()
q_type = pair.get("question_type", "").strip().lower()
if mode != "open-ended":
return pair
if q_type not in OPEN_ENDED_TYPES:
logger.warning(f"Inconsistent open-ended question_type: '{q_type}'")
return None
# No choices for open-ended
pair["choices"] = []
answer = pair.get("answer", "").strip()
if len(answer) == 1 and answer.upper() in {"A", "B", "C", "D"}:
# Misclassified multiple choice
return None
return pair