Skip to content

Instantly share code, notes, and snippets.

@baskaufs
Created October 6, 2021 21:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baskaufs/dc3ec935d4cfb0c3f86a98da9a63f0e9 to your computer and use it in GitHub Desktop.
Save baskaufs/dc3ec935d4cfb0c3f86a98da9a63f0e9 to your computer and use it in GitHub Desktop.
SPARQL query to find non-artwork items whose ACT ID needs to be switched to the artwork.
# work1 has an ACT ID, and is NOT an artwork. work2 is an artwork and may or may not have an ACT ID.
# If work2 does not have an ACT ID, then the ACT ID used with work1 should be transferred to work2 and the work1 ACT ID be deleted.
select distinct ?work1 ?actId1 ?work1Label ?class1Label ?work2 ?actId2 ?work2Label ?class2Label where {
?work1 wdt:P9092 ?actId1.
?work1 wdt:P18 ?commonsImage.
optional {?work1 wdt:P31 ?class1.}
?work2 wdt:P18 ?commonsImage.
?work2 wdt:P31 ?class2.
optional {?work2 wdt:P9092 ?actId2.}
filter(?work1 != ?work2)
minus {?work1 wdt:P31 wd:Q3305213.} # painting
minus {?work1 wdt:P31 wd:Q15711026.} # altarpiece
minus {?work1 wdt:P31 wd:Q93184.} # drawing
minus {?work1 wdt:P31 wd:Q22669139.} # fresco
minus {?work1 wdt:P31 wd:Q15123870.} # lithograph
minus {?work1 wdt:P31 wd:Q8362.} # miniature
minus {?work1 wdt:P31 wd:Q133067.} # mosaic
minus {?work1 wdt:P31 wd:Q219423.} # mural
minus {?work1 wdt:P31 wd:Q125191.} # photograph
minus {?work1 wdt:P31 wd:Q11060274.} # print
minus {?work1 wdt:P31 wd:Q1064538.} # quilt
minus {?work1 wdt:P31 wd:Q245117.} # relief sculpture
minus {?work1 wdt:P31 wd:Q860861.} # sculpture
minus {?work1 wdt:P31 wd:Q2282251.} # seven-branched candlestick
minus {?work1 wdt:P31 wd:Q1473346.} # stained glass
minus {?work1 wdt:P31 wd:Q179700.} # statue
minus {?work1 wdt:P31 wd:Q18761202.} # watercolor painting
{?work1 wdt:P31 wd:Q3305213.} # painting
union {?work2 wdt:P31 wd:Q15711026.} # altarpiece
union {?work2 wdt:P31 wd:Q93184.} # drawing
union {?work2 wdt:P31 wd:Q22669139.} # fresco
union {?work2 wdt:P31 wd:Q15123870.} # lithograph
union {?work2 wdt:P31 wd:Q8362.} # miniature
union {?work2 wdt:P31 wd:Q133067.} # mosaic
union {?work2 wdt:P31 wd:Q219423.} # mural
union {?work2 wdt:P31 wd:Q125191.} # photograph
union {?work2 wdt:P31 wd:Q11060274.} # print
union {?work2 wdt:P31 wd:Q1064538.} # quilt
union {?work2 wdt:P31 wd:Q245117.} # relief sculpture
union {?work2 wdt:P31 wd:Q860861.} # sculpture
union {?work2 wdt:P31 wd:Q2282251.} # seven-branched candlestick
union {?work2 wdt:P31 wd:Q1473346.} # stained glass
union {?work2 wdt:P31 wd:Q179700.} # statue
union {?work2 wdt:P31 wd:Q18761202.} # watercolor painting
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } # Helps get the label in your language, if not, then en language
}
order by ?work1Label
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment