I’m trying to run a query on DBPedia.org via SPARQL. Basically, here’s what I want to do:
- Get a list of DBPedia resource links
WHERE
- foaf:name (http://xmlns.com/foaf/0.1/name) is equal to PARAMETER1
- Or dbpprop:companyName (http://dbpedia.org/property/companyName) is equal to PARAMETER1
- Or dbpprop:name (http://dbpedia.org/property/name) is equal to PARAMETER1
AND
- rdf:type (http://www.w3.org/1999/02/22-rdf-syntax-ns#type) is equal to PARAMETER2
- Or dbpedia-owl:type (http://dbpedia.org/ontology/type) is equal to PARAMETER2
I’ve tried doing this myself, but utterly failed to get any successful results.
Any help will be appreciated – thanks!
Edit:
Here’s a query that I’ve been working on:
SELECT ?s
WHERE {
{
?s <http://xmlns.com/foaf/0.1/name> "Google Inc." .
} UNION {
?s <http://dbpedia.org/property/companyName> "Google Inc." .
} UNION {
?s <http://dbpedia.org/property/name> "Google Inc." .
}
{
?s <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://dbpedia.org/ontology/Company> .
} UNION {
?s <http://dbpedia.org/ontology/type> <http://dbpedia.org/resource/Public_company> .
}
}
You almost had it, the only problem is that property values in DBPedia use language tags and your query looks for names with plain literal values. This query works for me:
Note that I added a
DISTINCTto eliminate duplicate answers that arise when a resource has multiple values, e.g. forfoaf:nameanddbpprop:companyName.