-
Notifications
You must be signed in to change notification settings - Fork 558
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clarify confusion around type of context element in ConjunctiveGraphs and context aware stores #167
Comments
I've semi-fixed this in the last two commits. If you work with the ConjunctiveGraph class directly: g = ConjunctiveGraph()
g.get_context('urn:1').add( ( s, p, o ) ) You end up with a Graph object in the store, with identifier set to the URIRef "urn:1". >>> g1=ConjunctiveGraph()
>>> g2=ConjunctiveGraph()
>>> g1.get_context('urn:a').add( (s, p, o) )
>>> g2.addN( (x,y,z, g1.get_context('urn:a') ) )
>>> g2.store != g2.get_context('urn:a').store
True Hmm ... In [43]: list(g1.contexts())[0]
Out[43]: <Graph identifier=urn:a (<class 'rdflib.graph.Graph'>)>
In [44]: list(list(g1.contexts())[0])
Out[44]:
[(rdflib.term.BNode('Nae2ff5ac0056427e852347e0a58ff925'),
rdflib.term.BNode('N7c8cbd571a51409e8a92c2870a30eddd'),
rdflib.term.BNode('Nbc486ecd9a5b46d5913dafdc4458fc3f'))]
In [45]: list(g1.get_context('urn:a'))
Out[45]:
[(rdflib.term.URIRef(u'a'),
rdflib.term.URIRef(u'b'),
rdflib.term.URIRef(u'c'))] This is no good :) |
Something else, whatever we decide - the |
Note that this is also observed when using ds = Dataset()
quads = ds.quads((None, None, None, None)) # Fourth term is identifier
store = SPARQLUpdateStore()
store.addN(quads) # Expects four term to be graph This seems to have been intended with #409 with the goal of reducing confusion for end users. My personal experience was a large amount of confusion that required me to review the code for both modules in order to identifying what was going wrong. As a semantic web developer I've been trained to always interpret The documentation for the referenced methods, their argument names, and their method names are all ambiguous and add to the confusion. If a developer has started working with one of the APIs first (i.e., they are exposed to I'd recommend that usage of |
- Once again adjusting for RDFLib/rdflib#167 not being resolved
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:
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?
The text was updated successfully, but these errors were encountered: