Template:WDGettyCompQuery/testcases

Code Result
{{WDGettyCompQuery |vocabulary=ulan |wdprop=P21 |gvppath=foaf:focus/gvp:biographyPreferred/schema:gender |valuemapping getty= BIND(IF(?gettyObject = aat:300189559, wd:Q6581097, IF(?gettyObject = aat:300189557, wd:Q6581072, "")) AS ?wdObjectFromGetty) |valuemapping wd= FILTER(?wdObject = ?wdObjectFromGetty ) |output=nice}}
# property P21 statements without any reference
# with information in ULAN of the Getty Vocabulary Program (GVP)
# output: a human-readable table that allows visual checking of the data of Wikidata and the GVP

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
?item ?itemLabel ?wdObject ?wdObjectLabel ?gettyHumanURI ?gettySubjectTerm ?gettyObject ?gettyObjectTerm
  WITH { SELECT ?item ?gettyHumanURI ?gettySubjectTerm ?wdObject ?gettyObject ?gettyObjectTerm ?gettyID
  WHERE {
    ?item wdt:P245 ?gettyID .
    
    ?item p:P21 ?statement .
    ?statement ps:P21 ?wdObject .
    FILTER NOT EXISTS { ?statement prov:wasDerivedFrom ?wdRef . }
    FILTER NOT EXISTS { ?statement ?someQualProp [] .
                        [] wikibase:qualifier ?someQualProp . }
  } LIMIT 10 } 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 foaf:focus/gvp:biographyPreferred/schema:gender ?gettyObject .  \u0023
    OPTIONAL { ?gettySubject gvp:prefLabelGVP/xl:literalForm ?gettySubjectTerm. }
    OPTIONAL { ?gettyObject gvp:prefLabelGVP/xl:literalForm ?gettyObjectTerm. }
  BIND(IF(?gettyObject = aat:300189559, wd:Q6581097, IF(?gettyObject = aat:300189557, wd:Q6581072, "")) AS ?wdObjectFromGetty)
  }
  FILTER(?wdObject = ?wdObjectFromGetty )\u0023
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".}
}
ORDER BY xsd:integer(SUBSTR(STR(?qid),2))
# LIMIT 500 # I think this isn't needed
Try it! ; Try it!
{{WDGettyCompQuery |vocabulary=ulan |wdprop=P21 |gvppath=foaf:focus/gvp:biographyPreferred/schema:gender |valuemapping getty= BIND(IF(?gettyObject = aat:300189559, wd:Q6581097, IF(?gettyObject = aat:300189557, wd:Q6581072, "")) AS ?wdObjectFromGetty) |valuemapping wd= FILTER(?wdObject = ?wdObjectFromGetty ) |output=QSv1}}
# property P21 statements without any reference
# with information in ULAN of the Getty Vocabulary Program (GVP)
# output: a table that as TSV is ready for QuickStatements as "version 1 format"

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 ?wdPropPid ?P21 ?S248str ?S248 ?S245str ?s245 ?S577str ?s577 ?S813str ?s813
  WITH { SELECT ?item ?gettyHumanURI ?gettySubjectTerm ?wdObject ?gettyObject ?gettyObjectTerm ?gettyID
  WHERE {
    ?item wdt:P245 ?gettyID .
    
    ?item p:P21 ?statement .
    ?statement ps:P21 ?wdObject .
    FILTER NOT EXISTS { ?statement prov:wasDerivedFrom ?wdRef . }
    FILTER NOT EXISTS { ?statement ?someQualProp [] .
                        [] wikibase:qualifier ?someQualProp . }
  } LIMIT 10 } 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 foaf:focus/gvp:biographyPreferred/schema:gender ?gettyObject .  \u0023
    { SELECT ?gettyModified WHERE {
      ?gettySubject dct:modified ?gettyModified .
      } ORDER BY DESC(?gettyModified) LIMIT 1
    }
  BIND(IF(?gettyObject = aat:300189559, wd:Q6581097, IF(?gettyObject = aat:300189557, wd:Q6581072, "")) AS ?wdObjectFromGetty)
  }
  FILTER(?wdObject = ?wdObjectFromGetty )\u0023
  # formatting
  BIND(SUBSTR(STR(?item), 32) AS ?qid)
  BIND(SUBSTR(STR(?wdObject), 32) AS ?P21)
  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("P21" AS ?wdPropPid)    
  BIND("S248" as ?S248str)
  BIND("S245" as ?S245str)
  BIND("S577" as ?S577str)
  BIND("S813" as ?S813str)
}
ORDER BY xsd:integer(SUBSTR(STR(?qid),2))
# LIMIT 500 # I think this isn't needed
Try it! ; Try it!
{{WDGettyCompQuery |vocabulary=ulan |wdprop=P21 |gvppath=foaf:focus/gvp:biographyPreferred/schema:gender |valuemapping getty= BIND(IF(?gettyObject = aat:300189559, wd:Q6581097, IF(?gettyObject = aat:300189557, wd:Q6581072, "")) AS ?wdObjectFromGetty) |valuemapping wd= FILTER(?wdObject = ?wdObjectFromGetty ) |output=QScsv}}
# property P21 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): P21 ("sex or gender") 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 ?P21  ?S248 ?s245 ?s577 ?s813 ?commentRef
  WITH { SELECT ?item ?gettyHumanURI ?gettySubjectTerm ?wdObject ?gettyObject ?gettyObjectTerm ?gettyID
  WHERE {
    ?item wdt:P245 ?gettyID .
    
    ?item p:P21 ?statement .
    ?statement ps:P21 ?wdObject .
    FILTER NOT EXISTS { ?statement prov:wasDerivedFrom ?wdRef . }
    FILTER NOT EXISTS { ?statement ?someQualProp [] .
                        [] wikibase:qualifier ?someQualProp . }
  } LIMIT 10 } 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 foaf:focus/gvp:biographyPreferred/schema:gender ?gettyObject .  \u0023
    { SELECT ?gettyModified WHERE {
      ?gettySubject dct:modified ?gettyModified .
      } ORDER BY DESC(?gettyModified) LIMIT 1
    }
  BIND(IF(?gettyObject = aat:300189559, wd:Q6581097, IF(?gettyObject = aat:300189557, wd:Q6581072, "")) AS ?wdObjectFromGetty)
  }
  FILTER(?wdObject = ?wdObjectFromGetty )\u0023
  # formatting
  BIND(SUBSTR(STR(?item), 32) AS ?qid)
  BIND(SUBSTR(STR(?wdObject), 32) AS ?P21)
  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("P21" 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
Try it! ; Try it!


{{WDGettyCompQuery |vocabulary=ulan |wdprop=P19 |gvppath=foaf:focus/gvp:biographyPreferred/schema:birthPlace/^foaf:focus |valuemapping wd= ?wdObject wdt:P1667 ?tgnID . FILTER(URI(CONCAT("http://vocab.getty.edu/tgn/", ?tgnID)) = ?gettyObject) |limit = 200}}
# property P19 statements without any reference
# with information in ULAN of the Getty Vocabulary Program (GVP)
# output: a human-readable table that allows visual checking of the data of Wikidata and the GVP

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
?item ?itemLabel ?wdObject ?wdObjectLabel ?gettyHumanURI ?gettySubjectTerm ?gettyObject ?gettyObjectTerm
  WITH { SELECT ?item ?gettyHumanURI ?gettySubjectTerm ?wdObject ?gettyObject ?gettyObjectTerm ?gettyID
  WHERE {
    ?item wdt:P245 ?gettyID .
    
    ?item p:P19 ?statement .
    ?statement ps:P19 ?wdObject .
    FILTER NOT EXISTS { ?statement prov:wasDerivedFrom ?wdRef . }
    FILTER NOT EXISTS { ?statement ?someQualProp [] .
                        [] wikibase:qualifier ?someQualProp . }
  } LIMIT 200 } 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 foaf:focus/gvp:biographyPreferred/schema:birthPlace/^foaf:focus ?gettyObject .  \u0023
    OPTIONAL { ?gettySubject gvp:prefLabelGVP/xl:literalForm ?gettySubjectTerm. }
    OPTIONAL { ?gettyObject gvp:prefLabelGVP/xl:literalForm ?gettyObjectTerm. }
  
  }
  ?wdObject wdt:P1667 ?tgnID .
  FILTER(URI(CONCAT("http://vocab.getty.edu/tgn/", ?tgnID)) = ?gettyObject)\u0023
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".}
}
ORDER BY xsd:integer(SUBSTR(STR(?qid),2))
# LIMIT 500 # I think this isn't needed
Try it! ; Try it!
{{WDGettyCompQuery |vocabulary=ulan |wdprop=P19 |subj2obj= ?gettySubject foaf:focus/gvp:biographyPreferred/schema:birthPlace/^foaf:focus ?gettyObject . ?gettyObject xl:prefLabel/xl:literalForm ?ulanTerm. FILTER(LANG(?ulanTerm) = "en") |valuemapping wd= ?wdObject wdt:P1667 ?tgnID . FILTER(URI(CONCAT("http://vocab.getty.edu/tgn/", ?tgnID)) = ?gettyObject) |limit = 3000 |output=QSv1}}
# property P19 statements without any reference
# with information in ULAN of the Getty Vocabulary Program (GVP)
# output: a table that as TSV is ready for QuickStatements as "version 1 format"

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 ?wdPropPid ?P19 ?S248str ?S248 ?S245str ?s245 ?S577str ?s577 ?S813str ?s813
  WITH { SELECT ?item ?gettyHumanURI ?gettySubjectTerm ?wdObject ?gettyObject ?gettyObjectTerm ?gettyID
  WHERE {
    ?item wdt:P245 ?gettyID .
    
    ?item p:P19 ?statement .
    ?statement ps:P19 ?wdObject .
    FILTER NOT EXISTS { ?statement prov:wasDerivedFrom ?wdRef . }
    FILTER NOT EXISTS { ?statement ?someQualProp [] .
                        [] wikibase:qualifier ?someQualProp . }
  } LIMIT 3000 } 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 foaf:focus/gvp:biographyPreferred/schema:birthPlace/^foaf:focus ?gettyObject .
    ?gettyObject xl:prefLabel/xl:literalForm ?ulanTerm. FILTER(LANG(?ulanTerm) = "en") \u0023
    { SELECT ?gettyModified WHERE {
      ?gettySubject dct:modified ?gettyModified .
      } ORDER BY DESC(?gettyModified) LIMIT 1
    }
  
  }
  ?wdObject wdt:P1667 ?tgnID .
  FILTER(URI(CONCAT("http://vocab.getty.edu/tgn/", ?tgnID)) = ?gettyObject)\u0023
  # formatting
  BIND(SUBSTR(STR(?item), 32) AS ?qid)
  BIND(SUBSTR(STR(?wdObject), 32) AS ?P19)
  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("P19" AS ?wdPropPid)    
  BIND("S248" as ?S248str)
  BIND("S245" as ?S245str)
  BIND("S577" as ?S577str)
  BIND("S813" as ?S813str)
}
ORDER BY xsd:integer(SUBSTR(STR(?qid),2))
# LIMIT 500 # I think this isn't needed
Try it! ; Try it!
{{WDGettyCompQuery |vocabulary=ulan |wdprop=P19 |subj2obj= ?gettySubject foaf:focus/gvp:biographyPreferred/schema:birthPlace/^foaf:focus ?gettyObject . ?gettyObject xl:prefLabel/xl:literalForm ?ulanTerm. FILTER(LANG(?ulanTerm) = "en") |valuemapping wd= ?wdObject wdt:P1667 ?tgnID . FILTER(URI(CONCAT("http://vocab.getty.edu/tgn/", ?tgnID)) = ?gettyObject) |limit = 3000 |output=QScsv}}
# property P19 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): P19 ("place of birth") 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 ?P19  ?S248 ?s245 ?s577 ?s813 ?commentRef
  WITH { SELECT ?item ?gettyHumanURI ?gettySubjectTerm ?wdObject ?gettyObject ?gettyObjectTerm ?gettyID
  WHERE {
    ?item wdt:P245 ?gettyID .
    
    ?item p:P19 ?statement .
    ?statement ps:P19 ?wdObject .
    FILTER NOT EXISTS { ?statement prov:wasDerivedFrom ?wdRef . }
    FILTER NOT EXISTS { ?statement ?someQualProp [] .
                        [] wikibase:qualifier ?someQualProp . }
  } LIMIT 3000 } 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 foaf:focus/gvp:biographyPreferred/schema:birthPlace/^foaf:focus ?gettyObject .
    ?gettyObject xl:prefLabel/xl:literalForm ?ulanTerm. FILTER(LANG(?ulanTerm) = "en") \u0023
    { SELECT ?gettyModified WHERE {
      ?gettySubject dct:modified ?gettyModified .
      } ORDER BY DESC(?gettyModified) LIMIT 1
    }
  
  }
  ?wdObject wdt:P1667 ?tgnID .
  FILTER(URI(CONCAT("http://vocab.getty.edu/tgn/", ?tgnID)) = ?gettyObject)\u0023
  # formatting
  BIND(SUBSTR(STR(?item), 32) AS ?qid)
  BIND(SUBSTR(STR(?wdObject), 32) AS ?P19)
  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("P19" 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
Try it! ; Try it!


outputs
{{WDGettyCompQuery |vocabulary=tgn |wdprop=P1376 |gvppath=gvp:tgn3201_capital_of}}
# property P1376 statements without any reference
# with information in TGN of the Getty Vocabulary Program (GVP)
# output: a human-readable table that allows visual checking of the data of Wikidata and the GVP

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
?item ?itemLabel ?wdObject ?wdObjectLabel ?gettyHumanURI ?gettySubjectTerm ?gettyObject ?gettyObjectTerm
  WITH { SELECT ?item ?gettyHumanURI ?gettySubjectTerm ?wdObject ?gettyObject ?gettyObjectTerm ?gettyID
  WHERE {
    ?item wdt:P1667 ?gettyID .
    
    ?item p:P1376 ?statement .
    ?statement ps:P1376 ?wdObject .
    FILTER NOT EXISTS { ?statement prov:wasDerivedFrom ?wdRef . }
    FILTER NOT EXISTS { ?statement ?someQualProp [] .
                        [] wikibase:qualifier ?someQualProp . }
  } LIMIT 10 } AS %items

  # now see what Getty says to those statements
  WHERE { INCLUDE %items
  BIND(URI(CONCAT("http://vocab.getty.edu/tgn/", ?gettyID)) AS ?gettySubject)
  BIND(URI(CONCAT("http://vocab.getty.edu/page/tgn/", ?gettyID)) AS ?gettyHumanURI)
  SERVICE <http://vocab.getty.edu/sparql.json> {
    ?gettySubject gvp:tgn3201_capital_of ?gettyObject .  \u0023
    OPTIONAL { ?gettySubject gvp:prefLabelGVP/xl:literalForm ?gettySubjectTerm. }
    OPTIONAL { ?gettyObject gvp:prefLabelGVP/xl:literalForm ?gettyObjectTerm. }
  
  }
  \u0023
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".}
}
ORDER BY xsd:integer(SUBSTR(STR(?qid),2))
# LIMIT 500 # I think this isn't needed
Try it! ; Try it!
{{WDGettyCompQuery |vocabulary=tgn |wdprop=P1376 |gvppath=gvp:tgn3201_capital_of |output=QSv1}}
# property P1376 statements without any reference
# with information in TGN of the Getty Vocabulary Program (GVP)
# output: a table that as TSV is ready for QuickStatements as "version 1 format"

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 ?wdPropPid ?P1376 ?S248str ?S248 ?S1667str ?s1667 ?S577str ?s577 ?S813str ?s813
  WITH { SELECT ?item ?gettyHumanURI ?gettySubjectTerm ?wdObject ?gettyObject ?gettyObjectTerm ?gettyID
  WHERE {
    ?item wdt:P1667 ?gettyID .
    
    ?item p:P1376 ?statement .
    ?statement ps:P1376 ?wdObject .
    FILTER NOT EXISTS { ?statement prov:wasDerivedFrom ?wdRef . }
    FILTER NOT EXISTS { ?statement ?someQualProp [] .
                        [] wikibase:qualifier ?someQualProp . }
  } LIMIT 10 } AS %items

  # now see what Getty says to those statements
  WHERE { INCLUDE %items
  BIND(URI(CONCAT("http://vocab.getty.edu/tgn/", ?gettyID)) AS ?gettySubject)
  BIND(URI(CONCAT("http://vocab.getty.edu/page/tgn/", ?gettyID)) AS ?gettyHumanURI)
  SERVICE <http://vocab.getty.edu/sparql.json> {
    ?gettySubject gvp:tgn3201_capital_of ?gettyObject .  \u0023
    { SELECT ?gettyModified WHERE {
      ?gettySubject dct:modified ?gettyModified .
      } ORDER BY DESC(?gettyModified) LIMIT 1
    }
  
  }
  \u0023
  # formatting
  BIND(SUBSTR(STR(?item), 32) AS ?qid)
  BIND(SUBSTR(STR(?wdObject), 32) AS ?P1376)
  BIND("Q1520117" AS ?S248)
  BIND(CONCAT("\"", ?gettyID, "\"") AS ?s1667)
  # "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("P1376" AS ?wdPropPid)    
  BIND("S248" as ?S248str)
  BIND("S1667" as ?S1667str)
  BIND("S577" as ?S577str)
  BIND("S813" as ?S813str)
}
ORDER BY xsd:integer(SUBSTR(STR(?qid),2))
# LIMIT 500 # I think this isn't needed
Try it! ; Try it!
{{WDGettyCompQuery |vocabulary=tgn |wdprop=P1376 |gvppath=gvp:tgn3201_capital_of |output=QScsv}}
# property P1376 statements without any reference
# with information in TGN 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): P1376 ("capital of") statements: add TGN 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 ?P1376  ?S248 ?s1667 ?s577 ?s813 ?commentRef
  WITH { SELECT ?item ?gettyHumanURI ?gettySubjectTerm ?wdObject ?gettyObject ?gettyObjectTerm ?gettyID
  WHERE {
    ?item wdt:P1667 ?gettyID .
    
    ?item p:P1376 ?statement .
    ?statement ps:P1376 ?wdObject .
    FILTER NOT EXISTS { ?statement prov:wasDerivedFrom ?wdRef . }
    FILTER NOT EXISTS { ?statement ?someQualProp [] .
                        [] wikibase:qualifier ?someQualProp . }
  } LIMIT 10 } AS %items

  # now see what Getty says to those statements
  WHERE { INCLUDE %items
  BIND(URI(CONCAT("http://vocab.getty.edu/tgn/", ?gettyID)) AS ?gettySubject)
  BIND(URI(CONCAT("http://vocab.getty.edu/page/tgn/", ?gettyID)) AS ?gettyHumanURI)
  SERVICE <http://vocab.getty.edu/sparql.json> {
    ?gettySubject gvp:tgn3201_capital_of ?gettyObject .  \u0023
    { SELECT ?gettyModified WHERE {
      ?gettySubject dct:modified ?gettyModified .
      } ORDER BY DESC(?gettyModified) LIMIT 1
    }
  
  }
  \u0023
  # formatting
  BIND(SUBSTR(STR(?item), 32) AS ?qid)
  BIND(SUBSTR(STR(?wdObject), 32) AS ?P1376)
  BIND("Q1520117" AS ?S248)
  BIND(CONCAT("\"", ?gettyID, "\"") AS ?s1667)
  # "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("P1376" AS ?wdPropPid)    
  BIND("S248" as ?S248str)
  BIND("S1667" as ?S1667str)
  BIND("S577" as ?S577str)
  BIND("S813" as ?S813str)\u0023
  BIND("add first reference from [[Q1520117]]. 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
Try it! ; Try it!
{{WDGettyCompQuery |vocabulary=tgn |wdprop=P1376 |gvppath=gvp:tgn3201_capital_of |output=wdlist}}
# property P1376 statements without any reference
# with information in TGN of the Getty Vocabulary Program (GVP)
# output: a result set for a "Template:Wikidata list"

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
?item ?wdObject ?gettySubjectTerm ?gettyLink ?gettyObjectTerm ?gettyObjectLink ?QSlink # TODO: needs to be tested
  WITH { SELECT ?item ?gettyHumanURI ?gettySubjectTerm ?wdObject ?gettyObject ?gettyObjectTerm ?gettyID
  WHERE {
    ?item wdt:P1667 ?gettyID .
    
    ?item p:P1376 ?statement .
    ?statement ps:P1376 ?wdObject .
    FILTER NOT EXISTS { ?statement prov:wasDerivedFrom ?wdRef . }
    FILTER NOT EXISTS { ?statement ?someQualProp [] .
                        [] wikibase:qualifier ?someQualProp . }
  } LIMIT 10 } AS %items

  # now see what Getty says to those statements
  WHERE { INCLUDE %items
  BIND(URI(CONCAT("http://vocab.getty.edu/tgn/", ?gettyID)) AS ?gettySubject)
  BIND(URI(CONCAT("http://vocab.getty.edu/page/tgn/", ?gettyID)) AS ?gettyHumanURI)
  SERVICE <http://vocab.getty.edu/sparql.json> {
    ?gettySubject gvp:tgn3201_capital_of ?gettyObject .  \u0023
    { SELECT ?gettyModified WHERE {
      ?gettySubject dct:modified ?gettyModified .
      } ORDER BY DESC(?gettyModified) LIMIT 1
    }\u0023
    OPTIONAL { ?gettySubject gvp:prefLabelGVP/xl:literalForm ?gettySubjectTerm. }
    OPTIONAL { ?gettyObject gvp:prefLabelGVP/xl:literalForm ?gettyObjectTerm. }
  
  }
  \u0023
  # formatting
  BIND(SUBSTR(STR(?item), 32) AS ?qid)
  BIND(SUBSTR(STR(?wdObject), 32) AS ?P1376)
  BIND("Q1520117" AS ?S248)
  BIND(CONCAT("\"", ?gettyID, "\"") AS ?s1667)
  # "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("P1376" AS ?wdPropPid)    
  BIND("S248" as ?S248str)
  BIND("S1667" as ?S1667str)
  BIND("S577" as ?S577str)
  BIND("S813" as ?S813str)\u0023
  BIND("/*add first reference from [[Q1520117]]. Documentation at [[WD:WPVA/Getty]]. Please report any issues e.g. at [[WT:WPVA/Getty]]! */" AS ?comment)\u0023
  # Produce QuickStatements version 1 links
  # cf. <https://www.wikidata.org/wiki/Help:QuickStatements#Running_QuickStatements_through_URL>:
  BIND(URI(CONCAT("https://quickstatements.toolforge.org/index_old.html#v1=",
                  ?qid, "%09", ?wdPropPid, "%09", ?P1376, "%09", ?S248str, "%09", ?S248,
                  "%09", ?S1667str,
                  "%09", ?s1667,
                  "%09", ?S577str, "%09", ?s577,
                  "%09", ?S813str, "%09", ?s813,
                  ?comment)) AS ?QSlink)
  BIND(CONCAT("[", STR(?gettyHumanURI), " ", ?gettyID, "]") AS ?gettyLink)
  BIND(CONCAT("[", STR(?gettyObject), "]") AS ?gettyObjectLink)
}
ORDER BY xsd:integer(SUBSTR(STR(?qid),2))
# LIMIT 500 # I think this isn't needed
Try it! ; Try it!
{{WDGettyCompQuery |vocabulary=tgn |wdprop=P1376 |gvppath=gvp:tgn3201_capital_of |short=yes}}
# property P1376 statements without any reference
# with information in TGN of the Getty Vocabulary Program (GVP)
# output: a human-readable table that allows visual checking of the data of Wikidata and the GVP

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
?item ?itemLabel ?wdObject ?wdObjectLabel ?gettyHumanURI ?gettySubjectTerm ?gettyObject ?gettyObjectTerm
  WITH { SELECT ?item ?gettyHumanURI ?gettySubjectTerm ?wdObject ?gettyObject ?gettyObjectTerm ?gettyID
  WHERE {
    ?item wdt:P1667 ?gettyID .
    
    ?item p:P1376 ?statement .
    ?statement ps:P1376 ?wdObject .
    FILTER NOT EXISTS { ?statement prov:wasDerivedFrom ?wdRef . }
    FILTER NOT EXISTS { ?statement ?someQualProp [] .
                        [] wikibase:qualifier ?someQualProp . }
  } LIMIT 10 } AS %items

  # now see what Getty says to those statements
  WHERE { INCLUDE %items
  BIND(URI(CONCAT("http://vocab.getty.edu/tgn/", ?gettyID)) AS ?gettySubject)
  BIND(URI(CONCAT("http://vocab.getty.edu/page/tgn/", ?gettyID)) AS ?gettyHumanURI)
  SERVICE <http://vocab.getty.edu/sparql.json> {
    ?gettySubject gvp:tgn3201_capital_of ?gettyObject .  \u0023
    OPTIONAL { ?gettySubject gvp:prefLabelGVP/xl:literalForm ?gettySubjectTerm. }
    OPTIONAL { ?gettyObject gvp:prefLabelGVP/xl:literalForm ?gettyObjectTerm. }
  
  }
  \u0023
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".}
}
ORDER BY xsd:integer(SUBSTR(STR(?qid),2))
# LIMIT 500 # I think this isn't needed
Try it! ; Try it!
{{WDGettyCompQuery |vocabulary=tgn |wdprop=P1376 |gvppath=gvp:tgn3201_capital_of |output=QScsv |short=yes}}
# property P1376 statements without any reference
# with information in TGN 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): P1376 ("capital of") statements: add TGN 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 ?P1376  ?S248 ?s1667 ?s577 ?s813 ?commentRef
  WITH { SELECT ?item ?gettyHumanURI ?gettySubjectTerm ?wdObject ?gettyObject ?gettyObjectTerm ?gettyID
  WHERE {
    ?item wdt:P1667 ?gettyID .
    
    ?item p:P1376 ?statement .
    ?statement ps:P1376 ?wdObject .
    FILTER NOT EXISTS { ?statement prov:wasDerivedFrom ?wdRef . }
    FILTER NOT EXISTS { ?statement ?someQualProp [] .
                        [] wikibase:qualifier ?someQualProp . }
  } LIMIT 10 } AS %items

  # now see what Getty says to those statements
  WHERE { INCLUDE %items
  BIND(URI(CONCAT("http://vocab.getty.edu/tgn/", ?gettyID)) AS ?gettySubject)
  BIND(URI(CONCAT("http://vocab.getty.edu/page/tgn/", ?gettyID)) AS ?gettyHumanURI)
  SERVICE <http://vocab.getty.edu/sparql.json> {
    ?gettySubject gvp:tgn3201_capital_of ?gettyObject .  \u0023
    { SELECT ?gettyModified WHERE {
      ?gettySubject dct:modified ?gettyModified .
      } ORDER BY DESC(?gettyModified) LIMIT 1
    }
  
  }
  \u0023
  # formatting
  BIND(SUBSTR(STR(?item), 32) AS ?qid)
  BIND(SUBSTR(STR(?wdObject), 32) AS ?P1376)
  BIND("Q1520117" AS ?S248)
  BIND(CONCAT("\"", ?gettyID, "\"") AS ?s1667)
  # "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("P1376" AS ?wdPropPid)    
  BIND("S248" as ?S248str)
  BIND("S1667" as ?S1667str)
  BIND("S577" as ?S577str)
  BIND("S813" as ?S813str)\u0023
  BIND("add first reference from [[Q1520117]]. 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
QScsv ; QScsv
{{WDGettyCompQuery |vocabulary=tgn |wdprop=P1376 |gvppath=gvp:tgn3201_capital_of |label=Do it!}}
# property P1376 statements without any reference
# with information in TGN of the Getty Vocabulary Program (GVP)
# output: a human-readable table that allows visual checking of the data of Wikidata and the GVP

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
?item ?itemLabel ?wdObject ?wdObjectLabel ?gettyHumanURI ?gettySubjectTerm ?gettyObject ?gettyObjectTerm
  WITH { SELECT ?item ?gettyHumanURI ?gettySubjectTerm ?wdObject ?gettyObject ?gettyObjectTerm ?gettyID
  WHERE {
    ?item wdt:P1667 ?gettyID .
    
    ?item p:P1376 ?statement .
    ?statement ps:P1376 ?wdObject .
    FILTER NOT EXISTS { ?statement prov:wasDerivedFrom ?wdRef . }
    FILTER NOT EXISTS { ?statement ?someQualProp [] .
                        [] wikibase:qualifier ?someQualProp . }
  } LIMIT 10 } AS %items

  # now see what Getty says to those statements
  WHERE { INCLUDE %items
  BIND(URI(CONCAT("http://vocab.getty.edu/tgn/", ?gettyID)) AS ?gettySubject)
  BIND(URI(CONCAT("http://vocab.getty.edu/page/tgn/", ?gettyID)) AS ?gettyHumanURI)
  SERVICE <http://vocab.getty.edu/sparql.json> {
    ?gettySubject gvp:tgn3201_capital_of ?gettyObject .  \u0023
    OPTIONAL { ?gettySubject gvp:prefLabelGVP/xl:literalForm ?gettySubjectTerm. }
    OPTIONAL { ?gettyObject gvp:prefLabelGVP/xl:literalForm ?gettyObjectTerm. }
  
  }
  \u0023
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".}
}
ORDER BY xsd:integer(SUBSTR(STR(?qid),2))
# LIMIT 500 # I think this isn't needed
Do it! ; Do it!
{{WDGettyCompQuery |vocabulary=tgn |wdprop=P1376 |gvppath=gvp:tgn3201_capital_of |short=yes |label=Getty for {{P|1376}}}}
# property P1376 statements without any reference
# with information in TGN of the Getty Vocabulary Program (GVP)
# output: a human-readable table that allows visual checking of the data of Wikidata and the GVP

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
?item ?itemLabel ?wdObject ?wdObjectLabel ?gettyHumanURI ?gettySubjectTerm ?gettyObject ?gettyObjectTerm
  WITH { SELECT ?item ?gettyHumanURI ?gettySubjectTerm ?wdObject ?gettyObject ?gettyObjectTerm ?gettyID
  WHERE {
    ?item wdt:P1667 ?gettyID .
    
    ?item p:P1376 ?statement .
    ?statement ps:P1376 ?wdObject .
    FILTER NOT EXISTS { ?statement prov:wasDerivedFrom ?wdRef . }
    FILTER NOT EXISTS { ?statement ?someQualProp [] .
                        [] wikibase:qualifier ?someQualProp . }
  } LIMIT 10 } AS %items

  # now see what Getty says to those statements
  WHERE { INCLUDE %items
  BIND(URI(CONCAT("http://vocab.getty.edu/tgn/", ?gettyID)) AS ?gettySubject)
  BIND(URI(CONCAT("http://vocab.getty.edu/page/tgn/", ?gettyID)) AS ?gettyHumanURI)
  SERVICE <http://vocab.getty.edu/sparql.json> {
    ?gettySubject gvp:tgn3201_capital_of ?gettyObject .  \u0023
    OPTIONAL { ?gettySubject gvp:prefLabelGVP/xl:literalForm ?gettySubjectTerm. }
    OPTIONAL { ?gettyObject gvp:prefLabelGVP/xl:literalForm ?gettyObjectTerm. }
  
  }
  \u0023
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".}
}
ORDER BY xsd:integer(SUBSTR(STR(?qid),2))
# LIMIT 500 # I think this isn't needed
Getty for capital of (P1376) ; Getty for capital of (P1376)


