-1

Trying to create a query for SPARQL to extract all the school infobox data on dbpedia. Does that dataset already exist? (I am still confused after trying to read and understand the examples.) It seems like this specific wikipedia infobox data must exist in dbpedia but I can't figure out if it does already. If I want to export all college and university school infobox data is it possible easily do so?

1 Answers1

1

All classes in DBpedia that have maybe something to do with school or college (YAGO classes omitted for brevity):

select ?cls where {
  ?cls a owl:Class. 
  filter(regex(str(?cls), 'college|school', 'i'))
}

Output:

+------------------------------------------+
|                   cls                    |
+------------------------------------------+
| http://dbpedia.org/ontology/College      |
| http://dbpedia.org/ontology/CollegeCoach |
| http://dbpedia.org/ontology/SambaSchool  |
| http://dbpedia.org/ontology/School       |
+------------------------------------------+

If we take the http://dbpedia.org/ontology/School as an example, the query to get all the data would be something like

select * where {
  ?s a <http://dbpedia.org/ontology/School> ;
     ?p ?o 
}

a lots of data is rdf:type, rdfs:label, owl:sameAs etc., but to see that also the other more interesting data is returned, you can try

select * where {
  ?s a <http://dbpedia.org/ontology/School> . 
  ?s ?p ?o 
  filter(?p not in (rdf:type, owl:sameAs, rdfs:label, rdfs:comment, rdfs:seeAlso))
}

Note, that this query might not return all data you need, I just wanted to show you how to start

UninformedUser
  • 8,397
  • 1
  • 14
  • 23