Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [sparql]

SPARQL is a standardized query language for RDF and part of the Semantic Web.

0
votes
0answers
9 views

wikidata query missing out countries in Europe

I am using the following query against wikidata; SELECT ?country ?countryLabel WHERE { ?country wdt:P30 wd:Q46; wdt:P31 wd:Q6256. SERVICE wikibase:...
1
vote
0answers
35 views

Expand Wikidata SPARQL query to self-join

I have this query to get the population of cities and the country they belong to: SELECT ?city (?population as ?city_pop) ?country ?countryLabel ?continent ?continentLabel ?cityLabel WHERE { ...
0
votes
1answer
44 views

How to output only English labels in SPARQL query?

I don't understand why this SPARQL queries produce duplicates: SELECT DISTINCT ?WikidataItem ?itemLabel WHERE { ?WikidataItem rdfs:label ?itemLabel. ?WikidataItem ?label "Mozilla Firefox"@en. ...
1
vote
0answers
33 views

Wikidata - How to get codes without urls

Ive the following query, but I only want the country codes, not the entire link. This happens also with other fields and i cant find the solution PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> ...
0
votes
1answer
28 views

Wikidata - Filter or Detect or Get incomplete date

I've the following query PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> SELECT ?item ?itemLabel ?dod ?dob WHERE { ?item wdt:P570 ?dod. ?item wdt:P31 wd:Q5. SERVICE wikibase:label { bd:...
0
votes
0answers
23 views

How to access only the first item in a statement?

I am trying to collect a list of capitals of Japanese prefectures. However, some items have multiple images; my understanding is that such items in a statement are ordered, and the top one is the most ...
1
vote
1answer
24 views

Limiting a SPARQL Query to Lastest Point in Time

I'm trying to get information on Prefectures in Japan out of Wikidata. I succeeded to read the population statement, however there are occasionally several values with different point in time fields. ...
3
votes
0answers
61 views

(How) Was SPARQL influenced by erotetics?

Erotetics is the logic of questions and answers. The field has been developed over the last hundred years and is nicely summarized by (Wisniewski 2015). How, if at all, was SPARQL, the RDF query ...
1
vote
1answer
54 views

Get list of all wikidata properties used to link to an item

The first part of my question is, is there a SPARQL equivalent of the "What links here" link? E.g. as described at https://opendata.stackexchange.com/a/5271/20321 I tried: WHERE { ?item wdt:?...
2
votes
0answers
49 views

Querying Sparql dataset and caching results locally

During querying LOD datasets (using Sparql queries), we could face connection or server problems. Is there a reliable strategy that helps us to get data is a reliable way ? I'm looking for a tool (in ...
3
votes
1answer
48 views

Numerically order SPARQL results that are external identifiers but actually all numbers

I wrote this query to list Wikidata items that have an RFC identifier: SELECT ?rfcId ?itemLabel ?classLabel ?item WHERE { ?item wdt:P31 ?class. ?item wdt:P892 ?rfcId. SERVICE wikibase:label { ...
2
votes
1answer
51 views

How can I query Wikidata for a label and optional image without further constraints?

I made a derivation of the cats with images example where I query for a specific cat, in particular its label and a possible image (in the web interface): SELECT ?item ?itemLabel ?pic WHERE { ...
4
votes
1answer
58 views

Why does Wikidata's query interface return no results for entities with an id of Q10000001 or higher?

I have this SPARQL query to return an item's label and the url of a Wikipedia article: PREFIX schema: <http://schema.org/> PREFIX wd: <http://www.wikidata.org/entity/> SELECT ?article ?...
6
votes
1answer
70 views

Julian and Gregorian dates from Wikidata

How can I get the Julian birth or death date for someone who was born or died under the Julian Calendar (Isaac Newton, for example) on Wikidata using a SPARQL query? This simple query returns "4 ...
1
vote
1answer
30 views

Search in wikidata with specific Q code

I've this query but I can't understand why doesn't return any result. I try different versions (with link, with only code, with wd:code) but nothing seems to work. What I need is this query but ...
1
vote
1answer
104 views

Weird results in search from wikidata

I ve this query, which i want to find every instance of human with name Jose (already a first name like John, very common) in wikidata spanish, and then I get only 10 results. I believe is the way of ...
2
votes
0answers
75 views

Property and sub-property pairs

Here are some example records: https://www.wikidata.org/wiki/Q11361734 https://www.wikidata.org/wiki/Q74669 I have the following (updated) query: # Script #2 SELECT (GROUP_CONCAT( ?...
1
vote
1answer
49 views

Find all Wikidata items that use a particular P18 picture

I want to find all Wikidata items that have "Gthumb.svg" as a P18 property. Leaving aside the fact that "Gthumb.svg" may not exist on Commons and that normal P18 values have a "commons:" prefix, it ...
3
votes
1answer
112 views

Most efficient way to get the Wikidata entity for a city, given as a string

The goal is to get from the string "Lugano", the entity Q7024, knowing that I am searching for Swiss locations, by name in German. So far this is how I do it but it doesn't look very efficient. 1) ...
5
votes
1answer
76 views

Sort results by proximity with the “around” service in Wikidata

With this query, I can get a list of German cities around Berlin, within a radius of 50 km. SELECT ?place ?placeLabel ?location WHERE { wd:Q64 wdt:P625 ?arcLoc . ?place wdt:P31 wd:Q515 . ?...
2
votes
1answer
152 views

Wikidata - How to get a table with all US cities with associated counties?

I did not find existing data of good quality that I can use directly. I thought that Wikidata was the best source to use and that it would be an opportunity to learn how to extract from this data ...
8
votes
2answers
88 views

SPARQL federation and attribution licenses?

Many public datasets are published under licenses that require attribution, such as CC-BY. If I have a public SPARQL endpoint, and allow federated queries to access data from such endpoint, that means ...
8
votes
2answers
379 views

Wikidata get property of property

This question is related to this. We have the following query: SELECT DISTINCT ?item ?itemLabel ?AuthorLabel ?year WHERE { ?item wdt:P166 wd:Q255032. ?item wdt:P50 ?Author . ?item wdt:P577 ...
4
votes
2answers
394 views

get item's properties know QID

Know QID I can get items's label: SELECT DISTINCT * WHERE { wd:Q302 rdfs:label ?label . FILTER (langMatches( lang(?label), "EN" ) ) SERVICE wikibase:label { bd:serviceParam wikibase:language "...
1
vote
1answer
79 views

get label (Name) instead QID field

Using the following query: SELECT ?item ?itemLabel ?itemDescription ?director WHERE { ?item wdt:P31 wd:Q11424 . ?item wdt:P161 wd:Q2263 . OPTIONAL{?item wdt:P57 ?director .} SERVICE wikibase:...
7
votes
2answers
156 views

Retrieve periodic table information from wikidata

I'm trying to retrieve some basic informations from chemical elements stored in wikidata to create an interactive periodic table. It's my first attempt to use wikidata, so I've understood how to get ...
3
votes
1answer
153 views

Wikidata: QueryTimeoutException: Query deadline is expired

I used to execute successfully the following query: SELECT (COUNT(?r) AS ?count) WHERE { [] <http://www.wikidata.org/prop/direct/P31> ?r } on http://wdqs-beta.wmflabs.org/bigdata/namespace/wdq/...
2
votes
1answer
381 views

Get QID from Wikidata label name, via SPARQL

I use api.php to get the QID of something using its English label. Example: Mozambique → Q1029 $ wget --quiet -O - "http://www.wikidata.org/w/api.php?action=wbgetentities \ &sites=enwiki&...
2
votes
2answers
137 views

How to get all Wikidata items in a country?

Using SPARQL I want to show all French embassies in Liberia (spoiler: there is exactly one) So I wrote this naive query: SELECT ?item WHERE { ?item wdt:P17 wd:Q1014. # country: Liberia ?...
8
votes
2answers
1k views

How to include sub-classes in a Wikidata SPARQL query? (example: when querying “bands”, include “rock bands”)

Here is my naive query for bridges: SELECT ?item WHERE { ?item wdt:P31 wd:Q12280. # Item's type is: bridge } Problem: It only returns a small fraction of all bridges, because railway bridges (...
0
votes
1answer
45 views

Can SPARQL modify data like SQL? Or is it read-only?

Despite being a query language, SQL can perform DELETE/UPDATE/INSERT operations. Similarly, can SPARQL modify data? If find SPARQL convenient so I would like to use it to modify data, for instance ...
3
votes
1answer
163 views

Wikidata SPARQL, why an intermediate item is needed in this sample query?

In the Wikidata SPARQL samples, I found this query: What is the relation between Terrell Buckley and Miami Dolphins? Items used: Terrell Buckley (Q5571382), Miami Dolphins (Q223243) SELECT ?l WHERE ...
8
votes
3answers
590 views

Querying Wikidata : WDQ vs. WDQS / SPARQL

I'm new to Wikidata and I'm wanting to query it. The official page list several promising syntax / APIs : WDQ "Wikidata Query" syntax : http://wdq.wmflabs.org/api_documentation.html SPARQL syntax via ...
11
votes
2answers
839 views

How to output the description of Wikidata items using SPARQL?

I am trying to output a table using query.wikidata.org and SPARQL, with the name, birthdate, and brief description of notable, living Americans (i.e. those with wikidata entries) who will turn 100 ...
7
votes
2answers
87 views

GIThub to share a set of SPARQL queries

I am using github to share a set of SPARQL queries: http://www.boisvert.me.uk/opendata/sparql_aq+.html?file=specific%20sensor.txt Currently the simple work allows end-users to access queries stored ...
3
votes
1answer
135 views

Wikidata Query Service reliability

I encountered a partially incorrect result set from Wikidata Query Service. Requested Wikipedia article urls were missing for an item where this information existed, see https://stackoverflow.com/...
17
votes
2answers
3k views

Get Wikipedia URLs (sitelinks) in Wikidata SPARQL query

I can use the following query to list all sovereign states via the Wikidata query interface: PREFIX wikibase: <http://wikiba.se/ontology#> PREFIX wd: <http://www.wikidata.org/entity/> ...
6
votes
1answer
296 views

Mapping CSV Header to RDF + SPARQL console

I would like to know your opinion about the next system: with a large CSV file convert it's header to RDF schema, in which exists only the CSV columns information and access point. This way there's ...
3
votes
1answer
317 views

What triplestore that can handle the largest number of triples?

A triplestore is a special database engine containing information triples and answering to SPARQL requests. What is currently the triplestore that can contain most triples, while still being able to ...
4
votes
2answers
156 views

U.S. federal government data fetchable via SPARQL?

I am interested in U.S. federal government information (e.g., agencies/sub-agencies, programs, etc) that I can fetch via the Semantic Web/SPARQL. I am able to get this information via Dbpedia. The ...
11
votes
4answers
3k views

What server and technologies can I use to extract data out of Wikipedia's infoboxes (e.g., ATC code for drugs)

Wikipedia is a significant source of data. Data from Wikipedia may be available in various formats via other servers (e.g., SPARQL end point). For a task of extracting all pairs of "ATC code" - "...