Пример #1
0
    def test_changing_tag_then_def_mapping(self):
        def_dict = DefDict()
        def_string = HedString(self.basic_definition_string)
        def_string.convert_to_canonical_forms(None)
        def_dict.check_for_definitions(def_string)
        def_mapper = DefinitionMapper(def_dict)
        validator = HedValidator(self.hed_schema)
        validators = [validator, def_mapper]

        test_string = HedString(self.label_def_string)
        tag = test_string.get_direct_children()[0]
        tag.tag = "Organizational-property/" + str(tag)
        def_issues = test_string.validate(validators, expand_defs=True)
        self.assertFalse(def_issues)
        self.assertEqual(test_string.get_as_short(), f"{self.expanded_def_string}")

        test_string = HedString(self.label_def_string)
        tag = test_string.get_direct_children()[0]
        tag.tag = "Organizational-property22/" + str(tag)
        def_issues = test_string.validate(validators, expand_defs=True)
        self.assertTrue(def_issues)
Пример #2
0
 def test_group_tags(self):
     hed_string = '/Action/Reach/To touch,(/Attribute/Object side/Left,/Participant/Effect/Body part/Arm),' \
                  '/Attribute/Location/Screen/Top/70 px,/Attribute/Location/Screen/Left/23 px '
     string_obj = HedString(hed_string)
     # result = HedString.split_hed_string_into_groups(hed_string)
     tags_as_strings = [
         str(tag) for tag in string_obj.get_direct_children()
     ]
     self.assertCountEqual(tags_as_strings, [
         '/Action/Reach/To touch',
         '(/Attribute/Object side/Left,/Participant/Effect/Body part/Arm)',
         '/Attribute/Location/Screen/Top/70 px',
         '/Attribute/Location/Screen/Left/23 px'
     ])