query-b39a1b32845b25d198e944ae841497d9

rq turtle/ttl

property P40 statements without any reference

with information in ULAN of the Getty Vocabulary Program (GVP)

output: a table that as CSV is ready for QuickStatements as "CSV with header row"

after replacing the column headers ("comment" and) "commentRef" with the "#" character

suggested QS batch name: 'Getty Vocabulary Program (GVP): P40 ("child") statements: add ULAN as first reference'

PREFIX xl: http://www.w3.org/2008/05/skos-xl# PREFIX gvp: http://vocab.getty.edu/ontology# PREFIX aat: http://vocab.getty.edu/aat/

SELECT DISTINCT ?qid ?P40 ?S248 ?s245 ?s577 ?s813 ?commentRef WITH { SELECT ?item ?gettyHumanURI ?gettySubjectTerm ?wdObject ?gettyObject ?gettyObjectTerm ?gettyID WHERE { ?item wdt:P245 ?gettyID .

?item p:P40 ?statement .
?statement ps:P40 ?wdObject .
FILTER NOT EXISTS { ?statement prov:wasDerivedFrom ?wdRef . }
FILTER NOT EXISTS { ?statement ?someQualProp [] .
                    [] wikibase:qualifier ?someQualProp . }

} LIMIT 90000 } AS %items

# now see what Getty says to those statements WHERE { INCLUDE %items BIND(URI(CONCAT("http://vocab.getty.edu/ulan/", ?gettyID)) AS ?gettySubject) BIND(URI(CONCAT("http://vocab.getty.edu/page/ulan/", ?gettyID)) AS ?gettyHumanURI) SERVICE http://vocab.getty.edu/sparql.json { ?gettySubject gvp:ulan1512_parent_of ?gettyObject . \u0023 { SELECT ?gettyModified WHERE { ?gettySubject dct:modified ?gettyModified . } ORDER BY DESC(?gettyModified) LIMIT 1 } OPTIONAL { ?gettyObject gvp:prefLabelGVP/xl:literalForm ?gettyObjectTerm. } } ?wdObject wdt:P245 ?ulanID . FILTER(URI(CONCAT("http://vocab.getty.edu/ulan/", ?ulanID)) = ?gettyObject)\u0023 # formatting BIND(SUBSTR(STR(?item), 32) AS ?qid) BIND(SUBSTR(STR(?wdObject), 32) AS ?P40) BIND("Q2494649" AS ?S248) BIND(CONCAT("\"", ?gettyID, "\"") AS ?s245) # "publication date" (P577) BIND(CONCAT("+", SUBSTR(STR(?gettyModified),1,10), "T00:00:00Z/11") AS ?s577) # "retrieved" (P813) BIND(CONCAT("+", SUBSTR(STR(NOW()),1,10), "T00:00:00Z/11") AS ?s813)\u0023 # String variables QuickStatements version 1 format BIND("P40" AS ?wdPropPid)
BIND("S248" as ?S248str) BIND("S245" as ?S245str) BIND("S577" as ?S577str) BIND("S813" as ?S813str)\u0023 BIND("add first reference from [[Q2494649]]. Documentation at [[WD:WPVA/Getty]]. Please report any issues e.g. at [[WT:WPVA/Getty]]!" AS ?comment)\u0023 BIND(?comment AS ?commentRef) # copy the comment to the column "commentRef" so that it can be used for # the edit summaries of the edit adding the statement and the edit adding the reference } ORDER BY xsd:integer(SUBSTR(STR(?qid),2))

LIMIT 500 # I think this isn't needed

Use at

PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX prov: <http://www.w3.org/ns/prov#>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX dct: <http://purl.org/dc/terms/>
# property P40 statements without any reference
# with information in ULAN of the Getty Vocabulary Program (GVP)
# output: a table that as CSV is ready for QuickStatements as "CSV with header row"
# after replacing the column headers ("comment" and) "commentRef" with the "#" character
# suggested QS batch name: 'Getty Vocabulary Program (GVP): P40 ("child") statements: add ULAN as first reference'

PREFIX xl: <http://www.w3.org/2008/05/skos-xl#>
PREFIX gvp: <http://vocab.getty.edu/ontology#>
PREFIX aat: <http://vocab.getty.edu/aat/>

