我有一个获取一些对象和属性的查询。例如
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
但是我真正想要的是属性的简单字符串。就像是
company industry revenue homepage location
Argonon Digital media 5.0E7 United Kingdom
如何创建查询以获取属性名称?
听起来您只想获取其中某些值的rdfs:label。您可以通过跟随属性,然后是带有属性路径的rdfs:label来做到这一点。您可能还希望根据标签的语言进行过滤。您的查询的另一个问题是homepage属性实际上应该是dbp:property,而不是dbo:property。完成此操作后,您将得到以下查询:
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
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句