I wrote a python script that goes through a list of URI's and runs the following query on each of them:
query = "SELECT ?subject WHERE {<http://dbpedia.org" + uri + "> dct:subject ?subject.}"
This works when the given URI is correct, such as
/resource/Android_TV
.
But in my list of URI's I also have other URI's such as /resource/Sheldon_J._Plankton
.
When I run this query it doesn't find anything, but if I go to the corresponding DBPedia page http://dbpedia.org/resource/Sheldon_J._Plankton
it changes to
http://dbpedia.org/page/Plankton_(character)
.
So apparantly the correct URI for this page would be:
resource/Plankton_(character)
.
Is it possible to write the query in such a way that it changes the URI to be correct? This list of URI's is very, very long so I can't manually check and fix them unfortunately.
You can follow <http://dbpedia.org/ontology/wikiPageRedirects>
:
<http://dbpedia.org/resource/Sheldon_J._Plankton> dbo:wikiPageRedirects*/dct:subject ?subject .
The *
will make the property path match zero or more redirects.