TriplyDB / Yasgui

Yet Another Sparql GUI
https://yasgui.triply.cc
MIT License
178 stars 54 forks source link

Add support to SPARQL-Star #215

Open kinow opened 1 year ago

kinow commented 1 year ago

Closes #190

This draft pull request includes the commit from #214 , in order for the build to pass. If that other PR is merged, I will drop the commit here and rebase onto master.

The other commit, right now, adds the SPARQL grammar (thanks @afs for the link) to the Prolog database. I regenerated the tokenizer table, used by CodeMirror, with SWI-Prolog and tested locally in YASGUI. You can see it in action with the YASQE editor in these screenshots:

Screenshot from 2023-01-23 20-40-49 Screenshot from 2023-01-23 20-56-19

I've also tested successfully in Jena. This screenshot shows the current behavior (running FusekiCmd from Eclipse, port 3030):

image

And this one shows the Fuseki UI using the local development version of YASGUI (I removed triply/yasqe from Jena Fuseki UI, then yarn add /home/kinow/.../yasqe, running Yarn using port 8080, proxying Fuseki requests to the port 3030 - i.e. Fuseki UI dev mode, same data & backend, different UI only):

image

I loaded a simple Turtle file into a dataset in Jena:

PREFIX : <http://example/directory>
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>

<< :john foaf:name "John Smith" >> dct:source <http://example/directory> .

to query and produce some RDF-Star results. At the moment it shows a JavaScript error in the query results panel (“e[t].value.replace is not a function”).

image

So that's the only part pending, but I think the hardest part was the Prolog parser and getting it working with YASQE. Now it should be a matter of checking if the type is a triple and displaying it correctly (probably as a quoted triple?).

Cheers -Bruno

kinow commented 1 year ago

Not sure what would be the best way to display SPARQL-star results :disappointed_relieved:

I had a go at modifying the YASR parser and related code. I used a class-static method, but I guess that could have been an exported function instead. Not sure if that needs tests (nor how easy it'd be to write them). So happy to get a review for the current status, and then iterate and improve as needed :+1:

I used this nested example:

# https://w3c.github.io/rdf-star/tests/turtle/syntax/#turtle-star-nested-2
PREFIX : <http://example/>

:s :p :o .
:a :q <<:s :p :o >> .
<< :a :q <<:s :p :o >>>> :r :z .

Here's the result in Apache Jena Fuseki UI:

Screen Shot 2023-01-24 at 17 14 14-fullpage

Maybe each triple quoted should be a new 3-column table within the current column (recursively)?

Thanks! Bruno

SimonBin commented 4 months ago

Hi @kinow

I noticed some curious issue with this PR, the following code gets flagged as wrong:

PREFIX some: <https://www.example.com/>
SELECT * WHERE {
  bind(some:function(?var1) as ?var2)
  ^-- This line is invalid. Expected: VAR1, VAR2
}

no such error without this patch

afs commented 4 months ago

The syntax for triple terms / named occurrences being worked on by the RDF WG looks like it will be similar, but not the same, as the RDF-star CG report.

kinow commented 4 months ago

Had forgotten about this PR. Maybe I should move this to the forked repo that we are now using in Jena Fuseki. Will do that (later, when I find some spare time)