query-3a460720330fe6176460450b8b826aa9

rq turtle/ttl

Propertiesinstance of (P31)subclass of (P279)

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 schema: <http://schema.org/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?item ?itemLabel WHERE {
  ?link schema:about wd:Q87734646; schema:isPartOf <https://en.wikipedia.org/>; schema:name ?title . #point to the wiki you are searching, remove line if no QID
  SERVICE wikibase:mwapi {
     bd:serviceParam wikibase:api "Generator" .
     bd:serviceParam wikibase:endpoint "en.wikipedia.org" . #point to the wiki you are searching
     bd:serviceParam mwapi:gcmtitle ?title . #replace here if no QID
     bd:serviceParam mwapi:generator "categorymembers" .
     bd:serviceParam mwapi:gcmprop "ids|title|type" .
     bd:serviceParam mwapi:gcmlimit "max" .
    ?item wikibase:apiOutputItem mwapi:item .
    ?ns wikibase:apiOutput "@ns" .
  }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  MINUS { ?item wdt:P31 wd:Q3241045 .} #filtering out disease outbreak items
  MINUS { ?item wdt:P31/wdt:P279* wd:Q1048835 .} #filtering out countries and other political territorial entities
  FILTER (?ns = "0"). #showing only articles
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v4("?item"):::projected v2("?link") v1("?ns") v3("?title") a1((" ")) c21(["mwapi:item"]):::iri c23(["@ns"]):::literal c30(["wd:Q1048835"]):::iri c5([https://en.wikipedia.org/]):::iri c12(["en.wikipedia.org"]):::literal c8(["bd:serviceParam"]):::iri c28(["wd:Q3241045"]):::iri c19(["max"]):::literal c15(["categorymembers"]):::literal c3(["wd:Q87734646"]):::iri c26(["#91;AUTO_LANGUAGE#93;,en"]):::literal c17(["ids|title|type"]):::literal c10(["Generator"]):::literal f0[["?ns = '0'"]] f0 --> v1 v2 --"schema:about"--> c3 v2 --"schema:isPartOf"--> c5 v2 --"schema:name"--> v3 subgraph s1["http://wikiba.se/ontology#mwapi"] style s1 stroke-width:4px; c8 --"mwapi:api"--> c10 c8 --"mwapi:endpoint"--> c12 c8 --"mwapi:gcmtitle"--> v3 c8 --"mwapi:generator"--> c15 c8 --"mwapi:gcmprop"--> c17 c8 --"mwapi:gcmlimit"--> c19 v4 --"mwapi:apiOutputItem"--> c21 v1 --"mwapi:apiOutput"--> c23 end subgraph s2["http://wikiba.se/ontology#label"] style s2 stroke-width:4px; c8 --"mwapi:language"--> c26 end subgraph minus1["MINUS"] style minus1 stroke-width:6px,fill:pink,stroke:red; v4 --"wdt:P31"--> c28 end subgraph minus2["MINUS"] style minus2 stroke-width:6px,fill:pink,stroke:red; v4 --"wdt:P31"--> a1 a1 --"wdt:P279"--> c30 end