-
Notifications
You must be signed in to change notification settings - Fork 55
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
[YASR] Support SPARQL-star results #190
Comments
I notice that GraphDB 9.10.1, which seems to be using YASR and YASQE, has some support for SPARQL-star in them. @VladimirAlexiev any chance to see these changes open-sourced and submitted to the original code? Also related to #189. |
Our workbench is open source: https://github.com/Ontotext-AD/graphdb-workbench It uses an older version of YASR . Our modified version is also open source: @desislava-hristova-ontotext can say more. Also: we are currently working on making GDB WB (and YASR and charts) translatable. This is coordinated by @rdstn |
We are using YASGUI/YASR in Apache Jena, thanks a lot for sharing it. I forked and had a look at the project:
I have and I have the latest SWI Prolog for Ubuntu. I tried running the current code from GitHub to see if I could produce the tokenizer before trying to modify it. But running the kinow@ranma:~/Development/java/jena/Yasgui/packages/yasqe/grammar$ ./build.sh
Welcome to SWI-Prolog (threaded, 64 bits, version 9.0.2)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.
For online help and background, visit https://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).
ERROR: assertz/1: Type error: `callable' expected, found `[]' (an empty_list)
Exception: (9) *'or([baseDecl,prefixDecl])'===>_7470 ? My Prolog is really (but really) rusty. Any idea what could be wrong here, or if I need to install an older version? Thank you! |
(JavaCC rather than Antlr) The grammar changes for SPARQL are in the CG report which si BNF without the local parser actions attached: and for results formats: |
Tried with trealla prolog but looks like the code uses some features that are missing in trealla's (maybe the dynamic predicates, like Installed PDT on Eclipse (really nostalgic, years since I last used it), and loaded the Then calling I will try a few things to see if I can re-generate the JavaScript file correctly. |
Argh, I think I said Antlr in other issues too. Always confuse it. Thanks for correcting it.
Thanks @afs! If I cannot get the SWI-Prolog files to work here in Yasgui, a crazy idea that just occurred me was to try a few other possibilities:
But first will have a little more fun trying to remember how Prolog works 🤓 |
Fixed it by using an older version of |
Hmmm, I've added the grammar changes for SPARQL, and prolog runs OK (also with #214). diff --git a/packages/yasqe/grammar/sparql11-grammar.pl b/packages/yasqe/grammar/sparql11-grammar.pl
index 8f3681e..289bd9c 100644
--- a/packages/yasqe/grammar/sparql11-grammar.pl
+++ b/packages/yasqe/grammar/sparql11-grammar.pl
@@ -46,7 +46,7 @@ selectQuery ==>
[selectClause,*(datasetClause),whereClause,solutionModifier].
subSelect ==>
- [selectClause,whereClause,solutionModifier,valuesClause].
+ [selectClause,whereClause,solutionModifier,valuesClause].
% [9]
selectClause ==>
@@ -296,6 +296,7 @@ inlineDataOneVar ==> [var,'{',*(dataBlockValue),'}'].
inlineDataFull ==> [ 'NIL' or ['(',*(var),')'],
'{',*(['(',*(dataBlockValue),')'] or 'NIL'),'}'].
%[65]
+dataBlockValue ==> [quotedTriple].
dataBlockValue ==> [iriRef].
dataBlockValue ==> [rdfLiteral].
dataBlockValue ==> [numericLiteral].
@@ -337,7 +338,7 @@ constructTriples ==>
[triplesSameSubject,?(['.',?(constructTriples)])].
%[75]
triplesSameSubject ==>
- [varOrTerm,propertyListNotEmpty].
+ [varOrTermOrQuotedTP,propertyListNotEmpty].
triplesSameSubject ==>
[triplesNode,propertyList].
%[76]
@@ -356,9 +357,9 @@ objectList ==>
[object,*([',',object])].
%[80]
object ==>
- [graphNode].
+ [graphNode, ?(annotationPattern)].
%[81]
-triplesSameSubjectPath ==> [varOrTerm,propertyListPathNotEmpty].
+triplesSameSubjectPath ==> [varOrTermOrQuotedTP,propertyListPathNotEmpty].
triplesSameSubjectPath ==> [triplesNodePath,propertyListPath].
%[82]
propertyListPath ==> [propertyListNotEmpty].
@@ -376,7 +377,7 @@ verbSimple ==> [var].
objectListPath ==>
[objectPath,*([',',objectPath])].
%[87]
-objectPath ==> [graphNodePath].
+objectPath ==> [graphNodePath, ?(annotationPatternPath)].
%[88]
path ==> [pathAlternative].
%[89].
@@ -449,10 +450,10 @@ collection ==> ['(',+(graphNode),')'].
%[103]
collectionPath ==> ['(',+(graphNodePath),')'].
%[104]
-graphNode ==> [varOrTerm].
+graphNode ==> [varOrTermOrQuotedTP].
graphNode ==> [triplesNode].
%[105]
-graphNodePath ==> [varOrTerm].
+graphNodePath ==> [varOrTermOrQuotedTP].
graphNodePath ==> [triplesNodePath].
%[106]
varOrTerm ==> [var].
@@ -516,6 +517,7 @@ primaryExpression ==> [rdfLiteral].
primaryExpression ==> [numericLiteral].
primaryExpression ==> [booleanLiteral].
primaryExpression ==> [var].
+primaryExpression ==> [exprQuotedTP].
primaryExpression ==> [aggregate].
%[120]
brackettedExpression ==> ['(',expression,')'].
@@ -577,6 +579,11 @@ builtInCall ==> ['ISNUMERIC','(',expression,')'].
builtInCall ==> [regexExpression].
builtInCall ==> [existsFunc].
builtInCall ==> [notExistsFunc].
+builtInCall ==> ['TRIPLE','(',expression,expression,expression,')'].
+builtInCall ==> ['SUBJECT','(',expression,')'].
+builtInCall ==> ['PREDICATE','(',expression,')'].
+builtInCall ==> ['OBJECT','(',expression,')'].
+builtInCall ==> ['isTRIPLE','(',expression,')'].
%[122]
regexExpression ==>
['REGEX','(',expression,',',expression,?([',',expression]),')'].
@@ -642,7 +649,41 @@ prefixedName ==> ['PNAME_NS'].
%[138]
blankNode ==> ['BLANK_NODE_LABEL'].
blankNode ==> ['ANON'].
-
+%[174]
+quotedTP ==> ['<<',qtSubjectOrObject,verb,qtSubjectOrObject,'>>'].
+%[175]
+quotedTriple ==> ['<<',dataValueTerm,'(',iriRef or 'a',dataValueTerm,'>>'].
+%[176]
+qtSubjectOrObject ==> [var].
+qtSubjectOrObject ==> [blankNode].
+qtSubjectOrObject ==> [iriRef].
+qtSubjectOrObject ==> [rdfLiteral].
+qtSubjectOrObject ==> [numericLiteral].
+qtSubjectOrObject ==> [booleanLiteral].
+qtSubjectOrObject ==> [quotedTP].
+%[177]
+dataValueTerm ==> [iriRef].
+dataValueTerm ==> [rdfLiteral].
+dataValueTerm ==> [numericLiteral].
+dataValueTerm ==> [booleanLiteral].
+dataValueTerm ==> [quotedTriple].
+%[178]
+varOrTermOrQuotedTP ==> [var].
+varOrTermOrQuotedTP ==> [graphTerm].
+varOrTermOrQuotedTP ==> [quotedTP].
+%[179]
+annotationPattern ==> ['{|',propertyListNotEmpty,'|}'].
+%[180]
+annotationPatternPath ==> ['{|',propertyListPathNotEmpty,'|}'].
+%[181]
+exprQuotedTP ==> ['<<',exprVarOrTerm,verb,exprVarOrTerm,'>>'].
+%[182]
+exprVarOrTerm ==> [iriRef].
+exprVarOrTerm ==> [rdfLiteral].
+exprVarOrTerm ==> [numericLiteral].
+exprVarOrTerm ==> [booleanLiteral].
+exprVarOrTerm ==> [var].
+exprVarOrTerm ==> [exprQuotedTP].
% tokens defined by regular expressions elsewhere
tm_regex([
@@ -793,7 +834,15 @@ tm_keywords([
'SAMPLE',
'SEPARATOR',
-'STR'
+'STR',
+
+'REGEX',
+
+'TRIPLE',
+'SUBJECT',
+'PREDICATE',
+'OBJECT',
+'isTRIPLE'
]).
% Other tokens representing fixed, case sensitive, strings
@@ -830,5 +879,9 @@ tm_punct([
'^^'= '\\^\\^',
'?' = '\\?',
'|' = '\\|',
-'^'= '\\^'
+'^'= '\\^',
+'<<'='<<',
+'>>'='>>',
+'{|'='{|',
+'|}'='|}'
]). I ran Running |
These look awesome @VladimirAlexiev ! I'll refer to them while working on this PR. Thanks heaps! |
It would be nice if YASR (at least the table and response tabs) supported the SPARQL-star result formats (i.e. where able to display bindings where some variables are bound to quoted triples).
Note that the RDF-star CG report is now considered pretty stable (we are considering publishing a final report soon), and SPARQL-star is already supported or partially supported by a number of triple stores, so this could already be useful (see example).
The changes to the SPARQL result formats (XML and JSON) are documented here.
The text was updated successfully, but these errors were encountered: