Reputation: 1532
I have a query that gets some objects and attributes. For example
PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
SELECT DISTINCT * {
?company a <http://dbpedia.org/ontology/Company> .
OPTIONAL {
?company <http://dbpedia.org/ontology/industry> ?industry .
}
OPTIONAL {
?company <http://dbpedia.org/ontology/revenue> ?revenue_ .
}
OPTIONAL {
?company <http://dbpedia.org/ontology/homepage> ?homepage_ .
}
OPTIONAL {
?company <http://dbpedia.org/ontology/industry> ?industry_ .
}
OPTIONAL {
?company <http://dbpedia.org/ontology/location> ?location_ .
}
}LIMIT 200
I get some results, for example
But what I actually want is a simple String for the attributes. Something like
company industry revenue homepage location
Argonon Digital media 5.0E7 United Kingdom
How can I create a query to get the names of the properties?
Upvotes: 1
Views: 466
Reputation: 85853
It sounds like you just want to get the rdfs:label of some of those values. You can do that by following the property and then rdfs:label with a property path. You might also want to filter based on the language of the label. One other issue with your query is that the homepage property should actually dbp:property, not dbo:property. Once you do that, you end up with this query:
PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
SELECT DISTINCT * {
?company a <http://dbpedia.org/ontology/Company> .
OPTIONAL {
?company <http://dbpedia.org/ontology/industry>/rdfs:label ?industry .
filter langMatches(lang(?industry),"en")
}
OPTIONAL {
?company <http://dbpedia.org/ontology/revenue> ?revenue_ .
}
OPTIONAL {
?company <http://dbpedia.org/property/homepage> ?homepage_ .
}
OPTIONAL {
?company <http://dbpedia.org/ontology/industry>/rdfs:label ?industry_ .
filter langMatches(lang(?industry_),"en")
}
OPTIONAL {
?company <http://dbpedia.org/ontology/location>/rdfs:label ?location_ .
filter langMatches(lang(?location_),"en")
}
}LIMIT 200
Upvotes: 3