query-27d771989101c138906f57b4336c63f0

rq turtle/ttl

For all text pages in Dutch (in Category:Flora Batava - KB copy, and its subcategories), are all required structured data fields present?

Example File:Veronica chamaedrys - Pl0001 - DescriptionNL01 - FloraBatava-KB-v01.jpg:

- main subject (P921) = Qid of depicted plant spieces (for instance Veronica chamaedrys (Q157343))

- collection (P195) = Koninklijke Bibliotheek (Q1526131)

- instance of (P31) = digital image (Q1250322)

- copyright status (P6216) = public domain (Q19652)

- source of file (P7482) = file available on the internet (Q74228490) with qualifiers

- operator (P137) = kb.nl (Q93997197)

- described at URL (P973) = URL of image on kb.nl (for instance https://galerij.kb.nl/kb.html#/nl/florabatava01/page/16/zoom/3/lat/-67.06743335108297/lng/-51.328125)

SELECT DISTINCT ?plate ?file ?title ?mainsubject ?mainsubjectLabel ?mainsubjectIsA ?collection ?instanceof ?copyrightstatus ?source ?operator ?describedatURL WITH { SELECT ?file ?title WHERE { SERVICE wikibase:mwapi { bd:serviceParam wikibase:api "Generator" . bd:serviceParam wikibase:endpoint "commons.wikimedia.org" . bd:serviceParam mwapi:gcmtitle "Category:Flora Batava - KB copy" . bd:serviceParam mwapi:generator "categorymembers" . bd:serviceParam mwapi:gcmlimit "50" . ?categoryName wikibase:apiOutput mwapi:title . ?ns wikibase:apiOutput "@ns". } FILTER (?ns = "14") # (sub)categories only

SERVICE wikibase:mwapi { bd:serviceParam wikibase:api "Generator" . bd:serviceParam wikibase:endpoint "commons.wikimedia.org" . bd:serviceParam mwapi:gcmtitle ?categoryName. bd:serviceParam mwapi:generator "categorymembers" . bd:serviceParam mwapi:gcmtype "file" . bd:serviceParam mwapi:gcmlimit "1000" . ?title wikibase:apiOutput mwapi:title . ?pageid wikibase:apiOutput "@pageid" . } BIND (URI(CONCAT('https://commons.wikimedia.org/entity/M', ?pageid)) AS ?file) } } AS %get_files WHERE { INCLUDE %get_files BIND(STRBEFORE(STRAFTER(?title," - Pl")," - DescriptionNL") AS ?plate) FILTER(REGEX(?title,"(DescriptionNL[0-9]+ - FloraBatava-KB-v[0-9]{2}.jpg)$"))

OPTIONAL{ ?file wdt:P921 ?mainsubject. # main subject (P921) = Qid of depicted plant spieces (for instance Veronica chamaedrys (Q157343))
SERVICE https://query.wikidata.org/sparql { ?mainsubject rdfs:label ?mainsubjectLabel FILTER (lang(?mainsubjectLabel) = "la"). ?mainsubject wdt:P31 ?mainsubjectIsA. FILTER (?mainsubjectIsA = wd:Q16521) # ?mainsubject must be instance of taxon/Q16521 } } OPTIONAL{ ?file wdt:P31 ?instanceof. FILTER (?instanceof = wd:Q1250322). } # ?instanceof must be a digital image (Q1250322) OPTIONAL{ ?file wdt:P6216 ?copyrightstatus. } # copyright status (P6216) = public domain (Q19652) OPTIONAL{ ?file wdt:P195 ?collection. } # collection (P195) = Koninklijke Bibliotheek (Q1526131) OPTIONAL{ ?file p:P7482 [ps:P7482 ?source; pq:P137 ?operator; pq:P973 ?describedatURL].}

} ORDER BY ?plate

Use at

PREFIX mwapi: <http://wikiba.se/ontology#>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
# For all text pages in Dutch (in Category:Flora Batava - KB copy, and its subcategories), are all required structured data fields present?
# Example File:Veronica chamaedrys - Pl0001 - DescriptionNL01 - FloraBatava-KB-v01.jpg:
# - main subject (P921) = Qid of depicted plant spieces (for instance Veronica chamaedrys (Q157343))
# - collection (P195) = Koninklijke Bibliotheek (Q1526131)
# - instance of (P31) = digital image (Q1250322)
# - copyright status (P6216) = public domain (Q19652)
# - source of file (P7482) = file available on the internet (Q74228490) with qualifiers
#   - operator (P137) = kb.nl (Q93997197)
#   - described at URL (P973) = URL of image on kb.nl (for instance https://galerij.kb.nl/kb.html#/nl/florabatava01/page/16/zoom/3/lat/-67.06743335108297/lng/-51.328125)

SELECT DISTINCT 
?plate ?file ?title 
?mainsubject ?mainsubjectLabel ?mainsubjectIsA ?collection ?instanceof ?copyrightstatus 
?source ?operator ?describedatURL 
WHERE
{

{
  SELECT ?file ?title
  WHERE
  {
  SERVICE wikibase:mwapi
  {
    bd:serviceParam wikibase:api "Generator" .
    bd:serviceParam wikibase:endpoint "commons.wikimedia.org" .
    bd:serviceParam mwapi:gcmtitle "Category:Flora Batava - KB copy" .
    bd:serviceParam mwapi:generator "categorymembers" .
    bd:serviceParam mwapi:gcmlimit "50" .
    ?categoryName wikibase:apiOutput mwapi:title .
    ?ns wikibase:apiOutput "@ns".
  }
  FILTER (?ns = "14") # (sub)categories only

  SERVICE wikibase:mwapi
  {
    bd:serviceParam wikibase:api "Generator" .
    bd:serviceParam wikibase:endpoint "commons.wikimedia.org" .
    bd:serviceParam mwapi:gcmtitle ?categoryName.
    bd:serviceParam mwapi:generator "categorymembers" .
    bd:serviceParam mwapi:gcmtype "file" .
    bd:serviceParam mwapi:gcmlimit "1000" .
    ?title wikibase:apiOutput mwapi:title .
    ?pageid wikibase:apiOutput "@pageid" .
  }
    BIND (URI(CONCAT('https://commons.wikimedia.org/entity/M', ?pageid)) AS ?file)
  }
}  BIND(STRBEFORE(STRAFTER(?title," - Pl")," - DescriptionNL") AS ?plate)
  FILTER(REGEX(?title,"(DescriptionNL[0-9]+ - FloraBatava-KB-v[0-9]{2}.jpg)$"))

  OPTIONAL{ ?file wdt:P921 ?mainsubject. #  main subject (P921) = Qid of depicted plant spieces (for instance Veronica chamaedrys (Q157343))   
            SERVICE <https://query.wikidata.org/sparql> {
              ?mainsubject rdfs:label ?mainsubjectLabel FILTER (lang(?mainsubjectLabel) = "la").
              ?mainsubject wdt:P31 ?mainsubjectIsA. 
              FILTER (?mainsubjectIsA = wd:Q16521) # ?mainsubject must be instance of taxon/Q16521
            }
          } 
  OPTIONAL{ ?file wdt:P31 ?instanceof.
            FILTER (?instanceof = wd:Q1250322).
          } # ?instanceof must be a digital image (Q1250322) 
  OPTIONAL{ ?file wdt:P6216 ?copyrightstatus.
          }  # copyright status (P6216) = public domain (Q19652)
  OPTIONAL{ ?file wdt:P195 ?collection.
          }  # collection (P195) = Koninklijke Bibliotheek (Q1526131)
  OPTIONAL{ ?file p:P7482 [ps:P7482 ?source; pq:P137 ?operator; pq:P973 ?describedatURL].}

} ORDER BY ?plate

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v5("?categoryName") v12("?collection"):::projected v11("?copyrightstatus"):::projected v15("?describedatURL"):::projected v7("?file"):::projected v2("?instanceof"):::projected v8("?mainsubject"):::projected v9("?mainsubjectIsA"):::projected v10("?mainsubjectLabel"):::projected v4("?ns") v14("?operator"):::projected v6("?pageid") v8("?plate"):::projected v13("?source"):::projected v3("?title"):::projected a1((" ")) c18(["@ns"]):::literal c21(["1000"]):::literal c11(["Category:Flora Batava - KB copy"]):::literal c5(["bd:serviceParam"]):::iri c20(["file"]):::literal c15(["50"]):::literal c9(["commons.wikimedia.org"]):::literal c22(["@pageid"]):::literal c13(["categorymembers"]):::literal c17(["mwapi:title"]):::iri c7(["Generator"]):::literal f0[["regex(?title,'(DescriptionNL#91;0-9#93;+ - FloraBatava-KB-v#91;0-9#93;{2}.jpg)$')"]] f0 --> v3 f1[["?ns = '14'"]] f1 --> v4 subgraph s1["http://wikiba.se/ontology#mwapi"] style s1 stroke-width:4px; c5 --"mwapi:api"--> c7 c5 --"mwapi:endpoint"--> c9 c5 --"mwapi:gcmtitle"--> c11 c5 --"mwapi:generator"--> c13 c5 --"mwapi:gcmlimit"--> c15 v5 --"mwapi:apiOutput"--> c17 v4 --"mwapi:apiOutput"--> c18 end subgraph s1["http://wikiba.se/ontology#mwapi"] style s1 stroke-width:4px; c5 --"mwapi:api"--> c7 c5 --"mwapi:endpoint"--> c9 c5 --"mwapi:gcmtitle"--> v5 c5 --"mwapi:generator"--> c13 c5 --"mwapi:gcmtype"--> c20 c5 --"mwapi:gcmlimit"--> c21 v3 --"mwapi:apiOutput"--> c17 v6 --"mwapi:apiOutput"--> c22 end bind2[/"concat('https://commons.wikimedia.org/entity/M',?pageid)"/] v6 --o bind2 bind2 --as--o v7 bind3[/"substring-before(substring-after(?title,' - Pl'),' - DescriptionNL')"/] v3 --o bind3 bind3 --as--o v8 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v7 -."p:direct/P921".-> v8 subgraph s2["https://query.wikidata.org/sparql"] style s2 stroke-width:4px; f4[["?mainsubjectIsA = 'wd:Q16521'"]] f4 --> v9 f5[["?mainsubjectLabel = 'la'"]] f5 --> v10 v8 --"rdfs:label"--> v10 v8 --"p:direct/P31"--> v9 end end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v7 -."p:direct/P31".-> v2 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v7 -."p:direct/P6216".-> v11 end subgraph optional3["(optional)"] style optional3 fill:#bbf,stroke-dasharray: 5 5; v7 -."p:direct/P195".-> v12 end subgraph optional4["(optional)"] style optional4 fill:#bbf,stroke-dasharray: 5 5; a1 -."p:statement/P7482".-> v13 a1 --"p:qualifier/P137"--> v14 a1 --"p:qualifier/P973"--> v15 v7 --"p:P7482"--> a1 end