query-9bf64d15f81be59d6f0e0d867b8d40cd

rq turtle/ttl

Search in category SELECT DISTINCT ?item ?itemLabel ?inst ?instLabel ?found_in WITH { SELECT ?item (GROUP_CONCAT(?endpoint; SEPARATOR=", ") AS ?found_in) WHERE { ?cat schema:about wd:Q8682545 . ?cat schema:isPartOf ?wikimedia_site. ?cat schema:name ?category_title. BIND (STRBEFORE(STRAFTER(STR(?wikimedia_site), "https://"), "/") AS ?endpoint) OPTIONAL { SERVICE wikibase:mwapi { bd:serviceParam wikibase:endpoint ?endpoint. bd:serviceParam wikibase:api "Generator". bd:serviceParam mwapi:generator "categorymembers". bd:serviceParam mwapi:gcmtitle ?category_title. bd:serviceParam mwapi:gcmlimit "max". ?item wikibase:apiOutputItem mwapi:item. } } FILTER BOUND (?item) } GROUP BY ?item } AS %get_items WHERE { INCLUDE %get_items OPTIONAL { ?item wdt:P31 ?inst } SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],it". } }

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#>
#Search in category
SELECT DISTINCT ?item ?itemLabel ?inst ?instLabel ?found_in
WHERE
{

{
  SELECT ?item (GROUP_CONCAT(?endpoint; SEPARATOR=", ") AS ?found_in)
  WHERE
  {
    ?cat schema:about wd:Q8682545 .
    ?cat schema:isPartOf ?wikimedia_site.
    ?cat schema:name ?category_title.
    BIND (STRBEFORE(STRAFTER(STR(?wikimedia_site), "https://"), "/") AS ?endpoint)
    OPTIONAL
    {
      SERVICE wikibase:mwapi
      {
        bd:serviceParam wikibase:endpoint ?endpoint.
        bd:serviceParam wikibase:api "Generator".
        bd:serviceParam mwapi:generator "categorymembers".
        bd:serviceParam mwapi:gcmtitle ?category_title.
        bd:serviceParam mwapi:gcmlimit "max".
        ?item wikibase:apiOutputItem mwapi:item.
      }
    }
    FILTER BOUND (?item)
  }
  GROUP BY ?item
}  OPTIONAL { ?item wdt:P31 ?inst }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],it". }
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v2("?cat") v4("?category_title") v5("?endpoint") v6("?found_in"):::projected v7("?inst"):::projected v1("?item"):::projected v3("?wikimedia_site") c16(["mwapi:item"]):::iri c14(["max"]):::literal c11(["categorymembers"]):::literal c6(["bd:serviceParam"]):::iri c2(["wd:Q8682545"]):::iri c20(["#91;AUTO_LANGUAGE#93;,it"]):::literal c9(["Generator"]):::literal f0[["bound(?item)"]] f0 --> v1 v2 --"schema:about"--> c2 v2 --"schema:isPartOf"--> v3 v2 --"schema:name"--> v4 bind1[/"substring-before(substring-after(str(?wikimedia_site),'https://'),'/')"/] v3 --o bind1 bind1 --as--o v5 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; subgraph s1["http://wikiba.se/ontology#mwapi"] style s1 stroke-width:4px; c6 -."mwapi:endpoint".-> v5 c6 --"mwapi:api"--> c9 c6 --"mwapi:generator"--> c11 c6 --"mwapi:gcmtitle"--> v4 c6 --"mwapi:gcmlimit"--> c14 v1 --"mwapi:apiOutputItem"--> c16 end end bind3[/"?endpoint"/] v5 --o bind3 bind3 --as--o v6 subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v1 -."wdt:P31".-> v7 end subgraph s2["http://wikiba.se/ontology#label"] style s2 stroke-width:4px; c6 --"mwapi:language"--> c20 end