User:Aude/wikidata-guide: Difference between revisions
m AudeBot moved page User:Aude/presidents to User:Aude/wikidata-guide |
|||
Line 51: | Line 51: | ||
* Wikibase property (inverse of, subproperty of, …) |
* Wikibase property (inverse of, subproperty of, …) |
||
=== Further information |
=== Further information === |
||
* https://tools.wmflabs.org/hay/propbrowse/ |
* https://tools.wmflabs.org/hay/propbrowse/ |
Revision as of 16:26, 15 January 2017
Einführung
Wikidata is one of the newest sister projects of the Wikipedia.
- launched in 2012
- Now (as of January 2017) there are more than 24 million items
- 130 million statements
- provides centralized, multilingual structured data repository
- linked data - connects to other resources about a topic, such as through site links to pages on Wikimedia projects or through identifiers for external databases and resources.
data is licensed under Creative Commons Zero (CC-0), essentially public domain.
- powered by Wikibase, a set of MediaWiki extensions that allow storing structured data (json blobs) in place of wikitext.
- Wikidata items are editable, with revision history and other standard features that MediaWiki provides.* Data is machine readable, thus more easily queryable and reusable in third-party applications.
Videos
https://www.youtube.com/watch?v=7xyPiYvy0GA (Introduction by Asaf Bartov at WikiConference India) https://www.youtube.com/watch?v=qGfSDna3cJM (Presentation by Lydia)
Anatomy of a Wikidata item
Item with a statement
Item with multiple statements (statement group)
Wikidata in other languages
Labels, descriptions and aliases in other languages can be viewed and edited by clicking on "in more languages" / "All entered languages".
Interface language can be changed (currently only for logged-in users), using the language selector at the top of the page:
Properties
Property data types available
- Commons media (image, flag image, video, …)
- Globe coordinate (coordinate location, …)
- Identifier (geonames id, VIAF identifier, ...)
- Math (defining formula)
- Monolingual text (motto text, official name, …)
- Quantity - optionally, with units (area, population, …)
- String (formatter URL, serials ordinal, …)
- Time (date of birth, point in time, …)
- URL (official website, …)
- Wikibase item (instance of, head of government, …)
- Wikibase property (inverse of, subproperty of, …)
Further information
- https://tools.wmflabs.org/hay/propbrowse/
- Wikidata:List_of_properties
- Wikidata:Property_proposal
- Wikidata:Infoboxes_task_force
Bots
Request a bot to help
Creating a bot
- Wikidata:Bots - list of existing bots and general info
- Wikidata:Creating a bot (pywikibot has good support for Wikidata)
Data donations
Wikipedia integration
- TODO
Videos
- https://www.youtube.com/watch?v=U6llqWixxM4 - protein infoboxes
Wikidata Query Service
RDF
The query service uses RDF representation of Wikidata items.
RDF triples:
Subject : Predicate : Object
Q38 (Italy) : P36 (Capital) : Q220 (Rome)
using URIs (concept URIs):
http://www.wikidata.org/entity/Q38 : http://www.wikidata.org/prop/direct/P36 : http://www.wikidata.org/entity/Q220
Turtle
Flavor of RDF (Terse RDF Triple Language)
@prefix wd: http://www.wikidata.org/entity/ @prefix wdt: http://www.wikidata.org/prop/direct/ wd:Q38 : wdt:P36 : wd:Q220
SPARQL
SPARQL is a W3C standardized RDF query language.
Example:
Return all items with "instance of" (P31) = cat (Q146).
PREFIX wd: <http://www.wikidata.org/entity/> PREFIX wdt: <http://www.wikidata.org/prop/direct/> SELECT ?subject WHERE { ?subject wdt:P31 wd:Q146 }
GUI
There is a graphical user interface on https://query.wikidata.org for exploring the query service and building / running queries.
Cats
Cats with images
United States Presidents queries
List of all U.S. Presidents, sorted by label
SELECT ?item ?itemLabel WHERE { ?item wdt:P39 wd:Q11696 . SERVICE wikibase:label { bd:serviceParam wikibase:language "en" } } ORDER BY ?itemLabel
List of all U.S. Presidents, sorted by label, excluding fictional characters (only instance of = human)
SELECT ?item ?itemLabel WHERE { ?item wdt:P39 wd:Q11696 . ?item wdt:P31 wd:Q5 . SERVICE wikibase:label { bd:serviceParam wikibase:language "en" } } ORDER BY ?itemLabel
Pets
SELECT ?petLabel ?ownerLabel { ?pet wdt:P31/wdt:P279* wd:Q622852 . ?pet wdt:P127 ?owner SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } }
Presidential pets
SELECT DISTINCT ?pet ?petLabel ?ownerLabel { ?pet wdt:P31/wdt:P279* wd:Q622852 . ?pet wdt:P127 ?owner . ?owner wdt:P39 wd:Q11696 . ?pet wdt:P18 ?image . SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } }
Presidential pets with images
SELECT ?petLabel ?ownerLabel ?image { ?pet wdt:P31/wdt:P279* wd:Q622852 . ?pet wdt:P127 ?owner . ?owner wdt:P39 wd:Q11696 . ?pet wdt:P18 ?image . SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } }
Presidential pets, one image per pet
SELECT DISTINCT ?pet ?petLabel ?ownerLabel (SAMPLE(?image) as ?image) { ?pet wdt:P31/wdt:P279* wd:Q622852 . ?pet wdt:P127 ?owner . ?owner wdt:P39 wd:Q11696 . ?pet wdt:P18 ?image . SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } } GROUP BY ?pet ?petLabel ?ownerLabel
Species named after a U.S. President
SELECT ?taxon ?taxonLabel ?name WHERE { ?taxon wdt:P31 wd:Q16521; wdt:P138 ?namedAfter . ?namedAfter wdt:P39 wd:Q11696 . OPTIONAL { ?taxon wdt:P225 ?name. } SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } }
U.S. Presidents, with date and place of birth
SELECT ?item ?itemLabel ?dateOfBirth ?placeOfBirth WHERE { BIND(wd:Q11696 AS ?president) ?item wdt:P31 wd:Q5 . ?item wdt:P39 ?president . ?item wdt:P19 ?placeOfBirth . ?item wdt:P569 ?dateOfBirth . SERVICE wikibase:label { bd:serviceParam wikibase:language "en" } } ORDER BY ?dateOfBirth
U.S. Presidents, date and cause of death
SELECT ?item ?itemLabel ?dateOfDeath ?causeOfDeathLabel WHERE { BIND(wd:Q11696 AS ?president) ?item wdt:P31 wd:Q5 . ?item wdt:P39 ?president . ?item wdt:P570 ?dateOfDeath . ?item wdt:P509 ?causeOfDeath . SERVICE wikibase:label { bd:serviceParam wikibase:language "en" } } ORDER BY ?dateOfDeath
U.S. Presidents, cause of death, grouped by cause
SELECT ?causeOfDeathLabel (COUNT(?causeOfDeathLabel) as ?count) WHERE { BIND(wd:Q11696 AS ?president) ?item wdt:P31 wd:Q5 . ?item wdt:P39 ?president . ?item wdt:P509 ?causeOfDeath . SERVICE wikibase:label { bd:serviceParam wikibase:language "en" } } GROUP BY ?causeOfDeathLabel ?count ORDER BY DESC(?count)
U.S. Presidents, place of birth
SELECT ?placeOfBirthLabel ?itemLabel ?placeOfBirthCoord WHERE { BIND(wd:Q11696 AS ?president) ?item wdt:P31 wd:Q5 . ?item wdt:P39 ?president . ?item wdt:P19 ?placeOfBirth . ?placeOfBirth wdt:P625 ?placeOfBirthCoord . SERVICE wikibase:label { bd:serviceParam wikibase:language "en" } } ORDER BY ?placeOfBirthLabel
List of U.S. Presidents, sorted by label, excluding fictional characters (only instance of = human) (Alternative)
SELECT ?item ?itemLabel ?statement WHERE { BIND(wd:Q11696 AS ?president) ?item wdt:P31 wd:Q5 . ?item p:P39 ?statement . ?statement ps:P39 ?president . SERVICE wikibase:label { bd:serviceParam wikibase:language "en" } } ORDER BY ?itemLabel
U.S. Presidents, each listed only once
SELECT ?item ?itemLabel WHERE { BIND(wd:Q11696 AS ?president) ?item wdt:P31 wd:Q5 . ?item p:P39 ?statement . ?statement ps:P39 ?president . SERVICE wikibase:label { bd:serviceParam wikibase:language "en" } } GROUP BY ?item ?itemLabel ORDER BY ?itemLabel
List of U.S. Presidents, sorted by label, with start date
SELECT ?item ?itemLabel ?start WHERE { BIND(wd:Q11696 AS ?president) ?item wdt:P31 wd:Q5 . ?item p:P39 ?statement . ?statement ps:P39 ?president . ?statement pq:P580 ?start SERVICE wikibase:label { bd:serviceParam wikibase:language "en" } } ORDER BY ?itemLabel
List of U.S. Presidents, sorted by label, with earliest start date
SELECT ?item ?itemLabel (MIN(?start) as ?start) WHERE { BIND(wd:Q11696 AS ?president) ?item wdt:P31 wd:Q5 . ?item p:P39 ?statement . ?statement ps:P39 ?president . ?statement pq:P580 ?start SERVICE wikibase:label { bd:serviceParam wikibase:language "en" } } GROUP BY ?item ?itemLabel ORDER BY ?itemLabel
List of U.S. Presidents, sorted by start date
SELECT ?item ?itemLabel (MIN(?start) as ?start) WHERE { BIND(wd:Q11696 AS ?president) ?item wdt:P31 wd:Q5 . ?item p:P39 ?statement . ?statement ps:P39 ?president . ?statement pq:P580 ?start SERVICE wikibase:label { bd:serviceParam wikibase:language "en" } } GROUP BY ?item ?itemLabel ORDER BY ?start
Number of children of each U.S. President
SELECT ?item ?itemLabel (COUNT(?child) as ?count) WHERE { ?item wdt:P31 wd:Q5 . ?item wdt:P39 wd:Q11696 . ?item wdt:P40 ?child . SERVICE wikibase:label { bd:serviceParam wikibase:language "en" } } GROUP BY ?item ?itemLabel ?count ORDER BY DESC(?count) ?itemLabel
Count of children on Presidents' items vs. "number of children" (P1971)
SELECT ?item ?itemLabel ?numOfChildren (COUNT(?child) as ?count) WHERE { ?item wdt:P31 wd:Q5 . ?item wdt:P39 wd:Q11696 . ?item wdt:P1971 ?numOfChildren . ?item wdt:P40 ?child . SERVICE wikibase:label { bd:serviceParam wikibase:language "en" } } GROUP BY ?item ?itemLabel ?count ?numOfChildren ORDER BY DESC(?numOfChildren) ?itemLabel
List of children of U.S. Presidents
SELECT ?item ?itemLabel ?childLabel (MIN(?start) as ?start) WHERE { BIND(wd:Q11696 AS ?president) ?item wdt:P31 wd:Q5 . ?item wdt:P40 ?child . ?item p:P39 ?statement . ?statement ps:P39 ?president . ?statement pq:P580 ?start . SERVICE wikibase:label { bd:serviceParam wikibase:language "en" } } GROUP BY ?item ?itemLabel ?childLabel ?start ORDER BY ?start
Children of U.S. Presidents, with child's date of birth
SELECT ?item ?itemLabel ?childLabel ?childDateOfBirth WHERE { BIND(wd:Q11696 AS ?president) ?item wdt:P31 wd:Q5 . ?item wdt:P40 ?child . ?item p:P39 ?statement . ?statement ps:P39 ?president . ?statement pq:P580 ?start . ?child wdt:P569 ?childDateOfBirth . SERVICE wikibase:label { bd:serviceParam wikibase:language "en" } } GROUP BY ?item ?itemLabel ?childLabel ?childDateOfBirth ORDER BY ?start
Children of U.S. Presidents, sorted by child's date of birth
SELECT ?childLabel ?itemLabel ?childDateOfBirth WHERE { BIND(wd:Q11696 AS ?president) ?item wdt:P31 wd:Q5 . ?item wdt:P40 ?child . ?item p:P39 ?statement . ?statement ps:P39 ?president . ?statement pq:P580 ?start . ?child wdt:P569 ?childDateOfBirth . SERVICE wikibase:label { bd:serviceParam wikibase:language "en" } } GROUP BY ?itemLabel ?childLabel ?childDateOfBirth ORDER BY ?childDateOfBirth
Daughters of U.S. Presidents, sorted by child's date of birth
SELECT ?childLabel ?itemLabel ?childDateOfBirth WHERE { BIND(wd:Q11696 AS ?president) ?item wdt:P31 wd:Q5 . ?item wdt:P40 ?child . ?item p:P39 ?statement . ?statement ps:P39 ?president . ?statement pq:P580 ?start . ?child wdt:P569 ?childDateOfBirth . ?child wdt:P21 wd:Q6581072 . SERVICE wikibase:label { bd:serviceParam wikibase:language "en" } } GROUP BY ?itemLabel ?childLabel ?childDateOfBirth ORDER BY ?childDateOfBirth
Children of U.S. Presidents, born in New York State
SELECT ?childLabel ?itemLabel ?childDateOfBirth WHERE { BIND(wd:Q11696 AS ?president) ?item wdt:P31 wd:Q5 . ?item wdt:P40 ?child . ?item p:P39 ?statement . ?statement ps:P39 ?president . ?statement pq:P580 ?start . ?child wdt:P569 ?childDateOfBirth . ?child wdt:P19 ?placeOfBirth . ?placeOfBirth wdt:P131/wdt:P279* wd:Q1384 SERVICE wikibase:label { bd:serviceParam wikibase:language "en" } } GROUP BY ?itemLabel ?childLabel ?childDateOfBirth ORDER BY ?childDateOfBirth
Children of U.S. Presidents with an article in German Wikipedia
SELECT ?childLabel ?itemLabel ?childDateOfBirth WHERE { BIND(wd:Q11696 AS ?president) ?item wdt:P39 wd:Q11696 . ?item wdt:P31 wd:Q5 . ?item wdt:P40 ?child . ?child wdt:P569 ?childDateOfBirth . ?sitelink schema:about ?child . FILTER EXISTS { ?article schema:about ?child . ?article schema:inLanguage "de" . ?article schema:isPartOf <https://de.wikipedia.org/> } SERVICE wikibase:label { bd:serviceParam wikibase:language "en" } } GROUP BY ?itemLabel ?childLabel ?childDateOfBirth ORDER BY ?childDateOfBirth
Children of U.S. Presidents without an article in German Wikipedia
SELECT ?childLabel ?itemLabel ?childDateOfBirth WHERE { BIND(wd:Q11696 AS ?president) ?item wdt:P39 wd:Q11696 . ?item wdt:P31 wd:Q5 . ?item wdt:P40 ?child . ?child wdt:P569 ?childDateOfBirth . ?sitelink schema:about ?child . FILTER NOT EXISTS { ?article schema:about ?child . ?article schema:inLanguage "de" . ?article schema:isPartOf <https://de.wikipedia.org/> } SERVICE wikibase:label { bd:serviceParam wikibase:language "en" } } GROUP BY ?itemLabel ?childLabel ?childDateOfBirth ORDER BY ?childDateOfBirth