1616import networkx as nx
1717from curies import ReferenceTuple
1818from curies .preprocessing import BlocklistError
19- from curies .vocabulary import SynonymScope
19+ from curies .vocabulary import SynonymScope , xsd_datetime
2020from more_itertools import pairwise
2121from pystow .utils import open_zipfile , safe_open
2222from tqdm .auto import tqdm
4040)
4141from ..struct_utils import Annotation , Stanza
4242from ..typedef import default_typedefs , has_comment , has_ontology_root_term
43+ from ..vocabulary import term_tracker_item , xsd_uri
4344from ...constants import DATE_FORMAT , PROVENANCE_PREFIXES
4445from ...identifier_utils import (
4546 NotCURIEError ,
@@ -735,7 +736,6 @@ def _handle_xref(
735736
736737SUBSET_ERROR_COUNTER : Counter [tuple [str , str ]] = Counter ()
737738
738-
739739SubsetTypeDefs : TypeAlias = dict [Reference , str ]
740740
741741
@@ -1254,6 +1254,10 @@ def iterate_node_properties(
12541254
12551255UNHANDLED_PROPS : Counter [tuple [str , str ]] = Counter ()
12561256
1257+ PREDICATE_TO_DATATYPE = {
1258+ term_tracker_item : xsd_uri ,
1259+ }
1260+
12571261
12581262def _handle_prop (
12591263 prop_value_type : str ,
@@ -1286,7 +1290,9 @@ def _handle_prop(
12861290 value_type = value_type .strip ()
12871291 datatype : Reference | None
12881292 if " " not in value_type :
1289- value , datatype = value_type , None
1293+ value = value_type
1294+ # this automatically upgrades the datatype in some cases
1295+ datatype = PREDICATE_TO_DATATYPE .get (prop_reference )
12901296 else :
12911297 value , datatype_raw = (s .strip () for s in value_type .rsplit (" " , 1 ))
12921298 match _parse_str_or_curie_or_uri_helper (
@@ -1319,7 +1325,7 @@ def _handle_prop(
13191325
13201326 # first, special case datetimes. Whether it's quoted or not,
13211327 # we always deal with this first
1322- if datatype and datatype . curie == "xsd:dateTime" :
1328+ if datatype == xsd_datetime :
13231329 try :
13241330 obo_literal = OBOLiteral .datetime (value )
13251331 except ValueError :
@@ -1330,7 +1336,7 @@ def _handle_prop(
13301336 else :
13311337 return Annotation (prop_reference , obo_literal )
13321338
1333- if datatype and datatype . curie == "xsd:anyURI" :
1339+ if datatype == xsd_uri :
13341340 match _parse_str_or_curie_or_uri_helper (
13351341 value ,
13361342 node = node ,
0 commit comments