LearnToGrow
LearnToGrow

Reputation: 1750

How to get the WikiPageRedirects attribute for a dbpedia resource

I want to write a sparql query to return the WikiPageRedirects attribute for a given dbpedia resource.

For example: MongoDB has 3 as depicted here https://dbpedia.org/page/MongoDB

I write this query to get them:

PREFIX dbo: <http://dbpedia.org/ontology/>
SELECT ?alias
WHERE {
    VALUES (?resource) { (dbo:MongoDB) }
    ?resource dbo:wikiPageRedirects ?alias .
}

but it does not display anything sparql

Upvotes: 1

Views: 38

Answers (1)

There are two issues involved:

  • The URI of the the resource MongoDB is not dbo:MongoDB (→ http://dbpedia.org/ontology/MongoDB), but dbr:MongoDB (→ http://dbpedia.org/resource/MongoDB).

  • The property dbo:wikiPageRedirects has to be used in the other direction. On the linked MongoDB page, this is indicated by the "is … of" ("is dbo:wikiPageRedirects of").

So your query could be:

PREFIX dbr: <http://dbpedia.org/resource/>
PREFIX dbo: <http://dbpedia.org/ontology/>
SELECT ?alias
WHERE {
    VALUES (?resource) { (dbr:MongoDB) }
    ?resource ^dbo:wikiPageRedirects ?alias .
}

or:

PREFIX dbr: <http://dbpedia.org/resource/>
PREFIX dbo: <http://dbpedia.org/ontology/>
SELECT ?alias
WHERE {
    VALUES (?resource) { (dbr:MongoDB) }
    ?alias dbo:wikiPageRedirects ?resource .
}

Upvotes: 0

Related Questions