query-abe52e54596ee89ab53ef35e06f54af1

rq turtle/ttl

find an artist by the signing date of an art work and the initials of the artist. SELECT ?item ?itemLabel ?itemDescription ?yearOfBirth ?yearOfDeath $firstnameLabel ?lastnameLabel WITH { SELECT DISTINCT ?item WHERE { ?item wdt:P31 wd:Q5. ?item wdt:P106/wdt:P279 wd:Q21148249 . #wd:Q3391743 . #Q483501 ?item wdt:P569 []. ?item wdt:P735 []. ?item wdt:P734 []. } } AS %subquery1 WHERE { INCLUDE %subquery1 . BIND (1670 as ?yearOfWork). # year on the work of art BIND ("^J." as ?firstnamePattern). # first letter of initials, assuming firstname BIND ("^B.*" as ?lastnamePattern). # second letter of initials, assuming lastname

#?item wdt:P31 wd:Q5.
#?item wdt:P106/wdt:P279* wd:Q21148249 . #Q3391743 . #Q483501 
?item wdt:P569 ?birthDate .
bind (year(?birthDate) as ?yearOfBirth)
Filter (?yearOfBirth+20 < ?yearOfWork) # assuming was not creative before the age of 20
optional {?item wdt:P570 ?deathDate .
          bind (year(?deathDate) as ?yearOfDeath)
          Filter (?yearOfDeath >= ?yearOfWork)
         }
?item wdt:P735 ?firstname.
?item wdt:P734 ?lastname.
?firstname rdfs:label ?firstnameLabel .
?lastname rdfs:label ?lastnameLabel .
FILTER(LANG(?firstnameLabel) = 'de' && LANG(?lastnameLabel) = 'de'
            && regex(?firstnameLabel, ?firstnamePattern, "i") && regex(?lastnameLabel, ?lastnamePattern, "i")) .

SERVICE wikibase:label { bd:serviceParam wikibase:language '[AUTO_LANGUAGE,de,en]' } } GROUP BY ?item ?itemLabel ?itemDescription ?yearOfBirth ?yearOfDeath $firstnameLabel ?lastnameLabel ORDER BY ASC(?lastnameLabel) limit 100

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bd: <http://www.bigdata.com/rdf#>
# find an artist by the signing date of an art work and the initials of the artist.
SELECT ?item ?itemLabel ?itemDescription ?yearOfBirth ?yearOfDeath $firstnameLabel ?lastnameLabel WHERE {
   {
  SELECT DISTINCT ?item WHERE {
    ?item wdt:P31 wd:Q5.
    ?item wdt:P106/wdt:P279* wd:Q21148249 . #wd:Q3391743 . #Q483501 
    ?item wdt:P569 [].
    ?item wdt:P735 [].
    ?item wdt:P734 [].
}
}.
    BIND (1670 as ?yearOfWork). # year on the work of art
    BIND ("^J.*" as ?firstnamePattern). # first letter of initials, assuming firstname
    BIND ("^B.*" as ?lastnamePattern). # second letter of initials, assuming lastname

    #?item wdt:P31 wd:Q5.
    #?item wdt:P106/wdt:P279* wd:Q21148249 . #Q3391743 . #Q483501 
    ?item wdt:P569 ?birthDate .
    bind (year(?birthDate) as ?yearOfBirth)
    Filter (?yearOfBirth+20 < ?yearOfWork) # assuming was not creative before the age of 20
    optional {?item wdt:P570 ?deathDate .
              bind (year(?deathDate) as ?yearOfDeath)
              Filter (?yearOfDeath >= ?yearOfWork)
             }
    ?item wdt:P735 ?firstname.
    ?item wdt:P734 ?lastname.
    ?firstname rdfs:label ?firstnameLabel .
    ?lastname rdfs:label ?lastnameLabel .
    FILTER(LANG(?firstnameLabel) = 'de' && LANG(?lastnameLabel) = 'de'
                && regex(?firstnameLabel, ?firstnamePattern, "i") && regex(?lastnameLabel, ?lastnamePattern, "i")) .

  SERVICE wikibase:label { bd:serviceParam wikibase:language '[AUTO_LANGUAGE,de,en]' }
} GROUP BY ?item ?itemLabel ?itemDescription ?yearOfBirth ?yearOfDeath $firstnameLabel ?lastnameLabel ORDER BY ASC(?lastnameLabel)
 limit 100

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v9("?birthDate") v10("?deathDate") v11("?firstname") v2("?firstnameLabel"):::projected v9("?firstnamePattern") v8("?item"):::projected v12("?lastname") v1("?lastnameLabel"):::projected v9("?lastnamePattern") v10("?yearOfBirth"):::projected v11("?yearOfDeath"):::projected v9("?yearOfWork") a2((" ")) a3((" ")) a4((" ")) a1((" ")) c8(["wd:Q21148249"]):::iri c15(["bd:serviceParam"]):::iri c5(["wd:Q5"]):::iri c17(["#91;AUTO_LANGUAGE,de,en#93;"]):::literal f0[["?firstnameLabel = 'de'?lastnameLabel = 'de'regex(?firstnameLabel,?firstnamePattern,'i')regex(?lastnameLabel,?lastnamePattern,'i')"]] f0 --> v2 f0 --> v1 f0 --> v9 f0 --> v9 f1[["?yearOfBirth + '+20^^xsd:integer' < ?yearOfWork"]] f1 --> v10 f1 --> v9 v8 --"wdt:P31"--> c5 v8 --"wdt:P106"--> a1 a1 --"wdt:P279"--> c8 v8 --"wdt:P569"--> a2 v8 --"wdt:P735"--> a3 v8 --"wdt:P734"--> a4 bind2[/"'1670^^xsd:integer'"/] bind2 --as--o v9 bind3[/"'^J.*'"/] bind3 --as--o v9 bind4[/"'^B.*'"/] bind4 --as--o v9 v8 --"wdt:P569"--> v9 bind5[/"year-from-dateTime(?birthDate)"/] v9 --o bind5 bind5 --as--o v10 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v8 -."wdt:P570".-> v10 bind6[/"year-from-dateTime(?deathDate)"/] v10 --o bind6 bind6 --as--o v11 end v8 --"wdt:P735"--> v11 v8 --"wdt:P734"--> v12 v11 --"rdfs:label"--> v2 v12 --"rdfs:label"--> v1 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c15 --"wikibase:language"--> c17 end