32 votes

Get Wikipedia URLs (sitelinks) in Wikidata SPARQL query

On 18. April 2016 the ticket "More efficient SPARQL queries for sitelinks" brought us a better way: schema:isPartOf. ?sitelink schema:about ?item . ?sitelink schema:inLanguage "en" . ?sitelink ...
robbi5's user avatar
  • 421
15 votes
Accepted

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

The right expression to use here is p:P31/ps:P31/wdt:P279*. Explanation: p:P31/ps:P31 means instance of, or instance of not marked as preferred. Only using p:P31 at this step would miss some ...
Nicolas Raoul's user avatar
  • 8,426
15 votes
Accepted

Querying Wikidata : WDQ vs. WDQS / SPARQL

I'm the developer of WDQ. It was developed as a stop-gap measure, until Wikidata would get its own query service. That took some years, but now we have SPARQL and https://query.wikidata.org/ so I plan ...
Magnus Manske's user avatar
11 votes
Accepted

Is Wikidata up to date with Wikipedia?

The dependency is supposed to be the opposite, i.e. that Wikipedia should rely on data in Wikidata. This is however not fully implemented yet. If you look at the infobox on this cheese in French, all ...
Ainali's user avatar
  • 446
7 votes

How to get the name of a Wikidata item

You can get it also using SPARQL: SELECT DISTINCT * WHERE { wd:Q19675 rdfs:label ?label . FILTER (langMatches( lang(?label), "ES" ) ) } See it on Wikidata Query Service.
Alexan's user avatar
  • 442
7 votes
Accepted

Wikidata get property of property

The point in time property of the award received is what Wikidata calls a qualifier: Along with sources and ranks, qualifiers allow statements to be expanded on, annotated, or contextualized beyond ...
Patrick Hoefler's user avatar
6 votes
Accepted

Get QID from Wikidata label name, via SPARQL

Yes, you can, but it isn't short: SELECT distinct ?item ?itemLabel ?itemDescription WHERE{ ?item ?label "Mozambique"@en. ?item wdt:P31 wd:Q6256 . ?article schema:about ?item . ?article ...
Alexan's user avatar
  • 442
6 votes

Retrieve periodic table information from wikidata

I think this is close to what you want but there doesn't seem to be a property for group or period as a number. SELECT ?element ?elementLabel ?symbol ?protons ?group ?groupLabel ?period ?periodLabel ...
chrisis's user avatar
  • 388
6 votes
Accepted

Wikidata: How to represent British Hong Kong's under Japanese occupation?

As far as I know, there are no methodological guidelines for how to model those things on Wikidata. Rerardless Wikidata, modelling of such geopolitical endurants/perdurants/aggregates might be fairly ...
Stanislav Kralin's user avatar
5 votes
Accepted

Extract labels from Wikidata entity

You could do it with SPARQL: SELECT ?wdLabel ?ooLabel WHERE { VALUES (?s) {(wd:Q42)} ?s ?wdt ?o . ?wd wikibase:directClaim ?wdt . ?wd rdfs:label ?wdLabel . OPTIONAL { ?o rdfs:label ?...
Stanislav Kralin's user avatar
5 votes
Accepted

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

In the original query ?property and ?p are distinct values: ?property is wd:P54 (short for <http://www.wikidata.org/entity/P54>) and ?p is wdt:P54 (short for <http://www.wikidata.org/prop/...
svick's user avatar
  • 869
5 votes

Querying Wikidata : WDQ vs. WDQS / SPARQL

As Magnus Manske points out, SPARQL is the preferred way since, I would add, SPARQL is standardized BUT, here is the downside: The SPARQL endpoint, at this point in time, is NOT as reliable as WDQ ...
David Sánchez Martín's user avatar
5 votes

Querying Wikidata : WDQ vs. WDQS / SPARQL

You can abbreviate SPARQL by expanding a given query fragment with default namespace definitions and other options. For instance the wikidata query command line client expands wdq -tplanet '?planet ...
Jakob's user avatar
  • 195
5 votes

Is Wikidata up to date with Wikipedia?

Wikidata doesn't automatically use data from Wikipedia. Data from Wikipedia is uploaded to Wikidata by hand or using some more or less automated tools to do batch uploads but ultimately under control ...
Pere's user avatar
  • 381
5 votes

wikidata extract

Try Tabernacle. Seems to be exactly what you search. The downloaded resultset is in TSV format, and can be imported in Excel. You'll need to have a Wikimedia account to work with Tabernacle and some ...
XXN's user avatar
  • 51
4 votes

How to output the description of Wikidata items using SPARQL?

Include SERVICE wikibase:label { bd:serviceParam wikibase:language "en" } inside your WHERE clause Append the magic string Label and Description to the variable names of your SELECT For instance, if ...
Nicolas Raoul's user avatar
  • 8,426
4 votes
Accepted

Wikidata label language: How to fallback to ANY language?

As optional get the label in English and in any language, then coalesce: SELECT ?item (SAMPLE(COALESCE(?en_label, ?item_label)) as ?label) WHERE { ?item wdt:P31 wd:Q22674925 . OPTIONAL {?item ...
Nicolas Raoul's user avatar
  • 8,426
4 votes

How to add a claim to an existing Wikidata item, from command line?

You can use wikidata-agent for that: curl -XPOST http://your.wikidata.agent.instance/claim -d 'entity=Q5369879&property=P137&value=Q39' [Update]: you can now actually add claims using ...
maxlath's user avatar
  • 266
4 votes
Accepted

Constructing a WordNet-like tree from the Wikidata dataset?

I would say that the P279-property (subclass of) will span a semantic "tree" (it is not necessarily a tree but a directed graph). You might be able to build semantic trees from other Wikidata ...
Finn Årup Nielsen's user avatar
4 votes

Publishing (structured?) data about products: information about products, barcodes, photos (incl. packaging)

As you can see in Wikimedia Commons, packages usually involve some copyrighted content and therefore its image can't be published under a free license. It can only be published with permission of ...
Pere's user avatar
  • 381
4 votes
Accepted

Retrieve periodic table information from wikidata

Using the series ordinal added to the chemical groups, I can extract the group and period numbers with this query. SELECT ?element ?symbol ?protons ?group ?groupNumber ?period ?periodNumber WHERE { ...
Ben's user avatar
  • 201
4 votes
Accepted

get item's properties know QID

I asked similar question on SO and got 2 answers. first answer: Using the URI instead of the variable ?item will get the information based on the entity Albert Einstein: PREFIX schema: <...
Alexan's user avatar
  • 442
4 votes
Accepted

Weird results in search from wikidata

...like if I made the filter of my 50 previous results... Wikibase:mwapi supports the limit parameter of the Entity Search service: SELECT ?item ?label ?order WHERE { VALUES (?type ?name) {(wd:Q5 "...
Stanislav Kralin's user avatar
4 votes
Accepted

Search in wikidata with specific Q code

In short, URIs are "things, not strings". The filtering condition should be: ?item = <http://www.wikidata.org/entity/Q6015113>, or ?item = wd:Q6015113, or ?item = URI("http://www.wikidata.org/...
Stanislav Kralin's user avatar
4 votes
Accepted

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

There isn't an article about Татьяна Колотильщикова in English Wikipedia. Just comment out the second and the third triple patterns in your query. Or try e. g. Q11000001 instead of Q10000001.
Stanislav Kralin's user avatar
4 votes
Accepted

Limiting a SPARQL Query to Lastest Point in Time

SELECT ?itemLabel ?population ?date { ?item wdt:P31 wd:Q50337; p:P1082 [pq:P585 ?date; ps:P1082 ?population] FILTER NOT EXISTS {?item p:P1082 [pq:P585 ?date_] FILTER (?date_ > ?date)} ...
Stanislav Kralin's user avatar
4 votes
Accepted

Does Wikidata offer inferencing/reasoning?

You can test that by inspecting the results of executing a query that assumes reasoning. For example, subclass of in RDFS is a transitive property. Therefore, querying for subclass of author, should ...
pgmank's user avatar
  • 161
3 votes

How to get urls of entries in wikipedia list articles?

You might also use the SPARQL REST API to query wiki data. E.g. get a table of US citizens whose occupation is a subclass of scientist: PREFIX schema: <http://schema.org/> SELECT ?item ?...
aventurin's user avatar
  • 191
3 votes
Accepted

How to get urls of entries in wikipedia list articles?

You can use the links API property to get the titles of all the links on the page: https://en.wikipedia.org/w/api.php?action=query&format=jsonfm&titles=List_of_American_scientists&prop=...
NinjaBearMonkey's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible