query-619c3e9b65654c1723401e4e164bc3b0

rq turtle/ttl

曖昧さ回避関係は1万件を超えていてmwapiで全部は取得できないので、mwapi:gcmstartsortkeyprefixでずらしながら取得する必要がある。Category:曖昧さ回避のサブクラスに属さず、かつリダイレクトが存在するもの。(Q4167410)Wikimedia disambiguation page に含まれていて、でもwikidata項目がCategory:曖昧さ回避

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 owl: <http://www.w3.org/2002/07/owl#>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT (SAMPLE(?pagetitle) AS ?title) ?item  


WHERE {
   {
  SELECT ?pagetitle ?item WHERE {  
    wd:Q4167410 wdt:P910 ?category .
    ?link schema:about ?category; schema:isPartOf <https://ja.wikipedia.org/>; schema:name ?title .
    SERVICE wikibase:mwapi {
       bd:serviceParam wikibase:api "Generator" .
       bd:serviceParam wikibase:endpoint "ja.wikipedia.org" .
       bd:serviceParam mwapi:gcmtitle ?title .
       bd:serviceParam mwapi:generator "categorymembers" .
       bd:serviceParam mwapi:gcmnamespace "0" .
#       bd:serviceParam mwapi:gcmstartsortkeyprefix "T" .
       bd:serviceParam mwapi:gcmlimit "max" .
      # out
      ?pagetitle wikibase:apiOutput mwapi:title  .
      ?item wikibase:apiOutputItem mwapi:item .
    } 
    MINUS { ?item wdt:P31/wdt:P279* wd:Q4167410; }
  }
}.
  ?redirect owl:sameAs ?item .
}
GROUP BY ?item

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v1("?category") v5("?item"):::projected v2("?link") v4("?pagetitle"):::projected v6("?redirect") v7("?title") a1((" ")) c1(["wd:Q4167410"]):::iri c23(["mwapi:item"]):::iri c8(["bd:serviceParam"]):::iri c12(["ja.wikipedia.org"]):::literal c19(["max"]):::literal c15(["categorymembers"]):::literal c17(["0"]):::literal c5([https://ja.wikipedia.org/]):::iri c21(["mwapi:title"]):::iri c10(["Generator"]):::literal c1 --"wdt:P910"--> v1 v2 --"schema:about"--> v1 v2 --"schema:isPartOf"--> c5 v2 --"schema:name"--> v7 subgraph s1["http://wikiba.se/ontology#mwapi"] style s1 stroke-width:4px; c8 --"mwapi:api"--> c10 c8 --"mwapi:endpoint"--> c12 c8 --"mwapi:gcmtitle"--> v7 c8 --"mwapi:generator"--> c15 c8 --"mwapi:gcmnamespace"--> c17 c8 --"mwapi:gcmlimit"--> c19 v4 --"mwapi:apiOutput"--> c21 v5 --"mwapi:apiOutputItem"--> c23 end subgraph minus0["MINUS"] style minus0 stroke-width:6px,fill:pink,stroke:red; v5 --"wdt:P31"--> a1 a1 --"wdt:P279"--> c1 end v6 --"owl:sameAs"--> v5 bind2[/"sample(?pagetitle)"/] v4 --o bind2 bind2 --as--o v7