I noticed a problem when a rdfs:Datatype is defined as equivalent as a complement of another datatype.
For instance, if I have an OWL ontology with the following RDF-XML datatype, then it is not possible to parse the datatype by using owlready2.
<rdfs:Datatype rdf:about="http://example.org#example">
<owl:equivalentClass>
<rdfs:Datatype>
<owl:datatypeComplementOf rdf:resource="http://www.w3.org/2001/XMLSchema#integer"/>
</rdfs:Datatype>
</owl:equivalentClass>
<owl:equivalentClass>
<rdfs:Datatype>
<owl:intersectionOf rdf:parseType="Collection">
<rdf:Description rdf:about="http://www.w3.org/2002/07/owl#rational"/>
<rdfs:Datatype>
<owl:datatypeComplementOf rdf:resource="http://www.w3.org/2001/XMLSchema#integer"/>
</rdfs:Datatype>
</owl:intersectionOf>
</rdfs:Datatype>
</owl:equivalentClass>
</rdfs:Datatype>
File /opt/homebrew/lib/python3.11/site-packages/owlready2/class_construct.py:214, in LogicalClassConstruct.get_Classes(self)
[213] def get_Classes(self):
--> [214] if self._Classes is None: self._Classes = CallbackList(self.ontology._parse_list(self._list_bnode), self, LogicalClassConstruct._callback)
[215] return self._Classes
File /opt/homebrew/lib/python3.11/site-packages/owlready2/namespace.py:204, in _GraphManager._parse_list(self, bnode)
[202] while bnode and (bnode != rdf_nil):
[203] first, d = self._get_triple_sp_od(bnode, rdf_first)
--> [204] if not ((first == rdf_nil) and (d is None)): l.append(self._to_python(first, d))
[205] bnode = self._get_obj_triple_sp_o(bnode, rdf_rest)
[206] return l
File /opt/homebrew/lib/python3.11/site-packages/owlready2/namespace.py:217, in _GraphManager._to_python(self, o, d, main_type, main_onto, default_to_none)
[215] if d is None:
[216] if o is None: return None
--> [217] if o < 0: return self._parse_bnode(o)
[218] if o in _universal_abbrev_2_datatype: return _universal_abbrev_2_datatype[o]
[219] else: return self.world._get_by_storid(o, None, main_type, main_onto, None, default_to_none)
File /opt/homebrew/lib/python3.11/site-packages/owlready2/namespace.py:1322, in Ontology._parse_bnode(self, bnode)
[1316] break
[1317] #else:
[1318] # s = ""
[1319] # raise ValueError("Cannot parse blank node %s: unknown node type!")
[1320]
[1321] else: # Not a blank
-> [1322] r = self.world._get_by_storid(bnode, main_onto = self)
[1324] self._bnodes[bnode] = r
[1325] return r
File /opt/homebrew/lib/python3.11/site-packages/owlready2/namespace.py:650, in World._get_by_storid(self, storid, full_iri, main_type, main_onto, trace, default_to_none)
[647] if not entity is None: return entity
[649] try:
--> [650] return self._load_by_storid(storid, full_iri, main_type, main_onto, default_to_none)
[651] except RecursionError:
[652] return self._load_by_storid(storid, full_iri, main_type, main_onto, default_to_none, ())
File /opt/homebrew/lib/python3.11/site-packages/owlready2/namespace.py:777, in World._load_by_storid(self, storid, full_iri, main_type, main_onto, default_to_none, trace)
[775] elif main_type is Datatype:
[776] types = tuple(is_a_entities) or (Datatype,)
--> [777] entity = DatatypeClass(name, types, { "namespace" : namespace, "storid" : storid } )
[779] else:
[780] if default_to_none: return None
File /opt/homebrew/lib/python3.11/site-packages/owlready2/entity.py:145, in EntityClass.__new__(MetaClass, name, superclasses, obj_dict)
[136] _is_a = CallbackList(_is_a, None, MetaClass._class_is_a_changed)
[137] obj_dict.update(
[138] _name = name,
[139] namespace = namespace,
(...)
[142] _equivalent_to = None,
[143] )
--> [145] Class = namespace.world._entities[storid] = _is_a._obj = type.__new__(MetaClass, name, superclasses, obj_dict)
[146] _cache_entity(Class)
[148] if not LOADING:
TypeError: type.__new__() argument 1 must be str, not int
Hi, everyone!
I noticed a problem when a rdfs:Datatype is defined as equivalent as a complement of another datatype.
For instance, if I have an OWL ontology with the following RDF-XML datatype, then it is not possible to parse the datatype by using owlready2.
In particular, I get the following error: