-
Notifications
You must be signed in to change notification settings - Fork 0
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
Update SPARQL grammar for reifier syntax #150
Conversation
Andy, thanks for adapting the grammar! I have added a few comments in my review. Additionally, I have the suspicion that there is an issue in the part of the grammar accepted by the For instance, the production accepts the expression
because it accepts a With that expression accepted by the
I don't think that makes sense, does it? Other weird-looking things that may be written are
(because
|
Those do look odd (and probably shouldn't be written like that), but they all (can) make sense. Here's that last one flattened a bit: ?x ?y ?id .
<< ?s ?p ?o ~ ?id >> .
<< ?x ?y ?id ~ ?id2 >> .
?id2 :p :o .
<< ?x ?y ?id ~ ?id3 >> . Here's some data with a similar shape, with readable symbol names to provide an informal indication of meaning: <Alice> :says << <Book> :mentions <Bob> ~ <speechact-1> >>
~ <recording-2> {| :mentions <Bob> |}
~ <recording-3> . Which is short for: <Alice> :says <speechact-1> .
<speechact-1> rdf:reifies <<( <Book> :mentions <Bob> )>> .
<recording-2> rdf:reifies <<( <Alice> :says <speechact-1> )>> .
<recording-2> :mentions <Bob> .
<recording-3> rdf:reifies <<( <Alice> :says <speechact-1> )>> . (Not something I'd put in a primer, but it might perhaps help out here.) |
Thanks @niklasl ! As mentioned, I was out for 4+ weeks and, thus, have missed the recent discussions that led to the change of the Turtle shorthand notations (switching from
Is this the agreed-upon version of the shorthand notation now? |
And for those of us not joining the semantics TF calls, is there a summary of the new syntax? I've seen it mentioned in passing in emails and on the main WG calls, but don't recall seeing an introduction or summary of the new proposed syntax. |
@hartig @kasei I think the discussions originated with w3c/rdf-star-wg#116 (referenced a couple of times on the list). It was worked through more in detail in w3c/rdf-turtle#51. There's now text and grammar in https://w3c.github.io/rdf-turtle/spec/#reified-triples (thanks to @gkellogg, @TallTed and @afs!). (It wasn't really part of the semantics discussions IIRC.) |
Thanks for the pointers Niklas! However:
The grammar in the Turtle doc is not updated yet, and the text talks only about the new version of the |
w3c/rdf-turtle#62 does update the annotation syntax, although there is only minimal narrative discussing this. In the case of the annotation syntax, we have the potential to have multiple reifiers and annotation blocks; this doesn't make sense for the reifiedTriple production as that's expected to generate just a single term when parsing. |
is not legal. Temporarily, the sparql.org query validator is now running a development version with the latest SPARQL grammar and it will show the generated triples. Testing has been "light" so far. The RDF-star features are not fully propagated though the codebase. Only SPARQL parse-to-print is likely to work. |
Thanks, @niklasl. I had missed the subsequent discussion of details (maybe overlooked because I wouldn't have thought the syntax across formats would be a Turtle PR…?), and so had wrongly assumed it was something that had been agreed to in the semantics TF call. Thanks for the pointers! |
In this case, my earlier comment about the |
You are right. I was looking at the current main-branch version of the Turtle spec that Niklas was pointing too.
I agree regarding the reifiedTriple production, and I can also see now that the annotation syntax in w3c/rdf-turtle#62 accepts multiple reifiers and annotation blocks, exactly as the ObjectPath production for SPARQL in this PR here. Now I wonder, however, why @afs says above that
is illegal. The grammar in this PR accepts it and, similarly, the grammar in w3c/rdf-turtle#62 accepts the following Turtle string.
|
The declaration form is illegal. I didn't mean to say the """ |
f234ca0
to
b3fcf9b
Compare
Okay, then we are in agreement regarding As for the declaration form ...
I see that the new SPARQL grammar in this PR does not accept this. In contrast, however, the new Turtle grammar in w3c/rdf-turtle#62 does! (without the curly braces, of course). In particular, the
The relevant case here is the third option ( |
I think that's OK (I don't have a turtle parser to check). There must be a cc @gkellogg |
Yes there must be a Instead, it was about only writing a string that matches the
In contrast, the SPARQL grammar in this PR does not accept this in a WHERE clause, such as the following.
|
That's legal. It does not have a refiier after the
A reifier after would apply to the triple from inside the
and hence the syntax is two triples:
The annotation rule of Turtle includes both a following reifier for a triple and the Illegal: reifier after:
Legal:
Same for Turtle if I read the BNF right and predicateObjectList is necessary to get to the annotation syntax. This will be easier when we have parsers and not have to read raw BNF! For SPARQL, I've updated sparql.org. |
Ah, yes, I see now. I overlooked that the
:-D Indeed! |
FWIW, I've updated LDTR (mainly a TriG-to-JSON-LD transcriber) to support this reifier syntax. Its LDTR demo app can be used to play with Turtle-star examples. (It's made using a PEG-based parser generator, so it should be on par with the ENBF. There are some rough corners though, and both the interface and visualization needs more love. Also, over in the JSON-LD WG we're in the process of updating JSON-LD-star, so it's still quite experimental.) |
I've updated my distiller with latest versions of N-Triples, N-Quads, and Turtle parsers. Note that another difference between the Turtle grammar and SPARQL grammar is that SPARQL allows the annotation delimiters without any actual predicate or object: SELECT * WHERE {
:s :p :o {| |} .
} The Turtle grammar requires there to be a :s :p :o {| :p1 :o1 |} You can achieve the same affect using a reifier instead of an annotation block: :s :p :o ~ |
The reason the SPARQL grammar has I'm happy to go either way - they should align. c.f. |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small, for clarity
Co-authored-by: Ted Thibodeau Jr <tthibodeau@openlinksw.com>
This PR updates the grammar table in section 19.8.
https://pr-preview.s3.amazonaws.com/w3c/sparql-query/pull/150.html#sparqlGrammar
Preview | Diff