query-3177ae65299bc97478417fa9ac26eb66

rq turtle/ttl

Get full name given a person For some persons, their label is not their full name, so we cannot rely on the label alone. How can you select their full name in a predictable manner?Say you have already selected a person. Examples of expected results: Donald John Trump Q22686 Esben Esther Pirelli Benestad Q3421579 Sigrid Solbakk Raabe Q28864768 Madonna Louise Veronica Ciccone Q1744 Expected full name Person Skeleton of an example query: SELECT ?person ?fullName WHERE { BIND(http://www.wikidata.org/entity/Q1744 AS ?person) ?person SOMETHING_CLEVER_HERE ?fullName . # ... } 10:14, 15 October 2020 (UTC)) talk (ThorbenDahlNrk10:30, 15 October 2020 (UTC)) talk (TagishsimonMostly, you don't. The fullname might be in the label or alias. Or it might be in P1477 birth name, or capable of being assembled from P734 family name & P735 given name & its series ordinals, or P2562 married name, or P1559 name in native language. And that's all if we ignore P2366 Roman agnomen, P2365 Roman cognomen, P2359 Roman nomen gentilicium & P2358 Roman praenomen; and P6978 Scandinavian middle family name or P1950 second family name in Spanish name. One could fish around these and assemble the longest possible namestring from the competing possibilities, but it would be v.unreliable. --

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 DISTINCT ?item ?itemLabel ?fn 
{
    ?item wdt:P39 wd:Q11696 ; wdt:P31 wd:Q5 .
    OPTIONAL { ?item wdt:P1477 ?bn }
    OPTIONAL { ?item wdt:P1448 ?on }
    OPTIONAL { ?item wdt:P1559 ?nn }
    BIND(COALESCE(?on,?bn, ?nn ) as ?fn )
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v2("?bn") v5("?fn"):::projected v1("?item"):::projected v4("?nn") v3("?on") c9(["bd:serviceParam"]):::iri c4(["wd:Q5"]):::iri c11(["#91;AUTO_LANGUAGE#93;,en"]):::literal c2(["wd:Q11696"]):::iri v1 --"wdt:P39"--> c2 v1 --"wdt:P31"--> c4 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v1 -."wdt:P1477".-> v2 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v1 -."wdt:P1448".-> v3 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v1 -."wdt:P1559".-> v4 end bind0[/"?on?bn?nn"/] v3 --o bind0 v2 --o bind0 v4 --o bind0 bind0 --as--o v5 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c9 --"wikibase:language"--> c11 end