Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
495 views
in Technique[技术] by (71.8m points)

semantic web - Nested queries in sparql with limits

I currently trying to create a sample of the dbpedia data for a use case i have to present. My main goal is to ask for 5 five paintings per european artist (and i want to present only two artists per country at the beginning).

The query without the limits is as follows.

    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)

    }

You can run the query here: http://dbpedia.org/sparql Now, I am stuck because I do not know how to apply the nested limits in my use case. Thank you very much in beforehand.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...