Skip to content
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

The default graph should have no name. #2445

Open
aucampia opened this issue Jun 13, 2023 · 4 comments
Open

The default graph should have no name. #2445

aucampia opened this issue Jun 13, 2023 · 4 comments
Labels
breaking change This involves or proposes breaking RDFLib's public API. bug Something isn't working concept: default graph concept: RDF dataset Relates to the RDF datasets concept.

Comments

@aucampia
Copy link
Member

aucampia commented Jun 13, 2023

According to https://www.w3.org/TR/rdf11-concepts/#section-dataset

An RDF dataset is a collection of RDF graphs, and comprises:

  • Exactly one default graph, being an RDF graph. The default graph does not have a name and may be empty.
  • Zero or more named graphs. Each named graph is a pair consisting of an IRI or a blank node (the graph name), and an RDF graph. Graph names are unique within an RDF dataset.

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:

@aucampia aucampia added bug Something isn't working concept: RDF dataset Relates to the RDF datasets concept. breaking change This involves or proposes breaking RDFLib's public API. concept: default graph labels Jun 13, 2023
@ghost
Copy link

ghost commented Jun 13, 2023

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).

@ajnelson-nist
Copy link
Contributor

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.

@aucampia
Copy link
Member Author

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.

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.

@ajnelson-nist
Copy link
Contributor

ajnelson-nist commented Jun 22, 2023

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change This involves or proposes breaking RDFLib's public API. bug Something isn't working concept: default graph concept: RDF dataset Relates to the RDF datasets concept.
Projects
None yet
Development

No branches or pull requests

2 participants