How can I get a list of all organisations from DBpedia? By "organisation", I mean a entity of any type that is either a organisation or any subclass of organisation.
I found the question How to get all companies from DBPedia? but this doesn't work in the current DBpedia SPARQL web version and I wasn't able to adapt the query.
To simply get all resources that are an instance of dbo:Organization
or its subclass:
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX dbo: <http://dbpedia.org/ontology/>
SELECT DISTINCT ?org { ?org a/rdfs:subClassOf* dbo:Organisation . }
However, as the question you linked shows, DBpedia has a cap on how many results are returned. So, as in the answer to said question, you can use a subquery with LIMIT
and OFFSET
to get all the results in chunks:
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX dbo: <http://dbpedia.org/ontology/>
SELECT ?org {
SELECT DISTINCT ?org {
?org a/rdfs:subClassOf* dbo:Organisation .
} ORDER BY ?org
}
LIMIT 10000 OFFSET 0
This would get you the first 10000 results. To get the next 10000, just add 10000 to the offset: LIMIT 10000 OFFSET 10000
. Then, the next 10000 with OFFSET 20000
, and so on.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With