Skip to content

Clarify confusion around type of context element in ConjunctiveGraphs and context aware stores #167

Open
@ghost

Description

gromgull, 2011-08-20T07:58:07.000Z

In the ConjunctiveGraph, the context field is assumed to be a graph with the identifier set to the URI of the context, i.e. this is what happens if you create context like this:

g=ConjunctiveGraph()
uri1=URIRef("http://example.org/mygraph1")
uri2=URIRef("http://example.org/mygraph2")

bob = URIRef(u'urn:bob')
likes = URIRef(u'urn:likes')
pizza = URIRef(u'urn:pizza')

g.get_context(uri1).add((bob, likes, pizza))
g.get_context(uri2).add((bob, likes, pizza))

Now g.contexts() returns a generator over some graphs.

Now, for code working on the store level, i.e. serializers and parsers, there should perhaps not be any graph objects?

I came across this when looking at the nquad parser, here:

https://github.com/RDFLib/rdflib/blob/master/rdflib/plugins/parsers/nquads.py#L106

This adds context as simply an URI ref.

I added a "work-around" to make the conjunctivegraph.contexts generator work "correctly" here:

https://github.com/RDFLib/rdflib/blob/master/rdflib/graph.py#L1075

Is this ok?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions