HeardLibrary / vandycite

0 stars 0 forks source link

Step 1: delete ACT IDs from items where already connected to an item that's a valid artwork type #8

Closed baskaufs closed 3 years ago

baskaufs commented 3 years ago

Valid artwork types:

minus {?item wdt:P31 wd:Q3305213.} # painting
  minus {?item wdt:P31 wd:Q15711026.} # altarpiece  
  minus {?item wdt:P31 wd:Q93184.} # drawing
  minus {?item wdt:P31 wd:Q22669139.} # fresco
  minus {?item wdt:P31 wd:Q15123870.} # lithograph
  minus {?item wdt:P31 wd:Q8362.} # miniature
  minus {?item wdt:P31 wd:Q133067.} # mosaic
  minus {?item wdt:P31 wd:Q219423.} # mural
  minus {?item wdt:P31 wd:Q125191.} # photograph
  minus {?item wdt:P31 wd:Q11060274.} # print
  minus {?item wdt:P31 wd:Q1064538.} # quilt
  minus {?item wdt:P31 wd:Q245117.} # relief sculpture
  minus {?item wdt:P31 wd:Q860861.} # sculpture
  minus {?item wdt:P31 wd:Q2282251.} # seven-branched candlestick
  minus {?item wdt:P31 wd:Q1473346.} # stained glass
  minus {?item wdt:P31 wd:Q179700.} # statue
  minus {?item wdt:P31 wd:Q18761202.} # watercolor painting
baskaufs commented 3 years ago

If the Commons artwork is an image for a valid artwork type AND also some dumb kind of item:

If the Commons artwork is NOT an image for any valid artwork type

baskaufs commented 3 years ago

LInk to generate comparison query

https://w.wiki/4B6U

baskaufs commented 3 years ago

Better queries

First query:

# work1 has an ACT ID, and is an artwork. work2 is NOT an artwork and may or may not have an ACT ID.
# If work2 has an ACT ID, it should be removed. If it doesn't, no action is required.
select distinct ?work1 ?actId1 ?work1Label ?class1Label ?work2 ?actId2 ?work2Label ?class2Label where {
  ?work1 wdt:P9092 ?actId1.
  ?work1 wdt:P18 ?commonsImage.
  ?work1 wdt:P31 ?class1.
  ?work2 wdt:P18 ?commonsImage.
  optional{?work2 wdt:P31 ?class2.}
  optional {?work2 wdt:P9092 ?actId2.}
  filter(?work1 != ?work2)

  minus {?work2 wdt:P31 wd:Q3305213.} # painting
  minus {?work2 wdt:P31 wd:Q15711026.} # altarpiece  
  minus {?work2 wdt:P31 wd:Q93184.} # drawing
  minus {?work2 wdt:P31 wd:Q22669139.} # fresco
  minus {?work2 wdt:P31 wd:Q15123870.} # lithograph
  minus {?work2 wdt:P31 wd:Q8362.} # miniature
  minus {?work2 wdt:P31 wd:Q133067.} # mosaic
  minus {?work2 wdt:P31 wd:Q219423.} # mural
  minus {?work2 wdt:P31 wd:Q125191.} # photograph
  minus {?work2 wdt:P31 wd:Q11060274.} # print
  minus {?work2 wdt:P31 wd:Q1064538.} # quilt
  minus {?work2 wdt:P31 wd:Q245117.} # relief sculpture
  minus {?work2 wdt:P31 wd:Q860861.} # sculpture
  minus {?work2 wdt:P31 wd:Q2282251.} # seven-branched candlestick
  minus {?work2 wdt:P31 wd:Q1473346.} # stained glass
  minus {?work2 wdt:P31 wd:Q179700.} # statue
  minus {?work2 wdt:P31 wd:Q18761202.} # watercolor painting

   {?work1 wdt:P31 wd:Q3305213.} # painting
  union {?work1 wdt:P31 wd:Q15711026.} # altarpiece  
  union {?work1 wdt:P31 wd:Q93184.} # drawing
  union {?work1 wdt:P31 wd:Q22669139.} # fresco
  union {?work1 wdt:P31 wd:Q15123870.} # lithograph
  union {?work1 wdt:P31 wd:Q8362.} # miniature
  union {?work1 wdt:P31 wd:Q133067.} # mosaic
  union {?work1 wdt:P31 wd:Q219423.} # mural
  union {?work1 wdt:P31 wd:Q125191.} # photograph
  union {?work1 wdt:P31 wd:Q11060274.} # print
  union {?work1 wdt:P31 wd:Q1064538.} # quilt
  union {?work1 wdt:P31 wd:Q245117.} # relief sculpture
  union {?work1 wdt:P31 wd:Q860861.} # sculpture
  union {?work1 wdt:P31 wd:Q2282251.} # seven-branched candlestick
  union {?work1 wdt:P31 wd:Q1473346.} # stained glass
  union {?work1 wdt:P31 wd:Q179700.} # statue
  union {?work1 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

Second query:

# 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
baskaufs commented 3 years ago

This query seems to have fixed the problem with the query above, although not as sophisticated (had to ignore non-artworks for work2):

# work1 has an ACT ID, and is NOT an artwork. work2 is anything and may or may not have an ACT ID.
# If work2 does not have an ACT ID and it's an artwork, 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
  minus {?work1 wdt:P31 wd:Q48498.} # illuminated manuscript
  minus {?work1 wdt:P31 wd:Q184296.} # tapestry

  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