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 SPARQL-Star #215

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Add support to SPARQL-Star #215

wants to merge 3 commits into from

Conversation

kinow
Copy link

@kinow kinow commented Jan 23, 2023

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.

  • SPARQL Grammar
  • SPARQL Query Results

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 kinow changed the title Add support to RDF-Star Add support to SPARQL-Star Jan 23, 2023
@@ -46,7 +46,7 @@
[selectClause,*(datasetClause),whereClause,solutionModifier].

subSelect ==>
[selectClause,whereClause,solutionModifier,valuesClause].
[selectClause,whereClause,solutionModifier,valuesClause].
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting only, no change on this clause/rule.

%[81]
triplesSameSubjectPath ==> [varOrTerm,propertyListPathNotEmpty].
triplesSameSubjectPath ==> [varOrTermOrQuotedTP,propertyListPathNotEmpty].
% TODO: triplesNodePath[100] or triplesNode[98] below?
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is different than the docs, but I did not change as it's not directly related to the change here. Leaving a TODO for later™.

'<<'= '<<',
'>>'= '>>',
'{|'= '\\{\\|',
'|}'= '\\|\\}',
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's where I struggled the most. I hadn't realized I had to escape the right elements. I suspected I needed to move the << before other punctuation like < and <=, but it escaped me to escape it 😬 The error message was a CodeMirror error, saying the stream could not be processed. Took me at least one hour, then a walk outside, to come back and review everything and seeing other examples here I escaped these and everything worked fine 👍 🎉

@kinow kinow marked this pull request as ready for review January 24, 2023 16:11
@kinow
Copy link
Author

kinow commented Jan 24, 2023

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

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 👍

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
Copy link

SimonBin commented Feb 9, 2024

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
Copy link

afs commented Feb 9, 2024

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
Copy link
Author

kinow commented Feb 9, 2024

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)

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

Successfully merging this pull request may close these issues.

[YASR] Support SPARQL-star results
3 participants