I'm trying to run a query on DBPedia.org via SPARQL. Basically, here's what I want to do:
WHERE
AND
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:
SELECT DISTINCT ?s
WHERE {
{
?s <http://xmlns.com/foaf/0.1/name> "Google Inc."@en .
} UNION {
?s <http://dbpedia.org/property/companyName> "Google Inc."@en .
} UNION {
?s <http://dbpedia.org/property/name> "Google Inc."@en .
}
{
?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> .
}
}
Note that I added a DISTINCT
to eliminate duplicate answers that arise when a resource has multiple values, e.g. for foaf:name
and dbpprop:companyName
.