Skip to content

nquads parser creates one context per triple in the default graph #535

Closed
@pchampin

Description

@pchampin

In nquads, the 4th component (graph id) of each line can be omitted, meaning that the triple belongs to the default graph.

Currently, the nquads parser puts every such triple in a different context, identified by a fresh BNode, which is clearly wrong.

E.g.:

from rdflib import ConjunctiveGraph, Dataset
from rdflib.parser import StringInputSource

ds = ConjunctiveGraph()

src = StringInputSource("""
<http://example.org/s1> <http://example.org/p1> <http://example.org/o1> .
<http://example.org/s2> <http://example.org/p2> <http://example.org/o2> .
<http://example.org/s3> <http://example.org/p3> <http://example.org/o3> <http://example.org/g3> .
""")

ds.parse(src, format="nquads")

assert len(ds) == 3, len(g)
assert len(list(ds.contexts())) == 2, len(list(ds.contexts()))

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions