query-813350607a537c22792c153d7c152722
TODO
Use at
- https://query.wikidata.org/sparql
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT DISTINCT ?itemName ?item ?dob1 ?dod1 ?item2 ?dob2 ?dod2 ?dobdiff ?doddiff ?meandiff where {
{
select distinct ?item ?item2 ?itemName WHERE {
?item wdt:P106 ?occ .
?occ wdt:P279* wd:Q3391743 .
{ ?item rdfs:label ?itemName. } UNION { ?item skos:altLabel ?itemName. }
?item2 wdt:P106 ?occ2 .
?occ2 wdt:P279* wd:Q3391743 .
{ ?item2 rdfs:label ?itemName. } UNION { ?item2 skos:altLabel ?itemName. }
FILTER((LANG(?itemName)) = "en")
}
LIMIT 10000
} FILTER((STR(?item)) < (STR(?item2)))
MINUS { ?item wdt:P1889 ?item2. } # different from
MINUS { ?item2 wdt:P1889 ?item. }
MINUS { ?item wdt:P460 ?item2. } # said to be the same as
MINUS { ?item2 wdt:P460 ?item. }
MINUS { ?item wdt:P3373 ?item2. } # sibling
MINUS { ?item2 wdt:P3373 ?item. }
OPTIONAL { ?item wdt:P569 ?dob1. }
OPTIONAL { ?item2 wdt:P569 ?dob2. }
BIND((CEIL(ABS((?dob1 - ?dob2) / 3.652425))) / 100 AS ?dobdiff)
OPTIONAL { ?item wdt:P570 ?dod1. }
OPTIONAL { ?item2 wdt:P570 ?dod2. }
BIND((CEIL(ABS((?dod1 - ?dod2) / 3.652425))) / 100 AS ?doddiff)
BIND(BOUND(?dobdiff) AS ?dobdiffbound)
BIND(BOUND(?doddiff) AS ?doddiffbound)
BIND(IF(BOUND(?dobdiff), ?dobdiff, 0) AS ?dobdiffsafe)
BIND(IF(BOUND(?doddiff), ?doddiff, 0) AS ?doddiffsafe)
BIND((CEIL((?dobdiffsafe + ?doddiffsafe) / (xsd:integer(?dobdiffbound) + xsd:integer(?doddiffbound)) * 100) / 100) AS ?meandiff)
# SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
ORDER BY (!(?dobdiffbound) && !(?doddiffbound)) ?meandiff ?dobdiffbound ?dobdiff ?doddiffbound ?doddiff ?item
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v11("?dob1"):::projected
v12("?dob2"):::projected
v13("?dobdiff"):::projected
v15("?dobdiffbound")
v15("?dobdiffsafe")
v13("?dod1"):::projected
v14("?dod2"):::projected
v15("?doddiff"):::projected
v15("?doddiffbound")
v16("?doddiffsafe")
v6("?item"):::projected
v7("?item2"):::projected
v8("?itemName"):::projected
v17("?meandiff"):::projected
v9("?occ")
v10("?occ2")
c4(["wd:Q3391743"]):::iri
f0[["str(?item) < str(?item2)"]]
f0 --> v6
f0 --> v7
f1[["?itemName = 'en'"]]
f1 --> v8
v6 --"wdt:P106"--> v9
v9 --"wdt:P279"--> c4
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
v6 --"skos:altLabel"--> v8
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v6 --"rdfs:label"--> v8
end
union0r <== or ==> union0l
end
v7 --"wdt:P106"--> v10
v10 --"wdt:P279"--> c4
subgraph union1[" Union "]
subgraph union1l[" "]
style union1l fill:#abf,stroke-dasharray: 3 3;
v7 --"skos:altLabel"--> v8
end
subgraph union1r[" "]
style union1r fill:#abf,stroke-dasharray: 3 3;
v7 --"rdfs:label"--> v8
end
union1r <== or ==> union1l
end
subgraph minus2["MINUS"]
style minus2 stroke-width:6px,fill:pink,stroke:red;
v6 --"wdt:P1889"--> v7
end
subgraph minus3["MINUS"]
style minus3 stroke-width:6px,fill:pink,stroke:red;
v7 --"wdt:P1889"--> v6
end
subgraph minus4["MINUS"]
style minus4 stroke-width:6px,fill:pink,stroke:red;
v6 --"wdt:P460"--> v7
end
subgraph minus5["MINUS"]
style minus5 stroke-width:6px,fill:pink,stroke:red;
v7 --"wdt:P460"--> v6
end
subgraph minus6["MINUS"]
style minus6 stroke-width:6px,fill:pink,stroke:red;
v6 --"wdt:P3373"--> v7
end
subgraph minus7["MINUS"]
style minus7 stroke-width:6px,fill:pink,stroke:red;
v7 --"wdt:P3373"--> v6
end
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v6 -."wdt:P569".-> v11
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v7 -."wdt:P569".-> v12
end
bind8[/"numeric-ceil(numeric-abs(?dob1 - ?dob2 / '3.652425^^xsd:decimal')) / '100^^xsd:integer'"/]
v11 --o bind8
v12 --o bind8
bind8 --as--o v13
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v6 -."wdt:P570".-> v13
end
subgraph optional3["(optional)"]
style optional3 fill:#bbf,stroke-dasharray: 5 5;
v7 -."wdt:P570".-> v14
end
bind9[/"numeric-ceil(numeric-abs(?dod1 - ?dod2 / '3.652425^^xsd:decimal')) / '100^^xsd:integer'"/]
v13 --o bind9
v14 --o bind9
bind9 --as--o v15
bind10[/"bound(?dobdiff)"/]
v13 --o bind10
bind10 --as--o v15
bind11[/"bound(?doddiff)"/]
v15 --o bind11
bind11 --as--o v15
bind12[/"if(bound(?dobdiff),?dobdiff,'0^^xsd:integer')"/]
v13 --o bind12
bind12 --as--o v15
bind13[/"if(bound(?doddiff),?doddiff,'0^^xsd:integer')"/]
v15 --o bind13
bind13 --as--o v16
bind14[/"numeric-ceil(?dobdiffsafe + ?doddiffsafe / http://www.w3.org/2001/XMLSchema#integer(?dobdiffbound) + http://www.w3.org/2001/XMLSchema#integer(?doddiffbound) * '100^^xsd:integer') / '100^^xsd:integer'"/]
v15 --o bind14
v16 --o bind14
v15 --o bind14
v15 --o bind14
bind14 --as--o v17