"""Parse the output text.
        Args:
            text (str): The output text to parse.
        Returns:
            Dict: The parsed output.
        """
        verdict = None
        score = None
        match_last = re.search(r"\s*(Y|N)\s*$", text, re.IGNORECASE)
        match_first = re.search(r"^\s*(Y|N)\s*", text, re.IGNORECASE)
        match_end = re.search(r"\b(Y|N)\b\s*$", text, re.IGNORECASE)
        if match_last:
            verdict = match_last.group(1).strip()
            text = text[: match_last.start()].strip()
        elif match_first:
            verdict = match_first.group(1).strip()
            text = text[match_first.end() :].strip()
        elif match_end:
            verdict = match_end.group(1).strip()
            text = text[: match_end.start()].strip()
        else:
            splits = text.strip().rsplit("\n", maxsplit=1)
            if len(splits) == 1:
                reasoning = ""
                verdict = splits[0]
            else:
                reasoning, verdict = splits
        if verdict:
            score = (
                1 if verdict.upper() == "Y" else (0 if verdict.upper() == "N" else None)
            )
        return {
            "reasoning": text.strip(),
            "value": verdict,
            "score": score,
        }
CRITERIA_TYPE = Union[
    Mapping[str, str],
    Criteria,
    ConstitutionalPrinciple,
]
[docs]def resolve_criteria(
    criteria: Optional[Union[CRITERIA_TYPE, str]],
) -> Dict[str, str]: