query-65007f922d5d42627209badb19889c93
requirements:
no aliases
only 1 label in de
3 descriptions in de, en, nl; those same apart from start
0 or 1 creator, if 1 matching with that one given in description
SELECT DISTINCT (STRAFTER(STR(?item), "entity/") AS ?qid) ?Lde (CONCAT("Gemälde aus dem Umkreis von ", ?descriptionTail) AS ?Dde) (CONCAT("painting by the circle of ", ?descriptionTail) AS ?Den) ("" AS ?Dnl) ?creator ?uncertaincreator
WHERE { ?item wdt:P195 wd:Q812285. ?item wdt:P31 wd:Q3305213. FILTER NOT EXISTS {?item skos:altLabel ?alias.} # no aliases OPTIONAL { ?item rdfs:label ?itemLabelOther FILTER((LANG(?itemLabelOther)) != "de") . } FILTER(!BOUND(?itemLabelOther)) # no non-de labels ?item rdfs:label ?itemLabel FILTER((LANG(?itemLabel)) = "de") . # 1 label in de OPTIONAL { ?item schema:description ?descriptionOther FILTER(LANG(?descriptionOther) NOT IN ("de", "en", "nl")) . } FILTER(!BOUND(?descriptionOther)) # no non-de/en/nl descriptions ?item schema:description ?descriptionDe FILTER(LANG(?descriptionDe) = "de") . ?item schema:description ?descriptionEn FILTER(LANG(?descriptionEn) = "en") . ?item schema:description ?descriptionNl FILTER(LANG(?descriptionNl) = "nl") . BIND(STRAFTER(STR(?descriptionDe), "Gemälde von ") AS ?descriptionTail) FILTER(?descriptionTail = STRAFTER(STR(?descriptionEn), "painting by ")) FILTER(?descriptionTail = STRAFTER(STR(?descriptionNl), "schilderij van ")) # same description tails
FILTER(REGEX(?itemLabel, "^.+\(.+\)$")) BIND(REPLACE(?itemLabel, "^.+\((.+)\)$", "$1") AS ?bracket) FILTER(REGEX(?bracket, 'Umkreis')) BIND(CONCAT("^(.+)\(", STR(?bracket), "\)$") AS ?matchBareLabel) # STR() shouldn't be necessary
BIND(REPLACE(?itemLabel, ?matchBareLabel, "$1") AS ?Lde) # why doesn't this work?
BIND(REPLACE(?itemLabel, "^(.+)\(Umkreis\)$", "$1") AS ?Lde)
MINUS { ?item p:P170 ?creatorstatement . ?creatorstatement prov:wasDerivedFrom ?reference . } OPTIONAL { ?item wdt:P170 ?creator . ?creator rdfs:label ?creatorLabel . # for matching purposes } OPTIONAL { ?item p:P170 ?creatorstatement. ?creatorstatement ps:P170 wd:Q4233718. ?creatorstatement ?qualifier ?uncertaincreator. ?qualifierproperty wikibase:qualifier ?qualifier. } }
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX schema: <http://schema.org/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX prov: <http://www.w3.org/ns/prov#>
PREFIX p: <http://www.wikidata.org/prop/>
# requirements:
# no aliases
# only 1 label in de
# 3 descriptions in de, en, nl; those same apart from start
# 0 or 1 creator, if 1 matching with that one given in description
SELECT DISTINCT
(STRAFTER(STR(?item), "entity/") AS ?qid)
?Lde
(CONCAT("Gemälde aus dem Umkreis von ", ?descriptionTail) AS ?Dde)
(CONCAT("painting by the circle of ", ?descriptionTail) AS ?Den)
("" AS ?Dnl)
?creator ?uncertaincreator
WHERE {
?item wdt:P195 wd:Q812285.
?item wdt:P31 wd:Q3305213.
FILTER NOT EXISTS {?item skos:altLabel ?alias.} # no aliases
OPTIONAL { ?item rdfs:label ?itemLabelOther FILTER((LANG(?itemLabelOther)) != "de") . }
FILTER(!BOUND(?itemLabelOther)) # no non-de labels
?item rdfs:label ?itemLabel FILTER((LANG(?itemLabel)) = "de") . # 1 label in de
OPTIONAL { ?item schema:description ?descriptionOther FILTER(LANG(?descriptionOther) NOT IN ("de", "en", "nl")) . }
FILTER(!BOUND(?descriptionOther)) # no non-de/en/nl descriptions
?item schema:description ?descriptionDe FILTER(LANG(?descriptionDe) = "de") .
?item schema:description ?descriptionEn FILTER(LANG(?descriptionEn) = "en") .
?item schema:description ?descriptionNl FILTER(LANG(?descriptionNl) = "nl") .
BIND(STRAFTER(STR(?descriptionDe), "Gemälde von ") AS ?descriptionTail)
FILTER(?descriptionTail = STRAFTER(STR(?descriptionEn), "painting by "))
FILTER(?descriptionTail = STRAFTER(STR(?descriptionNl), "schilderij van ")) # same description tails
FILTER(REGEX(?itemLabel, "^.+\\(.+\\)$"))
BIND(REPLACE(?itemLabel, "^.+\\((.+)\\)$", "$1") AS ?bracket)
FILTER(REGEX(?bracket, 'Umkreis'))
BIND(CONCAT("^(.+)\\(", STR(?bracket), "\\)$") AS ?matchBareLabel) # STR() shouldn't be necessary
# BIND(REPLACE(?itemLabel, ?matchBareLabel, "$1") AS ?Lde) # why doesn't this work?
BIND(REPLACE(?itemLabel, "^(.+)\\(Umkreis\\)$", "$1") AS ?Lde)
MINUS {
?item p:P170 ?creatorstatement .
?creatorstatement prov:wasDerivedFrom ?reference .
}
OPTIONAL { ?item wdt:P170 ?creator .
?creator rdfs:label ?creatorLabel . # for matching purposes
}
OPTIONAL {
?item p:P170 ?creatorstatement.
?creatorstatement ps:P170 wd:Q4233718.
?creatorstatement ?qualifier ?uncertaincreator.
?qualifierproperty wikibase:qualifier ?qualifier.
}
}