query-1f0dea0b7501008ec6c9d072277da24e

rq turtle/ttl

Propertiesinstance of (P31)published in (P1433)title (P1476)corrigendum / erratum (P2507)

Use at

PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
SELECT DISTINCT ?qid ?P2507 ?S887 ?comment WHERE {
  VALUES ?prefix { "CORRIGENDUM: " "Author Correction: " "Publisher Correction: " "ERRATUM: " }
  ?item wdt:P31 wd:Q1348305;
        wdt:P1433 wd:Q2261792;
        wdt:P1476 ?title.
  FILTER (STRSTARTS(?title, ?prefix)).
  BIND(REPLACE(?title, CONCAT("^", STR(?prefix), "(.*)$"), "$1") AS ?substring) # concat the prefix to make a regex
  ?item2 wdt:P1476 ?substring.
  FILTER ( NOT EXISTS { ?item2 wdt:P2507 ?item } )
  BIND (ENCODE_FOR_URI(REPLACE(STR(?item2), ".*Q", "Q")) AS ?qid) # article item
  BIND (ENCODE_FOR_URI(REPLACE(STR(?item), ".*Q", "Q")) AS ?P2507) # corrigendum/erratum
  BIND ("Q69652283" AS ?S887) # based on heuristic: inferred from title
  BIND ("link errata to articles by matching title" AS ?comment) 
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v7("?P2507"):::projected v8("?S887"):::projected v9("?comment"):::projected v2("?item") v1("?item2") v5("?prefix") v6("?qid"):::projected v5("?substring") v3("?title") c3(["wd:Q1348305"]):::iri c5(["wd:Q2261792"]):::iri f0[["not "]] subgraph f0e0["Exists Clause"] e0v1 --"wdt:P2507"--> e0v2 e0v2("?item"):::projected e0v1("?item2"):::projected end f0--EXISTS--> f0e0 f0 --> v1 f0 --> c1 f0 --> v2 v1 --"wdt:P2507"--> v2 f1[["starts-with(?title,?prefix)"]] f1 --> v3 f1 --> v5 bind2[/VALUES ?prefix/] bind2-->v5 bind20(["CORRIGENDUM: "]) bind20 --> bind2 bind21(["Author Correction: "]) bind21 --> bind2 bind22(["Publisher Correction: "]) bind22 --> bind2 bind23(["ERRATUM: "]) bind23 --> bind2 v2 --"wdt:P31"--> c3 v2 --"wdt:P1433"--> c5 v2 --"wdt:P1476"--> v3 bind3[/"replace(?title,concat('^',str(?prefix),'(.*)$'),'$1')"/] v3 --o bind3 v5 --o bind3 bind3 --as--o v5 v1 --"wdt:P1476"--> v5 bind4[/"encode-for-uri(replace(str(?item2),'.*Q','Q'))"/] v1 --o bind4 bind4 --as--o v6 bind5[/"encode-for-uri(replace(str(?item),'.*Q','Q'))"/] v2 --o bind5 bind5 --as--o v7 bind6[/"'Q69652283'"/] bind6 --as--o v8 bind7[/"'link errata to articles by matching title'"/] bind7 --as--o v9