def normalize_multi_choice()

in yourbench/utils/parsing_engine.py [0:0]


def normalize_multi_choice(pair: dict[str, Any]) -> Optional[dict[str, Any]]:
    """
    Ensures multiple-choice questions are valid.
    Returns None if the entry should be skipped.
    """
    pair = dict(pair)
    mode = pair.get("question_mode", "").strip().lower()
    q_type = pair.get("question_type", "").strip().lower()

    if mode != "multi-choice":
        return pair

    if q_type not in MULTI_CHOICE_TYPES:
        logger.warning(f"Inconsistent multiple-choice question_type: '{q_type}'")
        return None

    choices = validate_list(pair.get("choices", []))
    if len(choices) != 4:
        logger.warning("MCQ must have exactly 4 choices.")
        return None

    pair["choices"] = choices
    return pair