rdfjs / N3.js

Lightning fast, spec-compatible, streaming RDF for JavaScript
http://rdf.js.org/N3.js/
Other
712 stars 130 forks source link

Support RDF-star in store #256

Open jeswr opened 3 years ago

jeswr commented 3 years ago

This may be a misunderstanding of the intended implementation of RDF* on my part.

To my understanding, if we have a quad (lets call it q1) that is the subject of another quad then q1 should still be treated normally as a quad. However, this does not appear to be the case in the example below.

const data = `
@prefix :    <http://www.example.org/> .
@prefix ex:    <http://www.example.org/> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .

<<:bob foaf:age 23>> ex:certainty 0.9 .
`

const store = new Store();
const parser = new Parser({ format: 'turtle*' });

store.addQuads(parser.parse(data));

// Expected: 2, Result: 1
store.size

// Expected: 2, Result: 1
store.getQuads(null, null, null, null).length

// Expected: 1, Result: 0
store.getQuads(namedNode('http://www.example.org/bob'), null, null, null).length

Here I would expect that the quad with the predicate foaf:age and the quad with the predicate ex:certainty both contribute to the count, and are both searched over in the store.getQuads call.

RubenVerborgh commented 3 years ago

The store doesn't do RDF-star yet as far as I recall.

rubensworks commented 3 years ago

AFAIK this is intended behaviour. Making a statement about something does not necessarily imply that statement. (Ruben says that cows are blue => cows are blue)

RubenVerborgh commented 3 years ago

I think there are two things here:

TallTed commented 3 years ago

All the rest of the above notwithstanding, RDF-star (still a draft-CG-report, not yet even a WG Editor's Draft) isn't expected to support quoted (a/k/a reified, embedded, or inline) quads; only triples are expected to be supported in this way.

uvdsl commented 2 years ago

I just noticed that the parser does not like RDF lists with RDF-star triples in it.

const data = `
@prefix :    <http://www.example.org/> .
@prefix ex:    <http://www.example.org/> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .

:alice ex:says ( <<:bob foaf:age 23>> ) .
`

I get a Error: Expected entity but got << on line 6..

I thought, I just mention it here :)