rdflib
rdflib copied to clipboard
The default graph should have no name.
According to https://www.w3.org/TR/rdf11-concepts/#section-dataset
An RDF dataset is a collection of RDF graphs, and comprises:
In RDFLib however:
- The default context in ConjunctiveGraph has a BNode as name.
- The default context in Dataset has a IRI as a name.
Related issues:
- https://github.com/RDFLib/rdflib/issues/2021
According to https://www.w3.org/TR/rdf11-concepts/#section-dataset
The default graph does not have a name and may be empty.
I encountered this in my explorations of a solution ...
In RDFLib however:
* The default context in ConjunctiveGraph has a BNode as name.
If the entire class is to be deprecated, issue can be ignored
* The default context in Dataset has a IRI as a name.
Doesn't seem to present an issue for the API: exclude the URI from list(Dataset.contexts())
but include the Graph
object in list(Dataset.graphs())
and I've found the Dataset.default_graph
reference to be convenient.
OTOH, the Store API could be changed. AIUI RDFLib now has only context-aware Stores and I believe that uncontextualized statements are just quads with NULL as the fourth element (ISTR it's implemented with "" as a key).
FWIW, I have a static-rebuild motivation for requesting this change too. I think.
I include built graph files as part of unit test output, and version-control those files to show result evolution. One of those generated formats is JSON-LD. If I try to write the least code possible and use rdfpipe
to handle joining or format-converting graph files, I end up with an artifact that's a bit of a nuisance for independent results reproduction. The path to the input file is embedded in the output as what I thought would be the "default" graph's IRI. For instance, one workflow I just tried took a single Turtle file as input, converted it with rdfpipe --output-format json-ld in.ttl > out.json
, and I got this form of output (excerpted):
[
{
"@graph": [
{
"@id": "http://example.org/kb/[snip]",
"@type": [
"http://example.org/ontology/[snip]"
]
}
]
"@id": "file:///private/tmp/[snip]/result.ttl"
}
]
Is this rdfpipe
behavior in scope of this issue about the name of the default graph, or should I re-file this as a separate request for new flags to tune rdfpipe
's JSON-LD output? I'm guessing this could also be a quads issue.
For instance, one workflow I just tried took a single Turtle file as input, converted it with
rdfpipe --output-format json-ld in.ttl > out.json
, and I got this form of output (excerpted):[ { "@graph": [ { "@id": "http://example.org/kb/[snip]", "@type": [ "http://example.org/ontology/[snip]" ] } ] "@id": "file:///private/tmp/[snip]/result.ttl" } ]
Is this
rdfpipe
behavior in scope of this issue about the name of the default graph, or should I re-file this as a separate request for new flags to tunerdfpipe
's JSON-LD output? I'm guessing this could also be a quads issue.
I think this was fixed in this PR:
- https://github.com/RDFLib/rdflib/pull/2406
It would be worth checking the behaviour with the master branch, I think you can use pipx to run it without installing.
I think this was fixed in this PR:
It would be worth checking the behaviour with the master branch, I think you can use pipx to run it without installing.
@aucampia - You are correct, my issue is addressed in the current main
branch. Thank you for informing me!