I am currently querying DBPedia for a list of person names by using the SPARQL package in R. And now I am working on counting of different categories for one person, such as the number of wikilink or external_link. But I only know to count all the items together per person, such as:
query= "SELECT COUNT (*){
<http://dbpedia.org/resource/Philipp_Melanchthon> ?p ?o
}"
This just print out the count of all the items for one person, is there any way to print out the count of different categories for one person respectively? Many thx.
As you pointed out the following query gives you all the relations and objects related to it:
SELECT distinct *{
dbpedia:Philipp_Melanchthon ?p ?o.
}
If you want to find out the external links, you need to replace ?p
with the appropriate property in this case dbpedia-owl:wikiPageExternalLink
:
SELECT distinct *{
dbpedia:Philipp_Melanchthon dbpedia-owl:wikiPageExternalLink ?o.
}
Thus count will give you the external links:
SELECT (count(?o)){
dbpedia:Philipp_Melanchthon dbpedia-owl:wikiPageExternalLink ?o.
}