I am trying to write a SPARQL query to retrieve all pages that are linked to neighborhoods on Wikipedia. An example is http://live.dbpedia.org/page/Carter_Crest,_Edmonton. The property type is http://dbpedia.org/property/settlementType where settlementType should be "neighbourhood", the other option is template:infobox_settlement. So far, I've tried the following:
SELECT ?property ?hasValue ?isValueOf
WHERE {
{ <http://dbpedia.org/ontology/Settlement> ?property ?hasValue }
UNION
{ ?isValueOf ?property <http://dbpedia.org/ontology/Settlement> }
}
SELECT ?class ?label
WHERE {
?class rdf:type owl:Place.
?class rdfs:label ?label.
FILTER(lang(?label) = "Neighbourhood")
}
<http://dbpedia.org/ontology/Settlement>
is the IRI of the type Settlement
. Any particular settlement, such as Carter Crest, Edmonton, is an instance of that type.
By writing
<http://dbpedia.org/ontology/Settlement> ?property ?hasValue
you look for properties that are linked to the type Settlement
, rather than to any instances of it. What you are looking for is any property that is linked to an arbitrary object of type Settlement
:
?someObject ?property ?hasValue.
?someObject a <http://dbpedia.org/ontology/Settlement>.
In your second query, what you are currently retrieving is any instance of type owl:Place
, whose textual description equals Neighbourhood
(which sounds like a type again, rather than a specific thing).
However, you probably want to retrieve an instance whose type's label equals Neighbourhood
. (And actually, you probably don't actually want to do that, either; that would be wild guessing that the type labeled Neighbourhood
is what you are looking for. If you know the concrete type IRI, search for that as above.)