Map a judge response to 1 (accept) or 0 (reject). The judge is asked to reason first and state its verdict last, so we use the last occurrence of "accept"/"reject" rather than a naive substring check.
(message: Optional[str])
| 119 | |
| 120 | |
| 121 | def parse_verdict(message: Optional[str]) -> int: |
| 122 | """Map a judge response to 1 (accept) or 0 (reject). |
| 123 | |
| 124 | The judge is asked to reason first and state its verdict last, so we use the |
| 125 | last occurrence of "accept"/"reject" rather than a naive substring check. |
| 126 | """ |
| 127 | if not message: |
| 128 | return 0 |
| 129 | text = message.lower() |
| 130 | accept_at = text.rfind("accept") |
| 131 | reject_at = text.rfind("reject") |
| 132 | if accept_at == -1 and reject_at == -1: |
| 133 | return 0 |
| 134 | return 1 if accept_at > reject_at else 0 |
| 135 | |
| 136 | |
| 137 | # --------------------------------------------------------------------------- # |