mirror of
https://github.com/open-thought/reasoning-gym.git
synced 2026-04-25 17:10:51 +00:00
docs
This commit is contained in:
parent
7f611c2e0e
commit
dc6f6a4e7e
1 changed files with 4 additions and 0 deletions
|
|
@ -81,9 +81,12 @@ class GroupAnagramsDataset(ProceduralDataset):
|
||||||
return words
|
return words
|
||||||
|
|
||||||
def _sort_nested_list(self, lst: list[list[str]]) -> list[list[str]]:
|
def _sort_nested_list(self, lst: list[list[str]]) -> list[list[str]]:
|
||||||
|
"""Sort a nested list of strings"""
|
||||||
return sorted([sorted(sublist) for sublist in lst], key=lambda x: x[0] if x else "")
|
return sorted([sorted(sublist) for sublist in lst], key=lambda x: x[0] if x else "")
|
||||||
|
|
||||||
def _group_anagrams(self, words: list[str]) -> list[list[str]]:
|
def _group_anagrams(self, words: list[str]) -> list[list[str]]:
|
||||||
|
"""Group anagrams together"""
|
||||||
|
|
||||||
def _codify(word):
|
def _codify(word):
|
||||||
code = [0] * 26
|
code = [0] * 26
|
||||||
for c in word:
|
for c in word:
|
||||||
|
|
@ -99,6 +102,7 @@ class GroupAnagramsDataset(ProceduralDataset):
|
||||||
return self._sort_nested_list(anagrams)
|
return self._sort_nested_list(anagrams)
|
||||||
|
|
||||||
def score_answer(self, answer: Optional[str], entry: Dict[str, any]) -> float:
|
def score_answer(self, answer: Optional[str], entry: Dict[str, any]) -> float:
|
||||||
|
"""Score a single Group Anagrams question"""
|
||||||
reward = 0
|
reward = 0
|
||||||
if answer is not None:
|
if answer is not None:
|
||||||
answer = json.loads(answer)
|
answer = json.loads(answer)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue