issue with BNode and _rdflib_2_owlready()

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

issue with BNode and _rdflib_2_owlready()

Peter
Hi List

I'm trying to get Owlready2 and RDFlib to work together and to add blank nodes.  I'm getting an error in the function "_rdflib_2_owlready" in module "rdflib_store"

line 59, in _rdflib_2_owlready
    elif isinstance(o, rdflib.term.BNode  ): o = -int(o); d = None
ValueError: invalid literal for int() with base 10: rdflib.term.BNode('Nf179a7c1aefe493cb64234cd8326bcde')

The BNode identifiers created by RDFlib in code such as

linda = BNode() #from the RDFlib documentation

generates a UUID.

Any suggestions?

Thanks
Peter
Reply | Threaded
Open this post in threaded view
|

Re: issue with BNode and _rdflib_2_owlready()

Jiba
Administrator
Hi,

I've just fixed the problem in the development version of Owlready on BitBucket.

You can now use blank node with RDFlib, however, you need to create the blank node with the new BNode() method of the graph object, as in the following example:


import rdflib
graph = default_world.as_rdflib_graph()

bn = graph.BNode()

with onto:
      graph.add((bn, rdflib.URIRef("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"), rdflib.URIRef("http://www.w3.org/2002/07/owl#Class")))


This is needed, because Owlready use numeric identifiers and not alphanumeric ones.

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: issue with BNode and _rdflib_2_owlready()

Peter
Thanks very much Jiba!