actions
{{WDGettyCompQuery |vocabulary=ulan |wdprop=P19 |gvppath=foaf:focus/gvp:biographyPreferred/schema:birthPlace/^foaf:focus |valuemapping wd= BIND(SUBSTR(STR(?gettyObject), 28) AS ?tgnID) ?wdObject wdt:P1667 ?tgnID . |limit = 200 |action=add statement |output=wdlistraw}}
# property P19 statements that could be added
# with information in ULAN of the Getty Vocabulary Program (GVP)
# output: a result set for a "Template:Wikidata list"

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
?item ?wdObject ?gettySubjectTerm ?gettyLink ?gettyObjectTerm ?gettyObjectLink ?QSlink # TODO: needs to be tested
  WITH { SELECT ?item ?gettyHumanURI ?gettySubjectTerm ?wdObject ?gettyObject ?gettyObjectTerm ?gettyID
  WHERE {
    ?item wdt:P245 ?gettyID .
    
    FILTER NOT EXISTS { ?item p:P19 [] . }
  } LIMIT 200 } 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 foaf:focus/gvp:biographyPreferred/schema:birthPlace/^foaf:focus ?gettyObject .  \u0023
    { SELECT ?gettyModified WHERE {
      ?gettySubject dct:modified ?gettyModified .
      } ORDER BY DESC(?gettyModified) LIMIT 1
    }\u0023
    OPTIONAL { ?gettySubject gvp:prefLabelGVP/xl:literalForm ?gettySubjectTerm. }
    OPTIONAL { ?gettyObject gvp:prefLabelGVP/xl:literalForm ?gettyObjectTerm. }
  
  }
  BIND(SUBSTR(STR(?gettyObject), 28) AS ?tgnID)
  ?wdObject wdt:P1667 ?tgnID .\u0023
  hint:Query hint:optimizer "None" .\u0023
  # formatting
  BIND(SUBSTR(STR(?item), 32) AS ?qid)
  BIND(SUBSTR(STR(?wdObject), 32) AS ?P19)
  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("P19" AS ?wdPropPid)    
  BIND("S248" as ?S248str)
  BIND("S245" as ?S245str)
  BIND("S577" as ?S577str)
  BIND("S813" as ?S813str)\u0023
  BIND("/*add data from [[Q2494649]]. Documentation at [[WD:WPVA/Getty]]. Please report any issues e.g. at [[WT:WPVA/Getty]]! */" AS ?comment)\u0023
  # Produce QuickStatements version 1 links
  # cf. <https://www.wikidata.org/wiki/Help:QuickStatements#Running_QuickStatements_through_URL>:
  BIND(URI(CONCAT("https://quickstatements.toolforge.org/index_old.html#v1=",
                  ?qid, "%09", ?wdPropPid, "%09", ?P19, "%09", ?S248str, "%09", ?S248,
                  "%09", ?S245str,
                  "%09", ?s245,
                  "%09", ?S577str, "%09", ?s577,
                  "%09", ?S813str, "%09", ?s813,
                  ?comment)) AS ?QSlink)
  BIND(CONCAT("[", STR(?gettyHumanURI), " ", ?gettyID, "]") AS ?gettyLink)
  BIND(CONCAT("[", STR(?gettyObject), "]") AS ?gettyObjectLink)
}
ORDER BY xsd:integer(SUBSTR(STR(?qid),2))
# LIMIT 500 # I think this isn't needed
Try it! ; Try it!
{{WDGettyCompQuery |vocabulary=ulan |wdprop=P19 |gvppath=foaf:focus/gvp:biographyPreferred/schema:birthPlace/^foaf:focus |valuemapping wd= BIND(SUBSTR(STR(?gettyObject), 28) AS ?tgnID) ?wdObject wdt:P1667 ?tgnID . |limit = 200 |action=add first vocabulary reference |output=wdlistraw}}
# property P19 statements without a reference from ULAN of the Getty Vocabulary Program
# with information in ULAN of the Getty Vocabulary Program (GVP)
# output: a result set for a "Template:Wikidata list"

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
?item ?wdObject ?gettySubjectTerm ?gettyLink ?gettyObjectTerm ?gettyObjectLink ?QSlink # TODO: needs to be tested
  WITH { SELECT ?item ?gettyHumanURI ?gettySubjectTerm ?wdObject ?gettyObject ?gettyObjectTerm ?gettyID
  WHERE {
    ?item wdt:P245 ?gettyID .
    
    ?item p:P19 ?statement .
    ?statement ps:P19 ?wdObject .
    FILTER NOT EXISTS { ?statement prov:wasDerivedFrom [ pr:P248 wd:Q2494649 ]  . } # TODO: needs testing!!! # CAVE: adds double references where "stated in" (P248) is missing!
    FILTER NOT EXISTS { ?statement ?someQualProp [] .
                        [] wikibase:qualifier ?someQualProp . }
  } LIMIT 200 } 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 foaf:focus/gvp:biographyPreferred/schema:birthPlace/^foaf:focus ?gettyObject .  \u0023
    { SELECT ?gettyModified WHERE {
      ?gettySubject dct:modified ?gettyModified .
      } ORDER BY DESC(?gettyModified) LIMIT 1
    }\u0023
    OPTIONAL { ?gettySubject gvp:prefLabelGVP/xl:literalForm ?gettySubjectTerm. }
    OPTIONAL { ?gettyObject gvp:prefLabelGVP/xl:literalForm ?gettyObjectTerm. }
  
  }
  BIND(SUBSTR(STR(?gettyObject), 28) AS ?tgnID)
  ?wdObject wdt:P1667 ?tgnID .\u0023
  # formatting
  BIND(SUBSTR(STR(?item), 32) AS ?qid)
  BIND(SUBSTR(STR(?wdObject), 32) AS ?P19)
  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("P19" AS ?wdPropPid)    
  BIND("S248" as ?S248str)
  BIND("S245" as ?S245str)
  BIND("S577" as ?S577str)
  BIND("S813" as ?S813str)\u0023
  BIND("/*add reference from [[Q2494649]]. Documentation at [[WD:WPVA/Getty]]. Please report any issues e.g. at [[WT:WPVA/Getty]]! */" AS ?comment)\u0023
  # Produce QuickStatements version 1 links
  # cf. <https://www.wikidata.org/wiki/Help:QuickStatements#Running_QuickStatements_through_URL>:
  BIND(URI(CONCAT("https://quickstatements.toolforge.org/index_old.html#v1=",
                  ?qid, "%09", ?wdPropPid, "%09", ?P19, "%09", ?S248str, "%09", ?S248,
                  "%09", ?S245str,
                  "%09", ?s245,
                  "%09", ?S577str, "%09", ?s577,
                  "%09", ?S813str, "%09", ?s813,
                  ?comment)) AS ?QSlink)
  BIND(CONCAT("[", STR(?gettyHumanURI), " ", ?gettyID, "]") AS ?gettyLink)
  BIND(CONCAT("[", STR(?gettyObject), "]") AS ?gettyObjectLink)
}
ORDER BY xsd:integer(SUBSTR(STR(?qid),2))
# LIMIT 500 # I think this isn't needed
Try it! ; Try it!
{{WDGettyCompQuery |vocabulary=ulan |wdprop=P19 |gvppath=foaf:focus/gvp:biographyPreferred/schema:birthPlace/^foaf:focus |valuemapping wd= BIND(SUBSTR(STR(?gettyObject), 28) AS ?tgnID) ?wdObject wdt:P1667 [] . FILTER NOT EXISTS { ?wdObject wdt:P1667 ?tgnID . } |limit = 200 |action=find mismatch |output=nice}}
# property P19 statements mismatching Getty data
# with information in ULAN of the Getty Vocabulary Program (GVP)
# output: a human-readable table that allows visual checking of the data of Wikidata and the GVP

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
?item ?itemLabel ?wdObject ?wdObjectLabel ?gettyHumanURI ?gettySubjectTerm ?gettyObject ?gettyObjectTerm
  WITH { SELECT ?item ?gettyHumanURI ?gettySubjectTerm ?wdObject ?gettyObject ?gettyObjectTerm ?gettyID
  WHERE {
    ?item wdt:P245 ?gettyID .
    
    ?item p:P19 ?statement .
    ?statement ps:P19 ?wdObject .
    FILTER NOT EXISTS { ?statement prov:wasDerivedFrom ?wdRef . }
    FILTER NOT EXISTS { ?statement ?someQualProp [] .
                        [] wikibase:qualifier ?someQualProp . }
  } LIMIT 200 } 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 foaf:focus/gvp:biographyPreferred/schema:birthPlace/^foaf:focus ?gettyObject .  \u0023
    OPTIONAL { ?gettySubject gvp:prefLabelGVP/xl:literalForm ?gettySubjectTerm. }
    OPTIONAL { ?gettyObject gvp:prefLabelGVP/xl:literalForm ?gettyObjectTerm. }
  
  }
  BIND(SUBSTR(STR(?gettyObject), 28) AS ?tgnID)
  ?wdObject wdt:P1667 [] .
  FILTER NOT EXISTS { ?wdObject wdt:P1667 ?tgnID . }\u0023
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".}
}
ORDER BY xsd:integer(SUBSTR(STR(?qid),2))
# LIMIT 500 # I think this isn't needed
Try it! ; Try it!