query-a00be7582196b9304a633f10d00088ab

rq turtle/ttl

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

Example File:Veronica chamaedrys - Pl0001 - DescriptionFR01 - 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)

SELECT DISTINCT ?plate ?file ?title ?mainsubject ?mainsubjectLabel ?mainsubjectIsA ?collection ?instanceof ?copyrightstatus 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 "100" . ?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 "3000" . ?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")," - DescriptionFR") AS ?plate) FILTER(REGEX(?title,"(DescriptionFR[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) } 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 bd: <http://www.bigdata.com/rdf#>
# For all text pages in French (in Category:Flora Batava - KB copy, and its subcategories), are all required structured data fields present?
# Example File:Veronica chamaedrys - Pl0001 - DescriptionFR01 - 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)

SELECT DISTINCT 
?plate ?file ?title ?mainsubject ?mainsubjectLabel ?mainsubjectIsA ?collection ?instanceof ?copyrightstatus
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 "100" .
    ?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 "3000" .
    ?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")," - DescriptionFR") AS ?plate)
  FILTER(REGEX(?title,"(DescriptionFR[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)
} 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 v7("?file"):::projected v2("?instanceof"):::projected v8("?mainsubject"):::projected v9("?mainsubjectIsA"):::projected v10("?mainsubjectLabel"):::projected v4("?ns") v6("?pageid") v8("?plate"):::projected v3("?title"):::projected c18(["@ns"]):::literal c21(["3000"]):::literal c11(["Category:Flora Batava - KB copy"]):::literal c5(["bd:serviceParam"]):::iri c20(["file"]):::literal c9(["commons.wikimedia.org"]):::literal c22(["@pageid"]):::literal c13(["categorymembers"]):::literal c15(["100"]):::literal c17(["mwapi:title"]):::iri c7(["Generator"]):::literal f0[["regex(?title,'(DescriptionFR#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'),' - DescriptionFR')"/] v3 --o bind3 bind3 --as--o v8 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v7 -."wdt: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 --"wdt:P31"--> v9 end end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v7 -."wdt:P31".-> v2 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v7 -."wdt:P6216".-> v11 end subgraph optional3["(optional)"] style optional3 fill:#bbf,stroke-dasharray: 5 5; v7 -."wdt:P195".-> v12 end