Monthly Archives: August 2018

Querying public knowledge graph databases

You can query public knowledge graph databases (like wikidata.org and dbpedia.org) using SPARQL. For instance for extracting all “known” programming languages, you can use the query

SELECT ?item ?itemLabel WHERE {
  ?item wdt:P31 wd:Q9143.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
LIMIT 1000

There are also SPARQL clients for most of programming languages.

With (swi) prolog you can easily run

[library(semweb/sparql_client)].
sparql_query('SELECT ?item ?itemLabel WHERE {?item wdt:P31 wd:Q9143. SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }} LIMIT 1000', Row, [ scheme(https),host('query.wikidata.org'), path('/sparql')]).