query-8b14ec6c1157e5e8dab122c3256ccbef

rq turtle/ttl

1) Find all items for Wikimedia disambiguation pages with a label "FFCC" in any language.

2) Find all Wikimedia pages for the items.

3) Find all outgoing links (titles and items) on the disambiguation pages.

SELECT DISTINCT ?item ?article ?site ?title ?endpoint ?link_item ?link_title WHERE { SERVICE wikibase:mwapi { bd:serviceParam wikibase:endpoint "www.wikidata.org". bd:serviceParam wikibase:api "Generator". bd:serviceParam mwapi:generator "search". bd:serviceParam mwapi:gsrsearch "inlabel:FFCC". bd:serviceParam mwapi:gsrlimit "max". ?item wikibase:apiOutputItem mwapi:title. } ?item rdfs:label ?label. FILTER (STR(?label) = "FFCC") ?item wdt:P31/wdt:P279* wd:Q4167410. ?article schema:about ?item. ?article schema:isPartOf ?site. ?article schema:name ?title. BIND (STRBEFORE(STRAFTER(STR(?site), "https://"), "/") AS ?endpoint) OPTIONAL { SERVICE wikibase:mwapi { bd:serviceParam wikibase:endpoint ?endpoint. bd:serviceParam wikibase:api "Generator". bd:serviceParam mwapi:generator "links". bd:serviceParam mwapi:titles ?title. bd:serviceParam mwapi:gpllimit "max". bd:serviceParam mwapi:gplnamespace "0". ?link_item wikibase:apiOutputItem mwapi:item. ?link_title wikibase:apiOutput mwapi:title. } } }

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 rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bd: <http://www.bigdata.com/rdf#>
# 1) Find all items for Wikimedia disambiguation pages with a label "FFCC" in any language.
# 2) Find all Wikimedia pages for the items.
# 3) Find all outgoing links (titles and items) on the disambiguation pages.
SELECT DISTINCT ?item ?article ?site ?title ?endpoint ?link_item ?link_title
WHERE
{
  SERVICE wikibase:mwapi
  {
    bd:serviceParam wikibase:endpoint "www.wikidata.org".
    bd:serviceParam wikibase:api "Generator".
    bd:serviceParam mwapi:generator "search".
    bd:serviceParam mwapi:gsrsearch "inlabel:FFCC".
    bd:serviceParam mwapi:gsrlimit "max".
    ?item wikibase:apiOutputItem mwapi:title.
  }
  ?item rdfs:label ?label.
  FILTER (STR(?label) = "FFCC")
  ?item wdt:P31/wdt:P279* wd:Q4167410.
  ?article schema:about ?item.
  ?article schema:isPartOf ?site.
  ?article schema:name ?title.
  BIND (STRBEFORE(STRAFTER(STR(?site), "https://"), "/") AS ?endpoint)
  OPTIONAL
  {
    SERVICE wikibase:mwapi
    {
      bd:serviceParam wikibase:endpoint ?endpoint.
      bd:serviceParam wikibase:api "Generator".
      bd:serviceParam mwapi:generator "links".
      bd:serviceParam mwapi:titles ?title.
      bd:serviceParam mwapi:gpllimit "max".
      bd:serviceParam mwapi:gplnamespace "0".
      ?link_item wikibase:apiOutputItem mwapi:item.
      ?link_title wikibase:apiOutput mwapi:title.
    }
  }
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v3("?article"):::projected v6("?endpoint"):::projected v2("?item"):::projected v1("?label") v7("?link_item"):::projected v8("?link_title"):::projected v4("?site"):::projected v5("?title"):::projected a1((" ")) c19(["wd:Q4167410"]):::iri c28(["mwapi:item"]):::iri c9(["search"]):::literal c3(["bd:serviceParam"]):::iri c23(["links"]):::literal c5(["www.wikidata.org"]):::literal c13(["max"]):::literal c27(["0"]):::literal c11(["inlabel:FFCC"]):::literal c15(["mwapi:title"]):::iri c7(["Generator"]):::literal f0[["str(?label) = 'FFCC'"]] f0 --> v1 subgraph s1["http://wikiba.se/ontology#mwapi"] style s1 stroke-width:4px; c3 --"mwapi:endpoint"--> c5 c3 --"mwapi:api"--> c7 c3 --"mwapi:generator"--> c9 c3 --"mwapi:gsrsearch"--> c11 c3 --"mwapi:gsrlimit"--> c13 v2 --"mwapi:apiOutputItem"--> c15 end v2 --"rdfs:label"--> v1 v2 --"wdt:P31"--> a1 a1 --"wdt:P279"--> c19 v3 --"schema:about"--> v2 v3 --"schema:isPartOf"--> v4 v3 --"schema:name"--> v5 bind1[/"substring-before(substring-after(str(?site),'https://'),'/')"/] v4 --o bind1 bind1 --as--o v6 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; subgraph s1["http://wikiba.se/ontology#mwapi"] style s1 stroke-width:4px; c3 -."mwapi:endpoint".-> v6 c3 --"mwapi:api"--> c7 c3 --"mwapi:generator"--> c23 c3 --"mwapi:titles"--> v5 c3 --"mwapi:gpllimit"--> c13 c3 --"mwapi:gplnamespace"--> c27 v7 --"mwapi:apiOutputItem"--> c28 v8 --"mwapi:apiOutput"--> c15 end end