Next Step Semantic WebUK Prime Ministers, their Parties and their Religions

# U.S. Presidents and their Religions

I was wondering about the , and wondered what their religions were. So I zipped up some SPARQL queries to run against DBpedia, they aren’t perfect (i.e. they don’t capture all of the presidents due to mislabeling and me not being too bothered about the answers), but it provides some answers.

The Democrats:

SELECT ?PresidentName ?ReligionName
WHERE
{
?president
dbpprop:party <https://dbpedia.org/resource/Democratic_Party_%28United_States%29>;
dbpprop:order dbpedia:President_of_the_United_States;
<https://dbpedia.org/ontology/religion> ?Religion;
rdfs:label ?PresidentName.
FILTER (lang(?PresidentName) = "" || langMatches(lang(?PresidentName), "en")).
?Religion rdfs:label ?ReligionName.
FILTER (lang(?ReligionName) = "" || langMatches(lang(?ReligionName), "en"))
} ORDER BY ?ReligionName

Which the answer is viewable “Democratic Presidents Religions”

The Republicans

SELECT ?PresidentName ?ReligionName
WHERE
{
?president
dbpprop:party <https://dbpedia.org/resource/Republican_Party_%28United_States%29>;
dbpprop:order dbpedia:President_of_the_United_States;
<https://dbpedia.org/ontology/religion> ?Religion;
rdfs:label ?PresidentName.
FILTER (lang(?PresidentName) = "" || langMatches(lang(?PresidentName), "en")).
?Religion rdfs:label ?ReligionName.
FILTER (lang(?ReligionName) = "" || langMatches(lang(?ReligionName), "en"))
} ORDER BY ?Religion

Which the answer is available directly here: “Republican Presidents religions”

Please note

  • It doesn’t return all presidents of the parties
  • It does use the DBPedia SPARQL engine (powered by OpenLink Virtuoso)
  • It does use some shortcuts (i.e. not defining PREFIXs and the FROM clause), as the DBPedia SPARQL engine provides these nice shortcuts.

Leave a Reply