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

Support SPARQL #4

Open
magnusmanske opened this issue Apr 8, 2016 · 2 comments
Open

Support SPARQL #4

magnusmanske opened this issue Apr 8, 2016 · 2 comments

Comments

@magnusmanske
Copy link

In addition to WDQ, SPARQL queries at http://query.wikidata.org should be supported.

A simple rule could be that the first column of the returned rows must be an item; these items could then be used just as the items from WDQ.

Example query: SELECT ?item WHERE { ?item wdt:P31 wd:Q16521 . ?item wdt:P51 ?dummy0 }
Example URL generation (returns JSON):
$url = "https://query.wikidata.org/sparql?format=json&query=" . urlencode($sparql) ;

@cdrini
Copy link
Owner

cdrini commented Apr 15, 2016

Yeah, it's about time I got around to this :)

Adding an &sparql=... url parameter which expects the query's 1st var to be items, 2nd labels, 3rd startTime, 4th endTime. I'll have to do the UI for this at another time.

I'll pull the changes on the tools server over the weekend, because I'm having some trouble accessing it today :/

@cdrini
Copy link
Owner

cdrini commented May 14, 2016

Ok, changes are on the tools server. Here's an example of French heads of government (from https://www.mediawiki.org/wiki/Wikibase/Indexing/SPARQL_Query_Examples#French_heads_of_government_by_length_of_service )

https://tools.wmflabs.org/wikidata-timeline/#/timeline?title=French%20heads%20of%20government%20by%20length%20of%20service&sparql=PREFIX%20wikibase:%20%3Chttp:%2F%2Fwikiba.se%2Fontology%23%3E%0APREFIX%20wd:%20%3Chttp:%2F%2Fwww.wikidata.org%2Fentity%2F%3E%20%0APREFIX%20wdt:%20%3Chttp:%2F%2Fwww.wikidata.org%2Fprop%2Fdirect%2F%3E%0APREFIX%20rdfs:%20%3Chttp:%2F%2Fwww.w3.org%2F2000%2F01%2Frdf-schema%23%3E%0APREFIX%20p:%20%3Chttp:%2F%2Fwww.wikidata.org%2Fprop%2F%3E%0APREFIX%20v:%20%3Chttp:%2F%2Fwww.wikidata.org%2Fprop%2Fstatement%2F%3E%0APREFIX%20pq:%20%3Chttp:%2F%2Fwww.wikidata.org%2Fprop%2Fqualifier%2F%3E%0A%0ASELECT%20DISTINCT%20%3Fitem%20%3FitemLabel%20%3Fstart%20%3Fend%20WHERE%20%7B%0A%20%20%3Fitem%20wdt:P31%20wd:Q5%20.%0A%20%20%3Fitem%20p:P39%20%3Fposition_statement%20.%0A%20%20%3Fitem%20wdt:P18%20%3Fpicture%20.%0A%20%20%3Fposition_statement%20v:P39%20%3Fposition%20.%0A%20%20%3Fposition%20wdt:P279*%20wd:Q15135541%20.%0A%20%20%3Fposition_statement%20pq:P580%20%3Fstart%20FILTER%20(%3Fstart%20%3E%3D%20%221815-01-01T00:00:00Z%22%5E%5Exsd:dateTime)%20.%0A%20%20OPTIONAL%20%7B%20%3Fposition_statement%20pq:P582%20%3Fx%20%7D%0A%20%20OPTIONAL%20%7B%0A%20%20%20%20%3Fposition_statement%20pq:P794%20%3Fast%20.%0A%20%20%20%20%3Fast%20rdfs:label%20%3Fas%20filter%20(lang(%3Fas)%20%3D%20%22en%22)%20.%0A%20%20%7D%0A%20%20bind(if(bound(%3Fx),%20%3Fx,%20NOW())%20as%20%3Fend%20)%0A%20%20BIND(FLOOR(%3Fend%20-%20%3Fstart)%20as%20%3Fdays)%0A%20%20SERVICE%20wikibase:label%20%7B%20bd:serviceParam%20wikibase:language%20%22en%22%20.%20%7D%0A%7D%20ORDER%20BY%20DESC(%3Fdays)%20%3FitemLabel

sigh should probably add short urls at somepoint

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants