query-9072bf67019cf987117176fdcdc97ff4

rq turtle/ttl

Books or suclasses of books (NOT editions) written in a language the author, supposedly, can't write SELECT DISTINCT ?work ?workLabel ?year ?author ?authorLabel ?languageLabel WHERE {

#Work is an instance or any subclass of book ?work wdt:P31/wdt:P279* wd:Q571 .

#AND is not an instance of a version, translation or edition MINUS { ?work wdt:P31 wd:Q3331189 } .

#Show inception date of the work if available OPTIONAL { ?work wdt:P571 ?date . BIND( YEAR( ?date ) as ?year ) } .

#Get the language of the work ?work wdt:P407 ?language .

#AND the author ?work wdt:P50 ?author .

MINUS { ?author (wdt:P103|(p:P1412/ps:P1412))/wdt:P279* ?language } .

SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }

}

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
#Books or suclasses of books (NOT editions) written in a language the author, supposedly, can't write
SELECT DISTINCT ?work ?workLabel ?year ?author ?authorLabel ?languageLabel WHERE {

  #Work is an instance or any subclass of book 
  ?work wdt:P31/wdt:P279* wd:Q571 .

  #AND is not an instance of a version, translation or edition
  MINUS { ?work wdt:P31 wd:Q3331189 } .

  #Show inception date of the work if available
  OPTIONAL { ?work wdt:P571 ?date . BIND( YEAR( ?date ) as ?year ) } .

  #Get the language of the work
  ?work wdt:P407 ?language .

  #AND the author
  ?work wdt:P50 ?author .

  MINUS { ?author (wdt:P103|(p:P1412/ps:P1412))/wdt:P279* ?language } .

  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } 

}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v5("?author"):::projected v2("?date") v4("?language") v1("?work"):::projected v3("?year"):::projected a1((" ")) a2((" ")) a3((" ")) c4(["wd:Q3331189"]):::iri c12(["bd:serviceParam"]):::iri c14(["#91;AUTO_LANGUAGE#93;,en"]):::literal c3(["wd:Q571"]):::iri v1 --"p:direct/P31"--> a1 a1 --"p:direct/P279"--> c3 subgraph minus0["MINUS"] style minus0 stroke-width:6px,fill:pink,stroke:red; v1 --"p:direct/P31"--> c4 end subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v1 -."p:direct/P571".-> v2 bind1[/"year-from-dateTime(?date)"/] v2 --o bind1 bind1 --as--o v3 end v1 --"p:direct/P407"--> v4 v1 --"p:direct/P50"--> v5 subgraph minus2["MINUS"] style minus2 stroke-width:6px,fill:pink,stroke:red; subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; v5 --"p:P1412"--> a3 a3 --"p:statement/P1412"--> a2 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v5 --"p:direct/P103"--> a2 end union0r <== or ==> union0l end a2 --"p:direct/P279"--> v4 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c12 --"wikibase:language"--> c14 end