query-e74274fdbc0a622503a3298517097eef

rq turtle/ttl

Any idea how to combine the two in a way that doesn't time out? Suggestions should be something this: 10:45, 23 September 2017 (UTC)) talk (Multichill. (Q313194)Aelbert Cuyp "painting by A. Cuyp" -> (Q28060072)Mountainous landscape with herdmen and cattle helped on irc and after some fiddling around I got: Matěj Suchánek

Use at

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 p: <http://www.wikidata.org/prop/>
SELECT DISTINCT * WHERE {
   {
  SELECT DISTINCT ?item (STR(?description) AS ?description1) WHERE {
    ?item wdt:P31 wd:Q3305213 .
    { ?item wdt:P195 wd:Q28045665 } # UNION { ?item wdt:P195 wd:Q18600731 }.
    MINUS { ?item p:P170 [] } .
    ?item schema:description ?description FILTER( LANG( ?description ) = 'en' ) .
  } 
}.
   {
  SELECT DISTINCT ?painter (?description AS ?description2) WHERE {
    ?painter wdt:P106 wd:Q1028181 .
    ?painting wdt:P170 ?painter; wdt:P195/wdt:P17 wd:Q55 .
    {
      ?painter rdfs:label ?painterLabel .
      FILTER( LANG( ?painterLabel ) = 'en' ) .
    } UNION {
      ?painter skos:altLabel ?painterLabel .
      FILTER( LANG( ?painterLabel ) = 'en' ) .
    } .
    BIND( REPLACE( STR( ?painterLabel ), '^(.)[^\\s]+\\s(.+)$', 'painting by $1. $2' ) AS ?description ) .
    FILTER( REGEX( ?description, '^painting by .+' ) ) .
  } 
}.
  FILTER( ?description1 = ?description2 ) .
} LIMIT 150

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v8("?description") v5("?description1"):::projected v8("?description2"):::projected v4("?item"):::projected v5("?painter"):::projected v7("?painterLabel") v6("?painting") a1((" ")) a2((" ")) c5(["wd:Q28045665"]):::iri c13(["wd:Q55"]):::iri c10(["wd:Q1028181"]):::iri c3(["wd:Q3305213"]):::iri f0[["?description1 = ?description2"]] f0 --> v5 f0 --> v8 f1[["?description = 'en'"]] f1 --> v8 v4 --"p:direct/P31"--> c3 v4 --"p:direct/P195"--> c5 subgraph minus2["MINUS"] style minus2 stroke-width:6px,fill:pink,stroke:red; v4 --"p:P170"--> a1 end v4 --"schema:description"--> v8 bind3[/"str(?description)"/] v8 --o bind3 bind3 --as--o v5 f4[["regex(?description,'^painting by .+')"]] f4 --> v8 v5 --"p:direct/P106"--> c10 v6 --"p:direct/P170"--> v5 v6 --"p:direct/P195"--> a2 a2 --"p:direct/P17"--> c13 subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; f5[["?painterLabel = 'en'"]] f5 --> v7 v5 --"skos:altLabel"--> v7 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; f6[["?painterLabel = 'en'"]] f6 --> v7 v5 --"rdfs:label"--> v7 end union0r <== or ==> union0l end bind7[/"replace(str(?painterLabel),'^(.)#91;^\s#93;+\s(.+)$','painting by $1. $2')"/] v7 --o bind7 bind7 --as--o v8 bind8[/"?description"/] v8 --o bind8 bind8 --as--o v8