query-00e26c50fabb5d3a920f618d033bdca4

rq turtle/ttl

Finding disambiguation pages and equally-labelled occupations this is what I have so far, but unfortunately the query times out: Wikidata:SPARQL query service/query optimization#Searching labels. I wanted to find such disambiguation page items as well as valid occupations with the same label. Following (P106)occupation ) are erroneously used as property values, e.g. for (Q404866)Coach Sometimes, disambiguation page items (such as

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#>
SELECT ?pseudoOccupation ?realOccupation
WHERE
{
  {
    SELECT DISTINCT ?pseudoOccupation
    WHERE
    {
      ?someone wdt:P106 ?pseudoOccupation.
      ?pseudoOccupation wdt:P31 wd:Q4167410.
    }
  }
  ?pseudoOccupation rdfs:label ?label.
  BIND(CONCAT('inlabel:', ?label) AS ?search)
  SERVICE wikibase:mwapi
  {
    bd:serviceParam wikibase:endpoint 'www.wikidata.org';
                    wikibase:api 'Generator';
                    mwapi:generator 'search';
                    mwapi:gsrsearch ?search;
                    mwapi:gsrlimit 'max'.
    ?realOccupation wikibase:apiOutputItem mwapi:title.
  }
  ?realOccupation rdfs:label ?label.
  FILTER EXISTS
  {
    VALUES ?occupation { wd:Q12737077 wd:Q28640 wd:Q4164871 }
    ?realOccupation wdt:P31 ?occupation.
  }
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v5("?label") v1("?occupation") v4("?pseudoOccupation"):::projected v2("?realOccupation"):::projected v6("?search") v3("?someone") c8(["www.wikidata.org"]):::literal c3(["wd:Q4167410"]):::iri c15(["max"]):::literal c12(["search"]):::literal c6(["bd:serviceParam"]):::iri c17(["mwapi:title"]):::iri c10(["Generator"]):::literal f0[[" "]] subgraph f0e0["Exists Clause"] bind0[/VALUES ?occupation/] bind0-->e0v1 bind00(["wd:Q12737077"]) bind00 --> bind0 bind01(["wd:Q28640"]) bind01 --> bind0 bind02(["wd:Q4164871"]) bind02 --> bind0 e0v2 --"wdt:P31"--> e0v1 e0v1("?occupation"):::projected e0v2("?realOccupation"):::projected end f0--EXISTS--> f0e0 f0 --> v2 f0 --> c1 f0 --> v1 bind1[/VALUES ?occupation/] bind1-->v1 bind10(["wd:Q12737077"]) bind10 --> bind1 bind11(["wd:Q28640"]) bind11 --> bind1 bind12(["wd:Q4164871"]) bind12 --> bind1 v2 --"wdt:P31"--> v1 v3 --"wdt:P106"--> v4 v4 --"wdt:P31"--> c3 v4 --"rdfs:label"--> v5 bind2[/"concat('inlabel:',?label)"/] v5 --o bind2 bind2 --as--o v6 subgraph s1["http://wikiba.se/ontology#mwapi"] style s1 stroke-width:4px; c6 --"mwapi:endpoint"--> c8 c6 --"mwapi:api"--> c10 c6 --"mwapi:generator"--> c12 c6 --"mwapi:gsrsearch"--> v6 c6 --"mwapi:gsrlimit"--> c15 v2 --"mwapi:apiOutputItem"--> c17 end v2 --"rdfs:label"--> v5