def test_come(language_mode, learner): movee = standard_object( "movee", required_properties=[SELF_MOVING], banned_properties=[IS_SPEAKER, IS_ADDRESSEE], ) learner_obj = standard_object("leaner_0", LEARNER) speaker = standard_object( "speaker", PERSON, banned_properties=[IS_SPEAKER, IS_ADDRESSEE], added_properties=[IS_SPEAKER], ) object_ = standard_object("object_0", THING, banned_properties=[IS_SPEAKER, IS_ADDRESSEE]) ground = standard_object("ground", root_node=GROUND) come_to_speaker = Phase1SituationTemplate( "come-to-speaker", salient_object_variables=[movee, speaker], actions=[ Action(COME, argument_roles_to_fillers=[(AGENT, movee), (GOAL, speaker)]) ], ) come_to_learner = Phase1SituationTemplate( "come-to-leaner", salient_object_variables=[movee], actions=[ Action(COME, argument_roles_to_fillers=[(AGENT, movee), (GOAL, learner_obj)]) ], ) come_to_object = Phase1SituationTemplate( "come-to-object", salient_object_variables=[movee, object_], actions=[ Action(COME, argument_roles_to_fillers=[(AGENT, movee), (GOAL, object_)]) ], ) for situation_template in [ _make_come_down_template(movee, object_, speaker, ground, immutableset()), come_to_speaker, come_to_learner, come_to_object, ]: run_verb_test( learner(language_mode), situation_template, language_generator=phase1_language_generator(language_mode), )
def test_gaze_specified(): cookie = situation_object(COOKIE) table = situation_object(TABLE) dad = situation_object(DAD) situation = HighLevelSemanticsSituation( ontology=GAILA_PHASE_1_ONTOLOGY, salient_objects=[cookie, table, dad], actions=[ Action(EAT, argument_roles_to_fillers=[(AGENT, dad), (PATIENT, cookie)]) ], gazed_objects=[cookie], ) perception = _PERCEPTION_GENERATOR.generate_perception( situation, chooser=RandomChooser.for_seed(0)) frame = perception.frames[0] cookie_perception = perception_with_handle(frame, "**cookie_0") dad_perception = perception_with_handle(frame, "**Dad_0") table_perception = perception_with_handle(frame, "**table_0") # only the cookie is gazed at, because the user said so. assert HasBinaryProperty(cookie_perception, GAZED_AT) in frame.property_assertions assert HasBinaryProperty(dad_perception, GAZED_AT) not in frame.property_assertions assert HasBinaryProperty(table_perception, GAZED_AT) not in frame.property_assertions
def make_mom_put_ball_on_table(): mom = situation_object(ontology_node=MOM) ball = situation_object(ontology_node=BALL) table = situation_object(ontology_node=TABLE) return HighLevelSemanticsSituation( ontology=GAILA_PHASE_1_ONTOLOGY, salient_objects=[mom, ball, table], actions=[ Action( PUT, ( (AGENT, mom), (THEME, ball), ( GOAL, Region( reference_object=table, distance=EXTERIOR_BUT_IN_CONTACT, direction=GRAVITATIONAL_UP, ), ), ), ) ], )
def test_no_region_in_gazed_objects(): putter = situation_object(MOM) object_put = situation_object(BALL) on_region_object = situation_object(TABLE) situation = HighLevelSemanticsSituation( salient_objects=[putter, object_put, on_region_object], actions=[ Action( PUT, argument_roles_to_fillers=[ (AGENT, putter), (THEME, object_put), ( GOAL, Region( on_region_object, distance=EXTERIOR_BUT_IN_CONTACT, direction=GRAVITATIONAL_UP, ), ), ], ) ], ontology=GAILA_PHASE_1_ONTOLOGY, ) assert situation.gazed_objects for object_ in situation.gazed_objects: assert not isinstance(object_, Region)
def _put_on_body_part_template( # X puts Y on body part agent: TemplateObjectVariable, theme: TemplateObjectVariable, goal_reference: TemplateObjectVariable, background: Iterable[TemplateObjectVariable], ) -> Phase1SituationTemplate: return Phase1SituationTemplate( f"{agent.handle}-puts-{theme.handle}-on-{goal_reference.handle}", salient_object_variables=[agent, theme, goal_reference], background_object_variables=background, actions=[ Action( PUT, argument_roles_to_fillers=[ (AGENT, agent), (THEME, theme), ( GOAL, Region( goal_reference, distance=EXTERIOR_BUT_IN_CONTACT, direction=GRAVITATIONAL_UP, ), ), ], ) ], constraining_relations=flatten_relations( bigger_than([agent, goal_reference], theme) ), asserted_always_relations=flatten_relations(has(agent, goal_reference)), )
def make_bird_flies_over_a_house(): bird = situation_object(BIRD) house = situation_object(HOUSE) situation = HighLevelSemanticsSituation( ontology=GAILA_PHASE_1_ONTOLOGY, salient_objects=[bird, house], actions=[ Action( FLY, argument_roles_to_fillers=[(AGENT, bird)], during=DuringAction( at_some_point=[ Relation( IN_REGION, bird, Region( reference_object=house, distance=DISTAL, direction=Direction( positive=True, relative_to_axis=GRAVITATIONAL_AXIS_FUNCTION, ), ), ) ] ), ) ], ) return situation
def test_before_after_relations_asserted(): ball = object_variable("ball", root_node=BALL) box = object_variable("box", root_node=BOX) ground = object_variable("ground", root_node=GROUND) template_action = Phase1SituationTemplate( "Before/After Relation", salient_object_variables=[ball, box], background_object_variables=[ground], actions=[ Action( ROLL, argument_roles_to_fillers=[(AGENT, ball)], auxiliary_variable_bindings=[(ROLL_SURFACE_AUXILIARY, ground)], ) ], before_action_relations=flatten_relations([on(ball, box)]), after_action_relations=flatten_relations([far(ball, box)]), ) situation_with_relations = tuple( sampled( template_action, ontology=GAILA_PHASE_1_ONTOLOGY, chooser=RandomChooser.for_seed(0), max_to_sample=1, )) assert situation_with_relations[0].before_action_relations assert situation_with_relations[0].after_action_relations
def test_dynamic_prepositions_implicit_grounding(): truck = situation_object(ontology_node=TRUCK) baby = situation_object(ontology_node=BABY) situation = HighLevelSemanticsSituation( ontology=GAILA_PHASE_1_ONTOLOGY, salient_objects=[baby, truck], actions=[Action(FALL, argument_roles_to_fillers=[(THEME, baby)])], after_action_relations=[on(baby, truck)], ) perception = _PERCEPTION_GENERATOR.generate_perception( situation, chooser=RandomChooser.for_seed(0) ) first_frame = perception.frames[0] baby_perception = perception_with_handle(first_frame, "**baby_0") ground_perception = perception_with_handle(first_frame, "the ground") truck_perception = perception_with_handle(first_frame, "**truck_0") first_frame_relations = first_frame.relations second_frame_relations = perception.frames[1].relations assert on(baby_perception, truck_perception)[0] not in first_frame_relations assert on(baby_perception, truck_perception)[0] in second_frame_relations assert on(baby_perception, ground_perception)[0] not in second_frame_relations assert on(truck_perception, ground_perception)[0] in first_frame_relations assert on(truck_perception, ground_perception)[0] in second_frame_relations
def _go_under_template( agent: TemplateObjectVariable, goal_object: TemplateObjectVariable, background: Iterable[TemplateObjectVariable], *, is_distal: bool, # pylint:disable=unused-argument ) -> Phase1SituationTemplate: return Phase1SituationTemplate( f"go_under-{agent.handle}-under-{goal_object.handle}", salient_object_variables=[agent, goal_object], background_object_variables=background, actions=[ Action( GO, argument_roles_to_fillers=[ (AGENT, agent), ( GOAL, Region( goal_object, distance=PROXIMAL, direction=GRAVITATIONAL_DOWN ), ), ], ) ], before_action_relations=[negate(on(goal_object, GROUND_OBJECT_TEMPLATE))], asserted_always_relations=[negate(on(goal_object, GROUND_OBJECT_TEMPLATE))], after_action_relations=[ negate(on(goal_object, GROUND_OBJECT_TEMPLATE)), near(agent, goal_object), ], constraining_relations=flatten_relations(bigger_than(goal_object, agent)), )
def test_perceive_explicit_relations(): # we want to test that relations explicitly called out in the situation are perceived. # Such relations fall into three buckets: # those which hold before an action, # those which hold after an action, # and those which hold both before and after an action. # To test all three of these at once, we use a situation where # (a) Mom is putting a ball on a table # (b) before the action the ball is far from a box, # (c) but after the action the ball is near the box, # (d) throughout the action the box is on the table. mom = situation_object(MOM) ball = situation_object(BALL) box = situation_object(BOX) table = situation_object(TABLE) situation = HighLevelSemanticsSituation( ontology=GAILA_PHASE_1_ONTOLOGY, salient_objects=[mom, box, ball, table], always_relations=[on(ball, table)], before_action_relations=[far(ball, box)], after_action_relations=[near(ball, box)], actions=[ Action( PUT, argument_roles_to_fillers=[ (AGENT, mom), (THEME, ball), ( GOAL, Region( reference_object=table, distance=EXTERIOR_BUT_IN_CONTACT, direction=GRAVITATIONAL_UP, ), ), ], ) ], ) perception = _PERCEPTION_GENERATOR.generate_perception( situation, chooser=RandomChooser.for_seed(0) ) ball_perception = perception_with_handle(perception.frames[0], "**ball_0") box_perception = perception_with_handle(perception.frames[0], "**box_0") table_perception = perception_with_handle(perception.frames[0], "**table_0") assert only(on(ball_perception, table_perception)) in perception.frames[0].relations assert only(on(ball_perception, table_perception)) in perception.frames[0].relations assert only(far(ball_perception, box_perception)) in perception.frames[0].relations assert ( only(far(ball_perception, box_perception)) not in perception.frames[1].relations ) assert ( only(near(ball_perception, box_perception)) not in perception.frames[0].relations ) assert only(near(ball_perception, box_perception)) in perception.frames[1].relations
def _make_drink_cups_curriculum( num_samples: Optional[int], noise_objects: Optional[int], language_generator: LanguageGenerator[ HighLevelSemanticsSituation, LinearizedDependencyTree ], ) -> Phase1InstanceGroup: templates = [] for cup in [CUP, CUP_2, CUP_3, CUP_4]: cup_obj = standard_object("cup", cup) liquid_0 = object_variable("liquid_0", required_properties=[LIQUID]) person_0 = standard_object( "person_0", PERSON, banned_properties=[IS_SPEAKER, IS_ADDRESSEE] ) templates.append( Phase1SituationTemplate( "drink-cup", salient_object_variables=[liquid_0, person_0, cup_obj], background_object_variables=make_noise_objects(noise_objects), actions=[ Action( DRINK, argument_roles_to_fillers=[(AGENT, person_0), (THEME, liquid_0)], auxiliary_variable_bindings=[(DRINK_CONTAINER_AUX, cup_obj)], ) ], asserted_always_relations=[inside(liquid_0, cup_obj)], ) ) return phase2_instances( "drink - cup", chain( *[ sampled( cup_template, chooser=PHASE1_CHOOSER_FACTORY(), ontology=GAILA_PHASE_2_ONTOLOGY, max_to_sample=num_samples, block_multiple_of_the_same_type=True, ) if num_samples else all_possible( cup_template, chooser=PHASE1_CHOOSER_FACTORY(), ontology=GAILA_PHASE_2_ONTOLOGY, ) for cup_template in templates ] ), perception_generator=GAILA_PHASE_2_PERCEPTION_GENERATOR, language_generator=language_generator, )
def test_path_from_action_description(): ball = situation_object(BALL) situation = HighLevelSemanticsSituation( ontology=GAILA_PHASE_1_ONTOLOGY, salient_objects=[ball], actions=[Action(FALL, argument_roles_to_fillers=[(THEME, ball)])], ) perception = _PERCEPTION_GENERATOR.generate_perception( situation, chooser=RandomChooser.for_seed(0) ) ball_perception = perception_with_handle(perception.frames[0], "**ball_0") ground_perception = perception_with_handle(perception.frames[0], "the ground") assert perception.during assert perception.during.objects_to_paths assert len(perception.during.objects_to_paths) == 1 path = only(perception.during.objects_to_paths[ball_perception]) assert path.reference_object == ground_perception assert path.operator == TOWARD
def test_relations_between_objects_and_ground(): # person_put_ball_on_table person = situation_object(ontology_node=PERSON) ball = situation_object(ontology_node=BALL) table = situation_object(ontology_node=TABLE) situation = HighLevelSemanticsSituation( ontology=GAILA_PHASE_1_ONTOLOGY, salient_objects=[person, ball, table], actions=[ # What is the best way of representing the destination in the high-level semantics? # Here we represent it as indicating a relation which should be true. Action( PUT, ( (AGENT, person), (THEME, ball), ( GOAL, Region( reference_object=table, distance=EXTERIOR_BUT_IN_CONTACT, direction=GRAVITATIONAL_UP, ), ), ), ) ], ) perception = _PERCEPTION_GENERATOR.generate_perception( situation, chooser=RandomChooser.for_seed(0) ) first_frame = perception.frames[0] ball_perception = perception_with_handle(first_frame, "**ball_0") ground_perception = perception_with_handle(first_frame, "the ground") table_perception = perception_with_handle(first_frame, "**table_0") first_frame_relations = first_frame.relations second_frame_relations = perception.frames[1].relations assert on(ball_perception, ground_perception)[0] in first_frame_relations assert on(ball_perception, ground_perception)[0] not in second_frame_relations assert on(table_perception, ground_perception)[0] in first_frame_relations assert on(table_perception, ground_perception)[0] in second_frame_relations
def _instantiate_action( self, action: Action[_ExplicitOrVariableActionType, "TemplateObjectVariable"], object_var_to_instantiations: Mapping["TemplateObjectVariable", SituationObject], action_variables_to_fillers: Mapping["TemplateActionTypeVariable", OntologyNode], ) -> Action[OntologyNode, SituationObject]: def map_action_type() -> OntologyNode: if isinstance(action.action_type, OntologyNode): return action.action_type else: return action_variables_to_fillers[action.action_type] def map_action_variable_binding( x: Union[TemplateObjectVariable, TemplateRegion] ) -> Union[SituationObject, SituationRegion]: if isinstance(x, Region): return x.copy_remapping_objects(object_var_to_instantiations) else: return object_var_to_instantiations[x] # new_aux_bindings = [] # for (auxiliary_variable, auxiliary_variable_binding) in \ # action.auxiliary_variable_bindings.items(): # new_aux_bindings.append((auxiliary_variable, object_var_to_instantiations[auxiliary_variable_binding])) return Action( action_type=map_action_type(), argument_roles_to_fillers=[ (role, map_action_variable_binding(arg)) for (role, arg) in action.argument_roles_to_fillers.items() ], during=action.during.copy_remapping_objects( object_var_to_instantiations) if action.during else None, auxiliary_variable_bindings=[( auxiliary_variable, map_action_variable_binding(auxiliary_variable_binding), ) for ( auxiliary_variable, auxiliary_variable_binding, ) in action.auxiliary_variable_bindings.items()], )
def test_multiple_trecognized_particulars_banned(): with pytest.raises(RuntimeError): dad_0 = situation_object(DAD) dad_1 = situation_object(DAD) box = situation_object(BOX) HighLevelSemanticsSituation( salient_objects=[dad_0, dad_1, box], actions=[ Action( GIVE, argument_roles_to_fillers=[ (AGENT, dad_0), (THEME, box), (GOAL, dad_1), ], ) ], ontology=GAILA_PHASE_1_ONTOLOGY, )
def test_recognize_in_transfer_of_possession(language_mode): dad = object_variable("person_0", DAD) baby = object_variable("person_1", BABY) chair = object_variable("give_object_0", CHAIR) giving_template = Phase1SituationTemplate( "dad-transfer-of-possession", salient_object_variables=[dad, baby, chair], actions=[ Action( GIVE, argument_roles_to_fillers=[(AGENT, dad), (GOAL, baby), (THEME, chair)], ) ], syntax_hints=[PREFER_DITRANSITIVE], ) (_, _, perception) = first( phase1_instances( "foo", sampled( giving_template, max_to_sample=1, chooser=PHASE1_CHOOSER_FACTORY(), ontology=GAILA_PHASE_1_ONTOLOGY, block_multiple_of_the_same_type=True, ), ).instances()) perception_graph = PerceptionGraph.from_dynamic_perceptual_representation( perception) perception_semantic_alignment = PerceptionSemanticAlignment.create_unaligned( perception_graph) (_, description_to_matched_semantic_node ) = LANGUAGE_MODE_TO_OBJECT_RECOGNIZER[language_mode].match_objects( perception_semantic_alignment) assert len(description_to_matched_semantic_node) == 4 assert (language_mode == LanguageMode.ENGLISH and ("Dad", ) in description_to_matched_semantic_node) or ( language_mode == LanguageMode.CHINESE and ("ba4 ba4", ) in description_to_matched_semantic_node)
def _fly_over_template( # A bird flies over a ball agent: TemplateObjectVariable, object_in_path: TemplateObjectVariable, background: Iterable[TemplateObjectVariable], ) -> Phase1SituationTemplate: return Phase1SituationTemplate( f"{agent.handle}-flies-over-{object_in_path.handle}", salient_object_variables=[agent, object_in_path], background_object_variables=background, actions=[ Action( FLY, argument_roles_to_fillers=[(AGENT, agent)], during=DuringAction( at_some_point=flatten_relations(strictly_above(agent, object_in_path)) ), ) ], )
def _go_in_template( agent: TemplateObjectVariable, goal_object: TemplateObjectVariable, background: Iterable[TemplateObjectVariable], ) -> Phase1SituationTemplate: return Phase1SituationTemplate( f"go_in-{agent.handle}-in-{goal_object.handle}", salient_object_variables=[agent, goal_object], background_object_variables=background, actions=[ Action( GO, argument_roles_to_fillers=[ (AGENT, agent), (GOAL, Region(goal_object, distance=INTERIOR)), ], ) ], constraining_relations=flatten_relations(bigger_than(goal_object, agent)), after_action_relations=[inside(agent, goal_object)], )
def _go_to_template( agent: TemplateObjectVariable, goal_object: TemplateObjectVariable, background: Iterable[TemplateObjectVariable], ) -> Phase1SituationTemplate: return Phase1SituationTemplate( f"go_to-{agent.handle}-to-{goal_object.handle}", salient_object_variables=[agent, goal_object], background_object_variables=background, actions=[ Action( GO, argument_roles_to_fillers=[ (AGENT, agent), (GOAL, Region(goal_object, distance=PROXIMAL)), ], ) ], after_action_relations=[near(agent, goal_object)], gazed_objects=[agent], )
def _jump_over_template( # "Mom jumps over a ball" agent: TemplateObjectVariable, object_in_path: TemplateObjectVariable, background: Iterable[TemplateObjectVariable], ) -> Phase1SituationTemplate: return Phase1SituationTemplate( f"{agent.handle}-jumps-over-{object_in_path.handle}", salient_object_variables=[agent, object_in_path], background_object_variables=background, actions=[ Action( JUMP, argument_roles_to_fillers=[(AGENT, agent)], during=DuringAction( at_some_point=flatten_relations( strictly_above(agent, object_in_path) ), objects_to_paths=[ ( agent, SpatialPath( operator=VIA, reference_source_object=Region( object_in_path, direction=GRAVITATIONAL_UP, distance=DISTAL, ), reference_destination_object=GROUND_OBJECT_TEMPLATE, ), ) ], ), auxiliary_variable_bindings=[ (JUMP_INITIAL_SUPPORTER_AUX, GROUND_OBJECT_TEMPLATE) ], ) ], asserted_always_relations=[negate(on(agent, GROUND_OBJECT_TEMPLATE))], )
def _put_in_template( agent: TemplateObjectVariable, theme: TemplateObjectVariable, goal_reference: TemplateObjectVariable, background: Iterable[TemplateObjectVariable], ) -> Phase1SituationTemplate: return Phase1SituationTemplate( f"{agent.handle}-puts-{theme.handle}-in-{goal_reference.handle}", salient_object_variables=[agent, theme, goal_reference], background_object_variables=background, actions=[ Action( PUT, argument_roles_to_fillers=[ (AGENT, agent), (THEME, theme), (GOAL, Region(goal_reference, distance=INTERIOR)), ], ) ], constraining_relations=flatten_relations(bigger_than(goal_reference, theme)), )
def _fly_under_template( # A bird flies under a chair agent: TemplateObjectVariable, object_in_path: TemplateObjectVariable, background: Iterable[TemplateObjectVariable], ) -> Phase1SituationTemplate: return Phase1SituationTemplate( f"{agent.handle}-flies-under-{object_in_path.handle}", salient_object_variables=[agent, object_in_path], background_object_variables=background, actions=[ Action( FLY, argument_roles_to_fillers=[(AGENT, agent)], during=DuringAction( at_some_point=flatten_relations(strictly_above(object_in_path, agent)) ), ) ], asserted_always_relations=[negate(on(object_in_path, GROUND_OBJECT_TEMPLATE))], before_action_relations=[negate(on(object_in_path, GROUND_OBJECT_TEMPLATE))], after_action_relations=[negate(on(object_in_path, GROUND_OBJECT_TEMPLATE))], constraining_relations=flatten_relations(bigger_than(object_in_path, agent)), )
def test_person_put_ball_on_table(): person = situation_object(ontology_node=PERSON) ball = situation_object(ontology_node=BALL) table = situation_object(ontology_node=TABLE) situation = HighLevelSemanticsSituation( ontology=GAILA_PHASE_1_ONTOLOGY, salient_objects=[person, ball, table], actions=[ # What is the best way of representing the destination in the high-level semantics? # Here we represent it as indicating a relation which should be true. Action( PUT, ( (AGENT, person), (THEME, ball), ( GOAL, Region( reference_object=table, distance=EXTERIOR_BUT_IN_CONTACT, direction=GRAVITATIONAL_UP, ), ), ), ) ], ) perception = _PERCEPTION_GENERATOR.generate_perception( situation, chooser=RandomChooser.for_seed(0) ) assert len(perception.frames) == 2 first_frame = perception.frames[0] person_perception = perception_with_handle(first_frame, "**person_0") ball_perception = perception_with_handle(first_frame, "**ball_0") table_perception = perception_with_handle(first_frame, "**table_0") hand_perception = perception_with_handle(first_frame, "**hand_0") assert ( HasBinaryProperty(person_perception, ANIMATE) in first_frame.property_assertions ) assert ( HasBinaryProperty(person_perception, SELF_MOVING) in first_frame.property_assertions ) assert ( HasBinaryProperty(ball_perception, INANIMATE) in first_frame.property_assertions ) assert ( HasBinaryProperty(table_perception, INANIMATE) in first_frame.property_assertions ) first_frame_relations = first_frame.relations second_frame_relations = perception.frames[1].relations # assert we generate at least some relations in each frame assert first_frame_relations assert second_frame_relations assert ( Relation(SMALLER_THAN, ball_perception, person_perception) in first_frame_relations ) # Disabled because of https://github.com/isi-vista/adam/issues/673 # assert Relation(PART_OF, hand_perception, person_perception) in first_frame_relations assert ( Relation( IN_REGION, ball_perception, Region(reference_object=hand_perception, distance=EXTERIOR_BUT_IN_CONTACT), ) in first_frame_relations ) # continuing relations: assert ( Relation(SMALLER_THAN, ball_perception, person_perception) in second_frame_relations ) # new relations: ball_on_table_relation = Relation( IN_REGION, ball_perception, Region( table_perception, distance=EXTERIOR_BUT_IN_CONTACT, direction=GRAVITATIONAL_UP ), ) assert ball_on_table_relation in second_frame_relations # removed relations: assert ( Relation( IN_REGION, ball_perception, Region(reference_object=hand_perception, distance=EXTERIOR_BUT_IN_CONTACT), ) not in second_frame_relations ) # proto-role properties assert ( HasBinaryProperty(person_perception, VOLITIONALLY_INVOLVED) in first_frame.property_assertions ) assert ( HasBinaryProperty(person_perception, CAUSES_CHANGE) in first_frame.property_assertions ) assert ( HasBinaryProperty(ball_perception, UNDERGOES_CHANGE) in first_frame.property_assertions ) assert ( HasBinaryProperty(table_perception, STATIONARY) in first_frame.property_assertions )
def make_eat_big_small_curriculum( # pylint: disable=unused-argument num_samples: Optional[int], noise_objects: Optional[int], language_generator: LanguageGenerator[HighLevelSemanticsSituation, LinearizedDependencyTree], ) -> Phase1InstanceGroup: # "Mom eats a big cookie" # We generate situations directly since templates fail to generate plurals. learner = SituationObject.instantiate_ontology_node( ontology_node=LEARNER, debug_handle=LEARNER.handle, ontology=GAILA_PHASE_1_ONTOLOGY, ) situations = [] for eater_ontology_node in [MOM, DAD, BABY, DOG]: eater = SituationObject.instantiate_ontology_node( ontology_node=eater_ontology_node, debug_handle=eater_ontology_node.handle, ontology=GAILA_PHASE_1_ONTOLOGY, ) for _object in [COOKIE, WATERMELON]: object_to_eat = SituationObject.instantiate_ontology_node( ontology_node=_object, debug_handle=_object.handle, ontology=GAILA_PHASE_1_ONTOLOGY, ) other_edibles = [ SituationObject.instantiate_ontology_node( ontology_node=_object, debug_handle=_object.handle + f"_{i}", ontology=GAILA_PHASE_1_ONTOLOGY, ) for i in range(3) ] computed_background = [learner] computed_background.extend(other_edibles) # Big for relation_list in [ [ bigger_than(object_to_eat, learner), bigger_than(object_to_eat, other_edibles), ], [ bigger_than(learner, object_to_eat), bigger_than(other_edibles, object_to_eat), ], ]: situations.append( HighLevelSemanticsSituation( ontology=GAILA_PHASE_1_ONTOLOGY, salient_objects=[eater, object_to_eat], other_objects=computed_background, actions=[ Action( EAT, argument_roles_to_fillers=[ (AGENT, eater), (PATIENT, object_to_eat), ], ) ], always_relations=relation_list, )) return phase1_instances("Big - Small Curriculum", situations, language_generator=language_generator)
def make_spin_tall_short_curriculum( # pylint: disable=unused-argument num_samples: Optional[int], noise_objects: Optional[int], language_generator: LanguageGenerator[HighLevelSemanticsSituation, LinearizedDependencyTree], ) -> Phase1InstanceGroup: # "Mom spins a tall chair" # We generate situations directly since templates fail to generate plurals. learner = SituationObject.instantiate_ontology_node( ontology_node=LEARNER, debug_handle=LEARNER.handle, ontology=GAILA_PHASE_1_ONTOLOGY, ) situations = [] for agent_ontology_node in [MOM, DAD, BABY, DOG]: agent = SituationObject.instantiate_ontology_node( ontology_node=agent_ontology_node, debug_handle=agent_ontology_node.handle, ontology=GAILA_PHASE_1_ONTOLOGY, ) for _object in [CHAIR, TABLE]: theme = SituationObject.instantiate_ontology_node( ontology_node=_object, debug_handle=_object.handle, ontology=GAILA_PHASE_1_ONTOLOGY, ) other_objs = [ SituationObject.instantiate_ontology_node( ontology_node=_object, debug_handle=_object.handle + f"_{i}", ontology=GAILA_PHASE_1_ONTOLOGY, ) for i in range(3) ] computed_background = [learner] computed_background.extend(other_objs) # Tall and short for relation_list in [ [bigger_than(learner, theme), bigger_than(other_objs, theme)], [bigger_than(theme, learner), bigger_than(theme, other_objs)], ]: situations.append( HighLevelSemanticsSituation( ontology=GAILA_PHASE_1_ONTOLOGY, salient_objects=[agent, theme], other_objects=computed_background, actions=[ Action( SPIN, argument_roles_to_fillers=[ (AGENT, agent), (THEME, theme), ], ) ], always_relations=relation_list, syntax_hints=[USE_VERTICAL_MODIFIERS], )) return phase1_instances("Tall - Short Curriculum", situations, language_generator=language_generator)