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

Add support to create RDF* statements #305

Open
pajoma opened this issue Jan 8, 2024 · 5 comments
Open

Add support to create RDF* statements #305

pajoma opened this issue Jan 8, 2024 · 5 comments

Comments

@pajoma
Copy link

pajoma commented Jan 8, 2024

Is your feature request related to a problem? Please describe.
I am using RDF4J as backend with RDF* statements in the form

<triple> predicate value.

I am unable to convert these statements in RDFNQuads, since the subject is expected to be a RdfResource

Describe the solution you'd like
The RdfTriple interface could extend the RdfResource (example from RDF4J), to create RDFNQuads with RDF* semantics.

Describe alternatives you've considered
Not sure, for now I am filtering all RDF* statements.

@filip26
Copy link
Owner

filip26 commented Jan 8, 2024

@pajoma I'm sorry, but this project has nothing to do with RDF4J. Report the bug to RDF4J. Please feel free to re-open if there is something I'm missing.

@filip26 filip26 closed this as completed Jan 8, 2024
@pajoma
Copy link
Author

pajoma commented Jan 8, 2024

Sorry for the confusion, I just mentioned RDF4J as example.

The problem lies within the RDF Api of Titanium (RDFNQuads and Rdf Resource are Titanium Terms, nothing related to RDF4J)

@filip26
Copy link
Owner

filip26 commented Jan 8, 2024

Please, can you be more specific then? Why you cannot use the existing RDF API? RdfNQuad just extends RdfTriple of graph name which can be null.

@pajoma
Copy link
Author

pajoma commented Jan 8, 2024

Sure.

RDF statements are triples in the form <subject> <predicate> <object>.
RDF quads include the context: <subject> <predicate> <object> <graph>.

RDF* allows for expressing statements about statements (in subjects or objects):

<<subject> <predicate> <object>> <predicate> <object> or
<subject> <predicate> <<subject> <predicate> <object>>

A valid triple (let's forget about the graph for now) is therefore:
<Resource> <IRI> <Value> with

  • Resource being either a blank node, an IRI or a triple (RDF*)
  • Value being either a blank node, an IRI, a triple or a literal

You typically see this reflected in the class hierarchy, see RDFLib, Eclipse RDF4J or Apache Jena

In my application, I want to expose my triples as JSON-LD documents with RDF-Star statements. The implementation follows this pattern:

for each statement in the result model:

  1. convert the subject into a RdfResource
  2. convert the object into a RdfValue
  3. create a new RDFNQuad
  4. Add it to the new RdfDataset

And then I build a JsonLd Document

Document document = RdfDocument.of(myRdfDataset);
JsonArray jsonValues = JsonLd.fromRdf(document).options(myOptions).get();
JsonDocument jsonDocument = JsonDocument.of(jsonValues);
JsonObject jsonObject = JsonLd.frame(jsonDocument, myContectUri).options(myOptions).get();

The issue:
The RdfTriple class expects a RdfResource as subject (and a RdfValue as object). Since RDF* requires triples as subjects and objects, the Triple itself should be a RdfResource itself again.

I would expect the following class structure:

  • RdfValue
    • RdfLiteral
    • RdfResource
      • RdfTriple
        • RdfNQuad

Only then is it possible to create a new RDFNQuad with a triple either as subject or object (this should also include a check that it is actually a triple, and not another nquad)

@filip26 filip26 reopened this Jan 8, 2024
@filip26
Copy link
Owner

filip26 commented Jan 8, 2024

should be done after/together with/ #300

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants