SPARQL: Given a dbpedia url, how can I determine if the entity is a person?
Asked Answered
R

1

6

If I have a dbpedia url (i.e., http://dbpedia.org/page/Abraham_Lincoln), how can I query SPARQL to verify if the entity (in this case Abraham Lincoln) is a person? It occurred to me that I could return all the rdf:type values and then check to see if foaf:Person or dbo:Person are in the output, but it would be more convenient to just get a true/false response.

Rivas answered 2/3, 2017 at 1:26 Comment(0)
V
12

Use a SPARQL ASK query? This answer should have been found by yourself when looking into the W3C recommendation

ASK { ?s rdf:type <SOME_CLASS_URI> }

Note, it allows for more complex query pattern of course:

ASK {
   { ?s rdf:type foaf:Person }
  UNION 
   { ?s rdf:type dbo:Person }
}
Vaca answered 2/3, 2017 at 5:8 Comment(4)
Or ASK { values ?person { foaf:Person dbo:Person } ?s a ?person }. (I just like using values instead of UNION, since it scales more easily, and makes the logic a bit clearer.Ilowell
According to AKSW this question is "too obvious" to even ask, so if there aren't any objections, I'll delete it.Rivas
Well it could have been found yes but many people never heard of anything else than SELECT queries so there might be some reason to keep it.Obsecrate
Quite. There is nothing obvious about this to someone who is just starting with SPARQL. More real world examples are generally useful IMHO.Benevento

© 2022 - 2024 — McMap. All rights reserved.