Wikidata:WikiProject 20th Century Press Archives/Tools & Tasks/Subject Category checks

Incomplete subject category items

edit
select distinct ?item ?itemLabel
where {
  ?item wdt:P8484 ?subjectCode .
  filter( not exists {
    ?item wdt:P31 wd:Q92707903 .
  })
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
Try it!
select distinct ?item ?itemLabel
where {
  ?item wdt:P31 wd:Q92707903 .
  filter( not exists {
    ?item wdt:P8484 ?subjectCode .
  })
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
Try it!

"Suspect" subject category items

edit

pm20 subject category items with more than one "instance of" statements

edit
select ?item ?itemLabel
where {
  ?item wdt:P31 wd:Q92707903 ;
        wdt:P31 ?otherClass .
  filter(?otherClass != wd:Q92707903)
   SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
Try it!

pm20 subject category labels starting with lowercase letter

edit
select distinct ?item ?itemLabel
where {
  ?item wdt:P31 wd:Q92707903 .
  ?item rdfs:label ?label .
  filter(lang(?label) = 'en')
  filter(regex(substr(?label,1,1), '[a-z]'))
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
Try it!

Check WD ./. PM20 endpoint

edit

All PM20 subject categories with folders, which have no WD item with according subject code

edit
PREFIX zbwext: <http://zbw.eu/namespaces/zbw-extensions/>#
select distinct ?notation ?subject
where {
  service <http://zbw.eu/beta/sparql/pm20/query> {
    select distinct ?notation ?subject
    where {
      ?subject skos:notation ?notation .
      filter(exists {
        ?pm20 a zbwext:SubjectFolder ;
              zbwext:subject ?subject .
      })
    }
  }
  bind(replace(?notation, ' ', '_') as ?subjectCode)
  #
  filter(not exists {
    ?item wdt:P8484 ?subjectCode .
  })
}
Try it!

WD subject codes which have no match in PM20 endpoint

edit
select distinct ?item ?itemLabel ?subjectCode ?notation
where {
  ?item wdt:P8484 ?subjectCode .
  bind(replace(?subjectCode, '_', ' ') as ?notation)
  
  optional {
    service <http://zbw.eu/beta/sparql/pm20/query> {
      select distinct ?notation ?subject
      where {
        # it is not reqiered that according subject category has folders!
        # (may be empty level in the hierarchy)
        ?subject skos:notation ?notation .
      }
    }
  }
  filter(!bound(?subject))
  #
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
order by ?notation
Try it!

PM20 folders linking to subjects which are not PM20 Subject Categories

edit

The following query uses these:

  • Properties: instance of (P31)     , PM20 folder ID (P4293)     , main subject (P921)     
    select distinct ?item ?itemLabel
    where {
      ?item wdt:P31 wd:Q91257459 ; 
            wdt:P4293 ?pm20Id ;
            wdt:P921 ?subject .
      filter(not exists {
        ?subject wdt:P31 wd:Q92707903 .
      })
      
      SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
    }
    order by ?subject