Wikidata is a collaboratively edited multilingual knowledge graph hosted by the Wikimedia Foundation.[2] It is a common source of open data that Wikimedia projects such as Wikipedia
Wikidata is a free and open knowledge base that can be read and edited by both humans and machines.
Wikidata acts as central storage for the structured data of its Wikimedia sister projects including Wikipedia, Wikivoyage, Wiktionary, Wikisource, and others.
Wikidata:SPARQL tutorial - Wikidata
- Wikidata is a knowledge database. It contains millions of statements, such as “the capital of Canada is Ottawa”, or “the Mona Lisa is painted in oil paint on poplar wood”, or “gold has a melting point of 1,064.18 degrees Celsius”.
- SPARQL is a language to formulate questions (queries) for knowledge databases. With the right database, a SPARQL query could answer questions like “what is the most popular tonality in music?” or “which character was portrayed by the most actors?” or “what’s the distribution of blood types?” or “which authors’ works entered the public domain this year?”.
- WDQS, the Wikidata Query Service, brings the two together: You enter a SPARQL query, it runs it against Wikidata’s dataset and shows you the result.
SPARQL (pronounced "sparkle" /ˈspɑːkəl/, a recursive acronym[2] for SPARQL Protocol and RDF Query Language) is an RDF query language—that is, a semantic query language for databases—able to retrieve and manipulate data stored in Resource Description Framework (RDF) format.
example:
q = `#Movies released in 2017
SELECT DISTINCT ?item ?itemLabel WHERE {
SELECT DISTINCT ?item ?itemLabel WHERE {
?item wdt:P31 wd:Q11424.
?item wdt:P577 ?pubdate.
FILTER((?pubdate >= "2017-01-01T00:00:00Z"^^xsd:dateTime) && (?pubdate <= "2017-12-31T00:00:00Z"^^xsd:dateTime))
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}`
GET https://query.wikidata.org/sparql?query=uleEncode(q)
#Movies with Bruce Willis
SELECT ?item ?itemLabel (MIN(?date) AS ?firstReleased) ?_image
WHERE {
?item wdt:P161 wd:Q2680; wdt:P577 ?date
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
OPTIONAL { ?item wdt:P18 ?_image. }
} GROUP BY ?item ?itemLabel ?_image
ORDER BY (?date)
maxlath/wikibase-sdk: JS utils functions to query a Wikibase instance and simplify its results @GitHub
examples:
item types
prop types
cast member - Wikidata (P161) (actor in movie)
publication date - Wikidata (P577)
No comments:
Post a Comment