SELECT DISTINCT
?qid ?P40  ?S248 ?s245 ?s577 ?s813 ?commentRef

  # now see what Getty says to those statements
  WHERE {  { SELECT ?item ?gettyHumanURI ?gettySubjectTerm ?wdObject ?gettyObject ?gettyObjectTerm ?gettyID
  WHERE {
    ?item wdt:P245 ?gettyID .

    ?item p:P40 ?statement .
    ?statement ps:P40 ?wdObject .
    FILTER NOT EXISTS { ?statement prov:wasDerivedFrom ?wdRef . }
    FILTER NOT EXISTS { ?statement ?someQualProp [] .
                        [] wikibase:qualifier ?someQualProp . }
  } LIMIT 90000 }  BIND(URI(CONCAT("http://vocab.getty.edu/ulan/", ?gettyID)) AS ?gettySubject)
  BIND(URI(CONCAT("http://vocab.getty.edu/page/ulan/", ?gettyID)) AS ?gettyHumanURI)
  SERVICE <http://vocab.getty.edu/sparql.json> {
    ?gettySubject gvp:ulan1512_parent_of ?gettyObject .  \u0023
    { SELECT ?gettyModified WHERE {
      ?gettySubject dct:modified ?gettyModified .
      } ORDER BY DESC(?gettyModified) LIMIT 1
    }
  OPTIONAL { ?gettyObject gvp:prefLabelGVP/xl:literalForm ?gettyObjectTerm. }
  }
  ?wdObject wdt:P245 ?ulanID . FILTER(URI(CONCAT("http://vocab.getty.edu/ulan/", ?ulanID)) = ?gettyObject)\u0023
  # formatting
  BIND(SUBSTR(STR(?item), 32) AS ?qid)
  BIND(SUBSTR(STR(?wdObject), 32) AS ?P40)
  BIND("Q2494649" AS ?S248)
  BIND(CONCAT(""", ?gettyID, """) AS ?s245)
  # "publication date" (P577)
  BIND(CONCAT("+", SUBSTR(STR(?gettyModified),1,10), "T00:00:00Z/11") AS ?s577)
  # "retrieved" (P813)
  BIND(CONCAT("+", SUBSTR(STR(NOW()),1,10), "T00:00:00Z/11") AS ?s813)\u0023
  # String variables QuickStatements version 1 format
  BIND("P40" AS ?wdPropPid)    
  BIND("S248" as ?S248str)
  BIND("S245" as ?S245str)
  BIND("S577" as ?S577str)
  BIND("S813" as ?S813str)\u0023
  BIND("add first reference from [[Q2494649]]. Documentation at [[WD:WPVA/Getty]]. Please report any issues e.g. at [[WT:WPVA/Getty]]!" AS ?comment)\u0023
  BIND(?comment AS ?commentRef)
  # copy the comment to the column "commentRef" so that it can be used for
  # the edit summaries of the edit adding the statement and the edit adding the reference
}
ORDER BY xsd:integer(SUBSTR(STR(?qid),2))
# LIMIT 500 # I think this isn't needed

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v14("?P40"):::projected v21("?S245str") v15("?S248"):::projected v20("?S248str") v22("?S577str") v23("?S813str") v24("?comment") v25("?commentRef"):::projected v11("?gettyHumanURI") v8("?gettyID") v12("?gettyModified") v3("?gettyObject") v13("?gettyObjectTerm") v10("?gettySubject") v7("?item") v14("?qid"):::projected v16("?s245"):::projected v17("?s577"):::projected v18("?s813"):::projected v5("?someQualProp") v4("?statement") v2("?ulanID") v9("?wdObject") v19("?wdPropPid") v6("?wdRef") a1((" ")) a2((" ")) a3((" ")) f0[["concat('http://vocab.getty.edu/ulan/',?ulanID) = ?gettyObject"]] f0 --> v2 f0 --> v3 f1[["not "]] subgraph f1e0["Exists Clause"] e0v1 -->e0v2--> e0a1 e0a2 --"wikibase:qualifier"--> e0v2 e0v2("?someQualProp"):::projected e0v1("?statement"):::projected e0a1((" ")):::projected e0a2((" ")):::projected end f1--EXISTS--> f1e0 f1 --> v4 f1 --> v5 f1 --> a1 f1 --> a2 f1 --> c3 v4 -->v5--> a1 a2 --"wikibase:qualifier"--> v5 f2[["not "]] subgraph f2e1["Exists Clause"] e1v1 --"prov:wasDerivedFrom"--> e1v2 e1v1("?statement"):::projected e1v2("?wdRef"):::projected end f2--EXISTS--> f2e1 f2 --> v4 f2 --> c4 f2 --> v6 v4 --"prov:wasDerivedFrom"--> v6 v7 --"p:direct/P245"--> v8 v7 --"p:P40"--> v4 v4 --"p:statement/P40"--> v9 bind3[/"concat('http://vocab.getty.edu/ulan/',?gettyID)"/] v8 --o bind3 bind3 --as--o v10 bind4[/"concat('http://vocab.getty.edu/page/ulan/',?gettyID)"/] v8 --o bind4 bind4 --as--o v11 subgraph s1["http://vocab.getty.edu/sparql.json"] style s1 stroke-width:4px; v10 --http://vocab.getty.edu/ontology#ulan1512_parent_of--> v3 v10 --"dct:modified"--> v12 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v3 -.http://vocab.getty.edu/ontology#prefLabelGVP.-> a3 a3 --http://www.w3.org/2008/05/skos-xl#literalForm--> v13 end end v9 --"p:direct/P245"--> v2 bind5[/"substring(str(?item),'32^^xsd:integer')"/] v7 --o bind5 bind5 --as--o v14 bind6[/"substring(str(?wdObject),'32^^xsd:integer')"/] v9 --o bind6 bind6 --as--o v14 bind7[/"'Q2494649'"/] bind7 --as--o v15 bind8[/"concat(', ?gettyID, ')"/] bind8 --as--o v16 bind9[/"concat('+',substring(str(?gettyModified),'1^^xsd:integer','10^^xsd:integer'),'T00:00:00Z/11')"/] v12 --o bind9 bind9 --as--o v17 bind10[/"concat('+',substring(str(NOW()),'1^^xsd:integer','10^^xsd:integer'),'T00:00:00Z/11')"/] bind10 --as--o v18 bind11[/"'P40'"/] bind11 --as--o v19 bind12[/"'S248'"/] bind12 --as--o v20 bind13[/"'S245'"/] bind13 --as--o v21 bind14[/"'S577'"/] bind14 --as--o v22 bind15[/"'S813'"/] bind15 --as--o v23 bind16[/"'add first reference from #91;#91;Q2494649#93;#93;. Documentation at #91;#91;WD:WPVA/Getty#93;#93;. Please report any issues e.g. at #91;#91;WT:WPVA/Getty#93;#93;!'"/] bind16 --as--o v24 bind17[/"?comment"/] v24 --o bind17 bind17 --as--o v25