Restricted sparql queries

I'm currently trying to create a dbpedia sample data for a use case that I have to submit. My main goal is to ask for five paintings by a European artist (and I want to present only two artists in each country at the beginning).

The query without restrictions 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'm stuck because I don’t know how to apply the nested restrictions in my use case. Thank you so much in advance.

+3
source share

Source: https://habr.com/ru/post/978515/


All Articles