query-772326fb31df09c9b50b93dc47e08c1a

rq turtle/ttl

Non extinct bird families we were working on the following query Llywelyn2000With } } . "en" language:wikibase serviceParam:bd { label:wikibase SERVICE } ?taxonname P225:wdt ?item { OPTIONAL } ?image P18:wdt ?item { OPTIONAL # FILTER NOT EXISTS { ?item wdt:P141 wd:Q237350 } # no impact } Q23038290:wd P31:wdt ?item { NOT EXISTS FILTER . ?instanceof P31:wdt ?item . Q35409:wd P105:wdt ?item . Q5113:wd *P171:wdt ?item { WHERE ?taxonname ?image ?instanceofLabel ?instanceof ?itemLabel ?item DISTINCT SELECT 07:36, 18 March 2017 (UTC) Jura--- ? Create a new property? Check for another P31? (P524)temporal range end How can this be improved to exclude extinct families? Should one check conservation status of all included species? Complete and check for 11:15, 18 March 2017 (UTC)) talk (Succu). --(Q237350)extinct species = (P141)IUCN conservation status I think your query gives you the desired result. There are only fossile families but no "exitinct" families. At the moment we have 154 extinct bird species (18:09, 18 March 2017 (UTC)) talk (Llywelyn2000, some of these are extinct / fossil. Can we filter those out of the equation / code, please? I understand the figure of live bird families should be c. 170. Thanks! 357 familiesThe above code gives us 04:20, 19 March 2017 (UTC)) talk (Brya1) Some of the fossil families are not marked as such, so these are not filtered out. 2) The c. 170 as the figure of live bird families will be from one particular taxonomic point of view. From a NPoV there will be a lot of families which are recognized by some taxonomists but not by others. - 06:35, 19 March 2017 (UTC)) talk (Succu recognises 240 bird families. --IOC 06:13, 19 March 2017 (UTC)) talk (Brya belongs only with those described from fossil material. Extinct is something different. - (Q23038290)fossil taxon Oh no: 06:02, 19 March 2017 (UTC)) talk (Llywelyn2000 to those which are obviously extinct, then, all is done! Many thanks to all! (Q23038290)fossil taxon Ah! Of course! I'll add

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT 
    ?fam ?famLabel ?instanceof ?instanceofLabel 
    (SAMPLE(?image) as ?image)  (SAMPLE(?taxonname) as ?taxonname)
    # (GROUP_CONCAT(DISTINCT ?species; separator="/" ) as ?allspecies)
    (GROUP_CONCAT(DISTINCT ?extinct; separator=", " ) as ?extinct_species)
    (GROUP_CONCAT(DISTINCT ?nonextinct; separator=", " ) as ?nonextinct_species)
    (GROUP_CONCAT(DISTINCT ?unknown; separator=", " ) as ?unknownstatus_species)
    (GROUP_CONCAT(DISTINCT ?taxonnamespeciesmissing; separator=" " ) as ?taxonname_species_missing)
WHERE
{
    ?item wdt:P171* wd:Q5113 .
    ?item wdt:P105 wd:Q7432 .
    ?item wdt:P171* ?fam .
    ?fam wdt:P105 wd:Q35409 .
    ?fam wdt:P31 ?instanceof . 

    # FILTER NOT EXISTS { ?fam wdt:P31 wd:Q23038290 }    # fossil taxon (family)
    # FILTER NOT EXISTS { ?item wdt:P31 wd:Q23038290 }   # fossil taxon (species)
    # FILTER NOT EXISTS { ?item wdt:P141 wd:Q237350 }

    OPTIONAL { ?fam wdt:P18 ?image } .
    OPTIONAL { ?fam wdt:P225 ?taxonname } .

    OPTIONAL { ?item wdt:P225 ?taxonnamespecies } .  
    BIND( IF(!BOUND(?taxonnamespecies), str(?item), "") as ?taxonnamespeciesmissing) # does this work?

    OPTIONAL { ?item wdt:P141 ?status }
    BIND(IF(!BOUND(?status), ?taxonnamespecies, "") as ?unknown)  
    BIND(IF(?status = wd:Q237350, ?taxonnamespecies, "") as ?extinct)  
    BIND(IF(?status != wd:Q237350, ?taxonnamespecies, "") as ?nonextinct) 
    SERVICE wikibase:label { bd:serviceParam wikibase:language "en" . }
}
GROUP BY ?fam ?famLabel ?instanceof ?instanceofLabel

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v10("?extinct"):::projected v12("?extinct_species") v2("?fam"):::projected v12("?image"):::projected v3("?instanceof"):::projected v1("?item") v11("?nonextinct"):::projected v13("?nonextinct_species") v8("?status") v12("?taxonname"):::projected v15("?taxonname_species_missing") v6("?taxonnamespecies") v7("?taxonnamespeciesmissing"):::projected v9("?unknown"):::projected v14("?unknownstatus_species") c5(["wd:Q35409"]):::iri c13(["en"]):::literal c4(["wd:Q7432"]):::iri c11(["bd:serviceParam"]):::iri c2(["wd:Q5113"]):::iri v1 --"wdt:P171"--> c2 v1 --"wdt:P105"--> c4 v1 --"wdt:P171"--> v2 v2 --"wdt:P105"--> c5 v2 --"wdt:P31"--> v3 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v2 -."wdt:P18".-> v12 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v2 -."wdt:P225".-> v12 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v1 -."wdt:P225".-> v6 end bind0[/"if(not bound(?taxonnamespecies),str(?item),'')"/] v6 --o bind0 v1 --o bind0 bind0 --as--o v7 subgraph optional3["(optional)"] style optional3 fill:#bbf,stroke-dasharray: 5 5; v1 -."wdt:P141".-> v8 end bind1[/"if(not bound(?status),?taxonnamespecies,'')"/] v8 --o bind1 v6 --o bind1 bind1 --as--o v9 bind2[/"if(?status = 'wd:Q237350',?taxonnamespecies,'')"/] v8 --o bind2 v6 --o bind2 bind2 --as--o v10 bind3[/"if(?status != 'wd:Q237350',?taxonnamespecies,'')"/] v8 --o bind3 v6 --o bind3 bind3 --as--o v11 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c11 --"wikibase:language"--> c13 end bind10[/"sample(?image)"/] v12 --o bind10 bind10 --as--o v12 bind11[/"sample(?taxonname)"/] v12 --o bind11 bind11 --as--o v12 bind12[/"?extinct"/] v10 --o bind12 bind12 --as--o v12 bind13[/"?nonextinct"/] v11 --o bind13 bind13 --as--o v13 bind14[/"?unknown"/] v9 --o bind14 bind14 --as--o v14 bind15[/"?taxonnamespeciesmissing"/] v7 --o bind15 bind15 --as--o v15