Sinay Elihay
Sinay Elihay

Reputation: 31

How can I pull the Wikidata description?

I'm trying to pull the wikidata description of biblical figures. For example, for David, this would pull: king of Israel and Judah.

Here's what I started with:

select ?person ?personLabel
where {
  ?person wdt:P31 wd:Q20643955.
  SERVICE wikibase:label {
    bd:serviceParam wikibase:language "en" .
  }
}

Upvotes: 2

Views: 196

Answers (1)

logi-kal
logi-kal

Reputation: 7880

From Wikidata Query Service/User Manual § Label_service:

You can fetch the label, alias, or description [...] In automatic mode, you only need to specify the service template, e.g.:

PREFIX wikibase: <http://wikiba.se/ontology#>
SERVICE wikibase:label {
    bd:serviceParam wikibase:language "en" .
}

and WDQS will automatically generate labels as follows:

  • If an unbound variable in SELECT is named ?NAMELabel, then WDQS produces the label (rdfs:label) for the entity in variable ?NAME.
  • If an unbound variable in SELECT is named ?NAMEAltLabel, then WDQS produces the alias (skos:altLabel) for the entity in variable ?NAME.
  • If an unbound variable in SELECT is named ?NAMEDescription, then WDQS produces the description (schema:description) for the entity in variable ?NAME.

So you can just specify ?personDescription among your selected variables.

Here an example.

Upvotes: 3

Related Questions