SPARQL query against https://dbpedia.org/sparql/ - how to edit the *source* data?

33 Views Asked by At

I'm new to SPARQL and RDF etc. I have the following query: the intention is to find people on wikipedia who are somehow linked to another person.

PREFIX rdf: 
PREFIX rdfs: 
PREFIX schema: 
SELECT *
WHERE
{
    ?person rdfs:label 'Douglas Adams'@en.
    ?person rdf:type dbo:Person.
    ?person foaf:isPrimaryTopicOf ?wikipage.
    ?person dbo:wikiPageWikiLink ?linkedPerson.
    ?linkedPerson rdf:type dbo:Person.
    ?linkedPerson foaf:isPrimaryTopicOf ?Linkedwikipage.
}

This mostly works - however - one result returned is NOT a person - it is a comedy radio show : https://dbpedia.org/page/The_News_Huddlines

It looks to me that it is wrongly labelled. (But is there something I could do with my SPARQL to handle this better?).

The query returns the corresponding source wikipedia page:

https://en.wikipedia.org/wiki/The_News_Huddlines

But how do I edit the 'rdf:type' to fix this?

For completeness - here's the script I'm running the query ('linked.rq') with:

export ENDPOINT="https://dbpedia.org/sparql/"
export HEADER="accept:text/xml, application/sparql-results+xml"

export QUERY=`cat linked.rq`
curl --header "$HEADER" --data-urlencode "query=$QUERY" $ENDPOINT -o res.xml

EDIT: The following modification seems to help eliminate some noise in the data: makes sure the linked node has a property of 'birthdate':

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX schema: <http://schema.org/>
SELECT *
WHERE
{
?person rdfs:label 'Douglas Adams'@en.
?person rdf:type dbo:Person. 
?person foaf:isPrimaryTopicOf ?wikipage.
?person dbo:wikiPageWikiLink ?linkedPerson.
?linkedPerson rdf:type dbo:Person. 
?linkedPerson foaf:isPrimaryTopicOf ?linkedwikipage.
?linkedPerson dbo:birthDate ?_.
}

EDIT2:

Slightly improved query - avoid using birthdate - but just add 'foaf' vocabulary to try and weed out bad records. (Other vocabs could also help as well I guess).

SELECT *
WHERE
{
?person rdfs:label 'Douglas Adams'@en;
               rdf:type dbo:Person;
               foaf:isPrimaryTopicOf ?wikipage;
               dbo:wikiPageWikiLink ?linkedPerson.
?linkedPerson rdf:type  dbo:Person,
                        foaf:Person;
              foaf:isPrimaryTopicOf ?linkedwikipage.
}
0

There are 0 best solutions below