Skip to content

Commit

Permalink
Ontology fixes
Browse files Browse the repository at this point in the history
Leave equivalent to blank if it's the same as subclass of
fix missing )
  • Loading branch information
IanCa committed May 28, 2024
1 parent f38f9d5 commit 1c9d69e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion hed/schema/schema_io/ontology_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ def _convert_df_to_omn(df, annotation_properties=("",)):
equivalent_to = row[constants.equivalent_to]
equivalent_to = equivalent_to.replace(" and ", "\n\t\tand ")
subclass_of = row[constants.subclass_of]
if equivalent_to and equivalent_to != subclass_of:
if equivalent_to:
output_text += "\tEquivalentTo:\n"
output_text += f"\t\t{equivalent_to}"
else:
Expand Down
10 changes: 7 additions & 3 deletions hed/schema/schema_io/schema2df.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def _get_tag_equivalent_to(self, tag_entry):
if self._get_as_ids and found_range and found_range != HedKey.NumericRange:
section = self._schema[found_range]
if any(section.get(v) is None for v in values):
raise ValueError(f"Cannot find schema entry for {v}")
raise ValueError(f"Cannot find schema entry for {values}")
for v in values:
test_id = section.get(v).attributes.get(HedKey.HedID)
if not test_id:
Expand Down Expand Up @@ -278,9 +278,13 @@ def _get_tag_equivalent_to(self, tag_entry):
if self._get_as_ids:
attribute_strings.append(f"(hed:HED_0000102 some {schema_id})")
else:
attribute_strings.append(f"(inHedSchema some {schema_name}")
attribute_strings.append(f"(inHedSchema some {schema_name})")

return " and ".join([subclass] + attribute_strings)
# If they match, we want to leave equivalent_to blank
final_out = " and ".join([subclass] + attribute_strings)
if final_out == subclass:
return ""
return final_out

def _get_subclass_of(self, tag_entry):
# Special case for HedTag
Expand Down

0 comments on commit 1c9d69e

Please sign in to comment.