mirror of
https://github.com/open-thought/reasoning-gym.git
synced 2026-04-26 17:13:17 +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:
|
||||
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:
|
||||
story_parts.append(f"{person1.name} is married to {person2.name}.")
|
||||
|
||||
# Describe parent-child relationships
|
||||
for person in family:
|
||||
if person.children:
|
||||
children_names = [c.name for c in person.children]
|
||||
# Only describe children once per couple
|
||||
children = [c for c in person1.children if c not in described_children]
|
||||
if children:
|
||||
children_names = [c.name for c in children]
|
||||
described_children.update(children) # Mark these children as described
|
||||
|
||||
if len(children_names) == 1:
|
||||
story_parts.append(
|
||||
f"They have a child called {children_names[0]}."
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue