samples from yaml file #607
Replies: 3 comments
-
to install the tool: pip install -U pylodstorage usage sparqlquery -h
usage: sparqlquery [-h] [-d] [-ep ENDPOINTPATH] [-en ENDPOINTNAME]
[-f {csv,json,xml,tsv,latex,mediawiki,github}] [-li] [-le]
[-m MIMETYPE] [-p] [-sq] [-qp QUERIESPATH] [-q QUERY]
[-qn QUERYNAME] [-raw] [-V]
commandline query of endpoints in diverse languages such as SPARQL/SQL
Created by Wolfgang Fahl on 2020-09-10.
Copyright 2020-2022 Wolfgang Fahl. All rights reserved.
Licensed under the Apache License 2.0
http://www.apache.org/licenses/LICENSE-2.0
Distributed on an "AS IS" basis without warranties
or conditions of any kind, either express or implied.
USAGE
optional arguments:
-h, --help show this help message and exit
-d, --debug set debug [default: False]
-ep ENDPOINTPATH, --endpointPath ENDPOINTPATH
path to yaml file to configure SPARQL endpoints to use
for queries
-en ENDPOINTNAME, --endpointName ENDPOINTNAME
Name of the SPARQL endpoint to use for queries.
Avaliable by default: ['wikidata', 'qlever-wikidata',
'qlever-wikidata-proxy', 'blazegraph', 'sun-qlever']
-f {csv,json,xml,tsv,latex,mediawiki,github}, --format {csv,json,xml,tsv,latex,mediawiki,github}
-li, --list show the list of available queries
-le, --listEndpoints show the list of available endpoints
-m MIMETYPE, --mimeType MIMETYPE
MIME-type to use for the raw query
-p, --prefixes add predefined prefixes for endpoint
-sq, --showQuery show the query
-qp QUERIESPATH, --queriesPath QUERIESPATH
path to YAML file with query definitions
-q QUERY, --query QUERY
the query to run
-qn QUERYNAME, --queryName QUERYNAME
run a named query
-raw return the raw query result from the endpoint. (MIME
type defined over -f or -m)
-V, --version show program's version number and exit version sparqlquery -V
sparqlquery v0.1.12 (2022-02-26) list endpoints sparqlquery --listEndpoints
wikidata:https://query.wikidata.org/sparql
qlever-wikidata:https://qlever.cs.uni-freiburg.de/api/wikidata
qlever-wikidata-proxy:https://qlever.cs.uni-freiburg.de/api/wikidata-proxy
blazegraph:http://blazegraph.bitplan.com/namespace/wdq/sparql
sun-qlever:http://qlever.bitplan.com Endpoints are configured with yaml filse. You can specify the path to the yaml file with -ep or --endpointPath. If there is an endpoint configuration yaml file at $HOME/.pylodstorage/endpoints.yaml the content will be automatically added. An example content is: # Default SPARQL endpoints for sparqlquery tool
# 2022-02-14 tholzheim
'wikidata':
endpoint: https://query.wikidata.org/sparql
prefixes: |
PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX cc: <http://creativecommons.org/ns#>
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX ontolex: <http://www.w3.org/ns/lemon/ontolex#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX pqn: <http://www.wikidata.org/prop/qualifier/value-normalized/>
PREFIX pqv: <http://www.wikidata.org/prop/qualifier/value/>
PREFIX pr: <http://www.wikidata.org/prop/reference/>
PREFIX prn: <http://www.wikidata.org/prop/reference/value-normalized/>
PREFIX prov: <http://www.w3.org/ns/prov#>
PREFIX prv: <http://www.wikidata.org/prop/reference/value/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX psn: <http://www.wikidata.org/prop/statement/value-normalized/>
PREFIX psv: <http://www.wikidata.org/prop/statement/value/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX schema: <http://schema.org/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdata: <http://www.wikidata.org/wiki/Special:EntityData/>
PREFIX wdno: <http://www.wikidata.org/prop/novalue/>
PREFIX wdref: <http://www.wikidata.org/reference/>
PREFIX wds: <http://www.wikidata.org/entity/statement/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wdtn: <http://www.wikidata.org/prop/direct-normalized/>
PREFIX wdv: <http://www.wikidata.org/value/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
'qlever-wikidata':
endpoint: https://qlever.cs.uni-freiburg.de/api/wikidata
prefixes: |
PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX cc: <http://creativecommons.org/ns#>
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX ontolex: <http://www.w3.org/ns/lemon/ontolex#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX pqn: <http://www.wikidata.org/prop/qualifier/value-normalized/>
PREFIX pqv: <http://www.wikidata.org/prop/qualifier/value/>
PREFIX pr: <http://www.wikidata.org/prop/reference/>
PREFIX prn: <http://www.wikidata.org/prop/reference/value-normalized/>
PREFIX prov: <http://www.w3.org/ns/prov#>
PREFIX prv: <http://www.wikidata.org/prop/reference/value/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX psn: <http://www.wikidata.org/prop/statement/value-normalized/>
PREFIX psv: <http://www.wikidata.org/prop/statement/value/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX schema: <http://schema.org/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdata: <http://www.wikidata.org/wiki/Special:EntityData/>
PREFIX wdno: <http://www.wikidata.org/prop/novalue/>
PREFIX wdref: <http://www.wikidata.org/reference/>
PREFIX wds: <http://www.wikidata.org/entity/statement/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wdtn: <http://www.wikidata.org/prop/direct-normalized/>
PREFIX wdv: <http://www.wikidata.org/value/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
'qlever-wikidata-proxy':
endpoint: https://qlever.cs.uni-freiburg.de/api/wikidata-proxy
prefixes: |
PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX cc: <http://creativecommons.org/ns#>
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX ontolex: <http://www.w3.org/ns/lemon/ontolex#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX pqn: <http://www.wikidata.org/prop/qualifier/value-normalized/>
PREFIX pqv: <http://www.wikidata.org/prop/qualifier/value/>
PREFIX pr: <http://www.wikidata.org/prop/reference/>
PREFIX prn: <http://www.wikidata.org/prop/reference/value-normalized/>
PREFIX prov: <http://www.w3.org/ns/prov#>
PREFIX prv: <http://www.wikidata.org/prop/reference/value/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX psn: <http://www.wikidata.org/prop/statement/value-normalized/>
PREFIX psv: <http://www.wikidata.org/prop/statement/value/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX schema: <http://schema.org/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdata: <http://www.wikidata.org/wiki/Special:EntityData/>
PREFIX wdno: <http://www.wikidata.org/prop/novalue/>
PREFIX wdref: <http://www.wikidata.org/reference/>
PREFIX wds: <http://www.wikidata.org/entity/statement/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wdtn: <http://www.wikidata.org/prop/direct-normalized/>
PREFIX wdv: <http://www.wikidata.org/value/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> |
Beta Was this translation helpful? Give feedback.
-
E.g. in my environment i can test against:
the available named testing queries can be listed with: sparqlquery --list
Predicate usage:Predicate usage
Predicate usage grouped by source:Predicate usage grouped by source
Conference Series:Scientific conference series
US President Nicknames:Nick names of US Presidents
10 Largest Cities Of The World:Ten largest cities of the world
cities:German cities by population
FirstTriple:First Triple the content of a query can be shown with --showQuery:
|
Beta Was this translation helpful? Give feedback.
-
sparqlquery --queryName "US President Nicknames" --format github will create and output in github markup that you see below as a cut&paste result: Nick names of US PresidentsquerySELECT ?president ?presidentLabel (GROUP_CONCAT(DISTINCT ?nickName; SEPARATOR=",") as ?nickNames)
WHERE
{
# president
?president wdt:P39 wd:Q11696.
# nickname
?president wdt:P1449 ?nickName
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
} GROUP BY ?president ?presidentLabel
result
|
Beta Was this translation helpful? Give feedback.
-
Please note that i have created the sparqlquery command line tool for testing queries on different platforms. see https://github.com/WolfgangFahl/pyLoDStorage
https://github.com/WolfgangFahl/pyLoDStorage is specifying queries in a yaml file now to allow better automated testing see:
https://github.com/WolfgangFahl/pyLoDStorage/tree/master/sampledata
Would it be feasible for you to support a similar format for your UI e.g. to drag & drop a yaml file with example queries to try out?
Given the latex,github and wiki output support of our tool it think it would be helpful in discussing features and limitations. See also #604
Beta Was this translation helpful? Give feedback.
All reactions