-
Notifications
You must be signed in to change notification settings - Fork 579
Open
Labels
bugSomething isn't workingSomething isn't workingconcept: RDF datasetRelates to the RDF datasets concept.Relates to the RDF datasets concept.concept: default graphcoreRelates to core functionality of RDFLib, i.e. `rdflib.{graph,store,term}`Relates to core functionality of RDFLib, i.e. `rdflib.{graph,store,term}`
Description
At the moment there are a few key issues with the current rdflib.Dataset
, particularly in its handling of parsing Default Graph triples. I am very interested in working on a Pull Request to solve these issues since it will improve Named Graph support for all projects making use of rdflib
.
Key issues with rdflib.Dataset
:
- Parsed default graph triples are put under a randomized Blank Node named graph.
- Serializing a
rdflib.Dataset
toapplication/n-quads
orapplication/trig
will always place default graph triples under a Blank Node named graph. - There is no way of accessing only the default graph in a
rdflib.Dataset
. - The default format for
Dataset().parse(data=...)
istext/turtle
when it really should beapplication/trig
.
By adding a new term rdflib.term.DefaultGraph
, we can handle the serialization of these triples independent from Named Graph triples. Additionally, we should be able to access the default graph by specifying the following:
from rdflib import Dataset
from rdflib.term import DefaultGraph
ds = Dataset()
trig_string = (
'<dg:s> <dg:p> <dg:o>. '
'GRAPH <ng:g> { <ng:s> <ng:p> <ng:o>. }'
)
ds.parse(data=trig_string, format="trig")
default_graph = ds.graph(DefaultGraph)
for triple in default_graph:
print(triple)
(rdflib.term.URIRef('dg:s'), rdflib.term.URIRef('dg:p'), rdflib.term.URIRef('dg:o'))
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingconcept: RDF datasetRelates to the RDF datasets concept.Relates to the RDF datasets concept.concept: default graphcoreRelates to core functionality of RDFLib, i.e. `rdflib.{graph,store,term}`Relates to core functionality of RDFLib, i.e. `rdflib.{graph,store,term}`