Querying public knowledge graph databases

2018-08-18

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')\]).

Enter your instance's address


More posts like this

Smart investment Problem with Prolog

2024-07-14 | #programming #prolog

Below my #prolog solution for Smart investment problem. It is a sample of Linear Programming using Prolog. A client of an investment firm has $10000 available for investment. He has instructed that his money be invested in particular stocks, so that no more than $5000 is invested in any one stock but at least $1000 be invested in each stock.

Continue reading 