Skip to content

Commit

Permalink
Improve the "replaced by" and "consider" term extraction (#209)
Browse files Browse the repository at this point in the history
* Extract the text, even if there are no attributes on that tag
* Add warning on missing datatype in `replaced_by` and `consider` RDF/XML parsing

---------

Co-authored-by: Martin Larralde <martin.larralde@embl.de>
  • Loading branch information
ebakke and althonos authored Aug 17, 2023
1 parent e07e1eb commit 608e148
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions pronto/parsers/rdfxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,13 @@ def _extract_term(self, elem: etree.Element, curies: Dict[str, str]):
iri = attrib[_NS["rdf"]["resource"]]
curie = curies.get(iri) or self._compact_id(iri)
termdata.replaced_by.add(curie)
elif _NS["rdf"]["datatype"] in attrib:
elif text is not None:
if _NS["rdf"]["datatype"] not in attrib:
warnings.warn(
"no datatype in `IAO:0100001` annotation",
SyntaxWarning,
stacklevel=2,
)
curie = curies.get(text) or self._compact_id(text)
termdata.replaced_by.add(curie)
else:
Expand All @@ -433,7 +439,13 @@ def _extract_term(self, elem: etree.Element, curies: Dict[str, str]):
iri = attrib[_NS["rdf"]["resource"]]
curie = curies.get(iri) or self._compact_id(iri)
termdata.consider.add(curie)
elif _NS["rdf"]["datatype"] in attrib:
elif text is not None:
if _NS["rdf"]["datatype"] not in attrib:
warnings.warn(
"no datatype in `oboInOwl:consider` annotation",
SyntaxWarning,
stacklevel=2,
)
curie = curies.get(text) or self._compact_id(text)
termdata.consider.add(curie)
else:
Expand Down

0 comments on commit 608e148

Please sign in to comment.