我目前正在尝试为我必须提供的用例创建dbpedia数据的示例。 我的主要目标是为每位欧洲艺术家要求5幅画作(我想在开始时每个国家只展示两位艺术家)。
没有限制的查询如下。
PREFIX dbpedia-owl:<http://dbpedia.org/ontology/>
PREFIX category: <http://dbpedia.org/resource/Category:>
PREFIX dcterms:<http://purl.org/dc/terms/>
PREFIX prop:<http://dbpedia.org/property/>
PREFIX geonames:<http://sws.geonames.org/>
PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
PREFIX dbpedia:<http://dbpedia.org/resource/>
PREFIX geo-ont:<http://www.geonames.org/ontology#>
PREFIX ourvocab:<http://example.org/>
prefix foaf:<http://xmlns.com/foaf/0.1/>
SELECT DISTINCT ?painting_name ?artist_name ?european_country ?description ?artist_birthday_year
WHERE {
?european_country dcterms:subject category:Countries_in_Europe.
?european_country rdf:type dbpedia-owl:Place.
?painting prop:artist ?artist.
?painting rdfs:label ?painting_name.
?painting prop:type dbpedia:Oil_painting.
?painting rdfs:comment ?description.
?artist foaf:name ?artist_name.
?artist rdf:type dbpedia-owl:Artist.
?artist prop:placeOfBirth ?european_country.
?artist dbpedia-owl:birthDate ?artist_birthday.
FILTER (lang(?painting_name) = "" || lang(?painting_name) = "en")
FILTER (lang(?description) = "" || lang(?description) = "en")
BIND(year(?artist_birthday) AS ?artist_birthday_year)
}
您可以在此处运行查询:http://dbpedia.org/sparql 现在,我被卡住了,因为我不知道如何在我的用例中应用嵌套限制。 非常感谢你。