Hi:
How can I control the form of CONSTRUCT results from the wikidata query service?
On the web interface I can get the results in various formats (but not something that can be read into SPARQL, I don't think). Using curl all I get is XML/RDF.
What I really want is n-triples so that I can concatenate several results, but Turtle would be better than RDF/XML.
peter
If you send an Accept header for Turtle, the server returns Turtle:
$ curl -H 'Accept: text/turtle' --data-urlencode query='CONSTRUCT { ?item a http://example.com/Human. } WHERE { ?item wdt:P31 wd:Q5. } LIMIT 10' https://query.wikidata.org/sparql @prefix wd: http://www.wikidata.org/entity/ . # ... wd:Q260 a http://example.com/Human . # ...
Unfortunately, specifying an analogous N-Triples header doesn’t work. I’m not sure why – perhaps BlazeGraph just doesn’t support it directly.
Cheers, Lucas
On 20.07.2018 04:22, Peter F. Patel-Schneider wrote:
Hi:
How can I control the form of CONSTRUCT results from the wikidata query service?
On the web interface I can get the results in various formats (but not something that can be read into SPARQL, I don't think). Using curl all I get is XML/RDF.
What I really want is n-triples so that I can concatenate several results, but Turtle would be better than RDF/XML.
peter
Wikidata-tech mailing list Wikidata-tech@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikidata-tech
Supported formats are documented on the WQS User Manual
https://www.mediawiki.org/wiki/Wikidata_Query_Service/User_Manual#SPARQL_end...
And I do not see Turtle listed there...however...I do see it listed on the Linked Data Fragments endpoint
https://www.mediawiki.org/wiki/Wikidata_Query_Service/User_Manual#Linked_Dat...
Hope that helps, -Thad
On Fri, Jul 20, 2018 at 6:04 AM Lucas Werkmeister mail@lucaswerkmeister.de wrote:
If you send an Accept header for Turtle, the server returns Turtle:
$ curl -H 'Accept: text/turtle' --data-urlencode query='CONSTRUCT { ?item a http://example.com/Human. } WHERE { ?item wdt:P31 wd:Q5. } LIMIT 10' https://query.wikidata.org/sparql @prefix wd: http://www.wikidata.org/entity/ . # ... wd:Q260 a http://example.com/Human . # ...
Unfortunately, specifying an analogous N-Triples header doesn’t work. I’m not sure why – perhaps BlazeGraph just doesn’t support it directly.
Cheers, Lucas
On 20.07.2018 04:22, Peter F. Patel-Schneider wrote:
Hi:
How can I control the form of CONSTRUCT results from the wikidata query service?
On the web interface I can get the results in various formats (but not something that can be read into SPARQL, I don't think). Using curl all
I get
is XML/RDF.
What I really want is n-triples so that I can concatenate several
results, but
Turtle would be better than RDF/XML.
peter
Wikidata-tech mailing list Wikidata-tech@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikidata-tech
Wikidata-tech mailing list Wikidata-tech@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikidata-tech
Thanks.
I dug a bit further and found https://wiki.blazegraph.com/wiki/index.php/REST_API so I tried text/plain, which produces N-triples.
peter
On 07/20/2018 04:03 AM, Lucas Werkmeister wrote:
If you send an Accept header for Turtle, the server returns Turtle:
$ curl -H 'Accept: text/turtle' --data-urlencode query='CONSTRUCT { ?item a http://example.com/Human. } WHERE { ?item wdt:P31 wd:Q5. } LIMIT 10' https://query.wikidata.org/sparql @prefix wd: http://www.wikidata.org/entity/ . # ... wd:Q260 a http://example.com/Human . # ...
Unfortunately, specifying an analogous N-Triples header doesn’t work. I’m not sure why – perhaps BlazeGraph just doesn’t support it directly.
Cheers, Lucas
On 20.07.2018 04:22, Peter F. Patel-Schneider wrote:
Hi:
How can I control the form of CONSTRUCT results from the wikidata query service?
On the web interface I can get the results in various formats (but not something that can be read into SPARQL, I don't think). Using curl all I get is XML/RDF.
What I really want is n-triples so that I can concatenate several results, but Turtle would be better than RDF/XML.
peter
Wikidata-tech mailing list Wikidata-tech@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikidata-tech
Wikidata-tech mailing list Wikidata-tech@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikidata-tech
List,
Here is a question I posed on Stackoverflow (https://stackoverflow.com/questions/51912599/get-records-for-a-list-of-multi...). Can anyone give me pointers?
I am mapping multiple entities (Q entries) in Wikidata for which I need the same record of properties (P entries). For sake of this question, say I have a list of five Wikidata entities (Q1, Q2, Q3, Q4, Q5) for which I want to retrieve the same property records (say, P1, P2, and P3). I know all Q and P in advance.
I understand how to pose a SPARQL query for an individual record (say for Q1), and I also understand how to specify the return of labels using the special SERVICE wikibase:label function for P1, P2, and P3.
First question, is there a way to loop over a list of entities (Q1 to Q5) with a given SPARQL query using only SPARQL?
If the answer is No, does any example Python or pseudocode exist for issuing single SPARQL queries looping over a list of external identifiers (Q1 to Q5), say provided as an external text or CSV file?
If there is a simple way to approach this, I'd love to hear.
Thanks!
Best, Mike
List,
Within a few hours I got very helpful responses on Stackoverflow. See the link.
Thanks!
Mike
On 8/18/2018 4:20 PM, Mike Bergman wrote:
List,
Here is a question I posed on Stackoverflow (https://stackoverflow.com/questions/51912599/get-records-for-a-list-of-multi...). Can anyone give me pointers?
I am mapping multiple entities (Q entries) in Wikidata for which I need the same record of properties (P entries). For sake of this question, say I have a list of five Wikidata entities (Q1, Q2, Q3, Q4, Q5) for which I want to retrieve the same property records (say, P1, P2, and P3). I know all Q and P in advance.
I understand how to pose a SPARQL query for an individual record (say for Q1), and I also understand how to specify the return of labels using the special SERVICE wikibase:label function for P1, P2, and P3.
First question, is there a way to loop over a list of entities (Q1 to Q5) with a given SPARQL query using only SPARQL?
If the answer is No, does any example Python or pseudocode exist for issuing single SPARQL queries looping over a list of external identifiers (Q1 to Q5), say provided as an external text or CSV file?
If there is a simple way to approach this, I'd love to hear.
Thanks!
Best, Mike
wikidata-tech@lists.wikimedia.org