You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi all,
I was trying SPARQL.js to parse queries from Wikidata. Wikidata SPARQL syntax allows named subqueries and supports keywords (WITH, AS and INCLUDE) which are coming from the underlying Blazegraph triple store that Wikidata uses.
So, I couldn't parse those kind of queries and I got this error message:
Error: Parse error on line 5:
...?orcid_) AS ?orcid)WITH { SELECT DIST
----------------------^
Expecting 'VAR', '(', 'WHERE', '{', 'FROM', got 'WITH'
at Parser.parseError (/.npm-global/lib/node_modules/sparqljs/lib/SparqlParser.js:663:21)
at Parser.parse (/.npm-global/lib/node_modules/sparqljs/lib/SparqlParser.js:730:22)
at Parser.parser.parse (/.npm-global/lib/node_modules/sparqljs/sparql.js:31:37)
at ReadStream.<anonymous> (/.npm-global/lib/node_modules/sparqljs/bin/sparql-to-json:25:65)
at ReadStream.emit (events.js:326:22)
at endReadableNT (_stream_readable.js:1241:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
hash: {
text: 'WITH',
token: 'WITH',
line: 5,
loc: { first_line: 5, last_line: 5, first_column: 28, last_column: 29 },
expected: [ "'VAR'", "'('", "'WHERE'", "'{'", "'FROM'" ]
}
}
And the SPARQL query I used is:
SELECT
(SAMPLE(?number_of_works_) AS?works)
(SAMPLE(?wikis_) AS?wikis)
?researcher?researcherLabel?researcherDescription
(SAMPLE(?orcid_) AS?orcid)
WITH {
SELECTDISTINCT?researcherWHERE {
?researcher ( wdt:P108 | wdt:P463 | wdt:P1416 ) / wdt:P361* wd:Q19845644 .
}
} AS %researchers
WITH {
SELECT
(COUNT(?work) AS?number_of_works_) ?researcherWHERE {
INCLUDE %researchers
OPTIONAL { ?work wdt:P50 ?researcher . }
# No biological pathways; they skew the statistics too much
MINUS { ?work wdt:P31 wd:Q4915012 }
}
GROUPBY?researcher
} AS %researchers_and_number_of_works
WHERE {
INCLUDE %researchers_and_number_of_works
OPTIONAL { ?researcher wdt:P496 ?orcid_ . }
OPTIONAL { ?researcher wikibase:sitelinks ?wikis_ }
SERVICE wikibase:label { bd:serviceParam wikibase:language "en,da,de,es,fr,nl,no,ru,sv,zh" . }
}
GROUPBY?researcher?researcherLabel?researcherDescriptionORDERBYDESC(?works)
It would be great if Wikidata queries can be supported. Wikidata has a lot of users and many applications are being developed on top of it like Scholia.
Thanks for all your efforts.
The text was updated successfully, but these errors were encountered:
Hi all,
I was trying SPARQL.js to parse queries from Wikidata. Wikidata SPARQL syntax allows named subqueries and supports keywords (WITH, AS and INCLUDE) which are coming from the underlying Blazegraph triple store that Wikidata uses.
So, I couldn't parse those kind of queries and I got this error message:
And the SPARQL query I used is:
It would be great if Wikidata queries can be supported. Wikidata has a lot of users and many applications are being developed on top of it like Scholia.
Thanks for all your efforts.
The text was updated successfully, but these errors were encountered: