Counting DBpedia wikilink and xref numbers using SPARQL
I am currently querying DBPedia for a list of people's names using the SPARQL package in R. And now I am working on counting different categories for one person, like wikilink number or external_link . But I only know to count all items together per person, for example:
query= "SELECT COUNT (*){
<http://dbpedia.org/resource/Philipp_Melanchthon> ?p ?o
}"
This will just print the count of all items for one person, is there a way to print the counter of different categories for one person respectively? Many thanks.
source to share
As you noted, the following query gives you all the relationships and objects associated with it:
SELECT distinct *{
dbpedia:Philipp_Melanchthon ?p ?o.
}
If you want to know external links, you need to replace with the ?p
appropriate property in this case dbpedia-owl:wikiPageExternalLink
:
SELECT distinct *{
dbpedia:Philipp_Melanchthon dbpedia-owl:wikiPageExternalLink ?o.
}
So counting will give you external links:
SELECT (count(?o)){
dbpedia:Philipp_Melanchthon dbpedia-owl:wikiPageExternalLink ?o.
}
source to share