mirror of
https://github.com/open-thought/reasoning-gym.git
synced 2026-04-19 12:58:07 +00:00
clean up ransom note
This commit is contained in:
parent
02c1fdf304
commit
ab51228f35
2 changed files with 28 additions and 1 deletions
|
|
@ -7,7 +7,7 @@ https://leetcode.com/problems/ransom-note/description/
|
|||
from collections import defaultdict
|
||||
from dataclasses import dataclass
|
||||
from random import Random
|
||||
from typing import Optional
|
||||
from typing import Dict, Optional
|
||||
|
||||
from ..factory import ProceduralDataset, register_dataset
|
||||
|
||||
|
|
@ -95,5 +95,27 @@ class RansomNoteDataset(ProceduralDataset):
|
|||
"metadata": {"ransom_note": ransom_note, "magazine": magazine, "solution": answer, "solvable": solvable},
|
||||
}
|
||||
|
||||
def score_answer(self, answer: Optional[str], entry: Dict[str, any]) -> float:
|
||||
"""Determine if the solution provided solves this task.
|
||||
|
||||
The function awards 1.0 for a correct answer.
|
||||
|
||||
Args:
|
||||
answer (Optional[str]): The user's answer.
|
||||
entry (Dict[str, any]): The original dataset entry containing the correct answer.
|
||||
|
||||
Returns:
|
||||
float: The computed score between 0.0 and 1.0.
|
||||
"""
|
||||
|
||||
if answer == None:
|
||||
return 0.0
|
||||
|
||||
s_answer = answer.strip()
|
||||
if not s_answer == str(entry['answer']):
|
||||
return 0.01
|
||||
else:
|
||||
return 1.0
|
||||
|
||||
|
||||
register_dataset("ransom_note", RansomNoteDataset, RansomNoteConfig)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue