query-a846d94682edcc7e3d024f5c715387cd

rq turtle/ttl

15:04, 23 December 2016 (UTC)) talk (ValterVB--

Use at

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 prov: <http://www.w3.org/ns/prov#>
SELECT ?item (COUNT(DISTINCT ?p) as ?ct) 
{  
    { SELECT ?item {    ?item wikibase:statements 2 
                              ; wikibase:sitelinks 0 
                              ; wdt:P31 wd:Q5 
                              ; wdt:P21 [] 
                   } LIMIT 1000 }
        # avoid timeout on wikibase:claim / ?sp 
    ?item ?sp ?claim .                  # double-check wikibase:statements
    ?p wikibase:claim ?sp .             # double-check wikibase:statements
    OPTIONAL{ ?backlink ?s ?item }                  FILTER(!BOUND(?backlink)) 
    OPTIONAL{ ?claim prov:wasDerivedFrom ?ref . ?ref ?p ?v . FILTER NOT EXISTS { ?v wdt:P31 wd:Q10876391 } }    FILTER(!BOUND(?ref)) # exclude no source and wikipedia only source
    # OPTIONAL{ ?claim prov:wasDerivedFrom ?ref }   FILTER(!BOUND(?ref)) # exclude any reference
    OPTIONAL{ ?art schema:about ?item }             FILTER(!BOUND(?art))    # double-check wikibase:sitelinks
}
GROUP BY ?item
HAVING (?ct = 2)    # double-check wikibase:statements

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v2("?art") v4("?backlink") v8("?claim") v11("?ct") v6("?item"):::projected v9("?p"):::projected v3("?ref") v10("?s") v7("?sp") v5("?v") a1((" ")) c6(["0^^xsd:integer"]):::literal c1(["2^^xsd:integer"]):::literal c7(["wd:Q5"]):::iri c3(["wd:Q10876391"]):::iri f0[["?ct = '2^^xsd:integer'"]] f0 --> v11 f1[["not bound(?art)"]] f1 --> v2 f2[["not bound(?ref)"]] f2 --> v3 f3[["not bound(?backlink)"]] f3 --> v4 v6 --"wikibase:statements"--> c1 v6 --"wikibase:sitelinks"--> c6 v6 --"wdt:P31"--> c7 v6 --"wdt:P21"--> a1 v6 -->v7--> v8 v9 --"wikibase:claim"--> v7 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v4 -->v10--> v6 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v8 -."prov:wasDerivedFrom".-> v3 v3 -->v9--> v5 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v2 -."schema:about".-> v6 end bind5[/"count(?p)"/] v9 --o bind5 bind5 --as--o v11