mirror of
https://github.com/open-thought/reasoning-gym.git
synced 2026-04-28 17:29:39 +00:00
refactor: Prevent duplicate child descriptions in family story generation
This commit is contained in:
parent
0c0eed31a3
commit
2b3b1a280d
1 changed files with 8 additions and 5 deletions
|
|
@ -218,14 +218,17 @@ class FamilyRelationshipsDataset(ProceduralDataset):
|
||||||
if person.spouse and (person.spouse, person) not in couples:
|
if person.spouse and (person.spouse, person) not in couples:
|
||||||
couples.add((person, person.spouse))
|
couples.add((person, person.spouse))
|
||||||
|
|
||||||
# Describe marriages
|
# Describe marriages and children for each couple
|
||||||
|
described_children = set() # Track which children have been described
|
||||||
for person1, person2 in couples:
|
for person1, person2 in couples:
|
||||||
story_parts.append(f"{person1.name} is married to {person2.name}.")
|
story_parts.append(f"{person1.name} is married to {person2.name}.")
|
||||||
|
|
||||||
# Describe parent-child relationships
|
# Only describe children once per couple
|
||||||
for person in family:
|
children = [c for c in person1.children if c not in described_children]
|
||||||
if person.children:
|
if children:
|
||||||
children_names = [c.name for c in person.children]
|
children_names = [c.name for c in children]
|
||||||
|
described_children.update(children) # Mark these children as described
|
||||||
|
|
||||||
if len(children_names) == 1:
|
if len(children_names) == 1:
|
||||||
story_parts.append(
|
story_parts.append(
|
||||||
f"They have a child called {children_names[0]}."
|
f"They have a child called {children_names[0]}."
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue