query-088cbf5407b250855a0504e051543f08
Both querys work well. I dont know why the first is not show correct, maybe the regex is a problem. - Now I try to combine both querys (like a join). But I get a servererror.
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 rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT distinct ?item ?label_de ?lastname ?itemlastname
WHERE
{
SERVICE bd:slice {
?item wdt:P31 wd:Q5 .
bd:serviceParam bd:slice.offset 0 . # Offset
bd:serviceParam bd:slice.limit 5000 . # number of datasets to scan
}
MINUS { ?item wdt:P734 [] } . # no family name
?item rdfs:label ?label_de . # only german label
FILTER(LANG(?label_de) = 'de') .
FILTER(REGEX(STR(?label_de), "[^,]")) . # no commas "Prinzessin Elisabeth Helene, Markgrafin von Meißen"
FILTER(!REGEX(STR(?label_de), "[0-9]")) . # no number "12th Planet"
FILTER(!REGEX(STR(?label_de), "\\?")) . # no Question mark "A.geh Wirklich?"
FILTER(!REGEX(STR(?label_de), "\\-")) . # no minus "Adib asch-Schischakli"
FILTER(REGEX(STR(?label_de), " ")) . # minimum one space z.B. "Athenagoras"
FILTER(!REGEX(STR(?label_de), "\\.$")) . # no point at the end "Johann Reinhard III."
FILTER(!REGEX(STR(?label_de), " (von|de|le|der|die|das|dem) ")) . # no nobiliary particle "Anton Günther Herzog von Oldenburg"
# only since 1875
OPTIONAL { ?item wdt:P569 ?date_of_birth }. # date of birth
FILTER (?date_of_birth >= "1875-01-01T00:00:00Z"^^xsd:dateTime)
BIND(REPLACE(?label_de, "^.* ([^\\s]+)$", "$1") AS ?lastname) # get lastname
FILTER(REGEX(STR(?lastname), "....*")) . # minimum 3 letters
SERVICE bd:slice {
?itemlastname wdt:P31 wd:Q101352 .
bd:serviceParam bd:slice.offset 0 .
bd:serviceParam bd:slice.limit 1000 .
}
FILTER (?lastname = ?itemlastnameLabel) .
SERVICE wikibase:label { bd:serviceParam wikibase:language "de". }
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v3("?date_of_birth")
v5("?item"):::projected
v6("?itemlastname"):::projected
v2("?itemlastnameLabel")
v4("?label_de"):::projected
v6("?lastname"):::projected
a1((" "))
c10(["de"]):::literal
c22(["wd:Q101352"]):::iri
c18(["5000^^xsd:integer"]):::literal
c23(["1000^^xsd:integer"]):::literal
c14(["bd:serviceParam"]):::iri
c13(["wd:Q5"]):::iri
c16(["0^^xsd:integer"]):::literal
f0[["?lastname = ?itemlastnameLabel"]]
f0 --> v6
f0 --> v2
f1[["regex(str(?lastname),'....*')"]]
f1 --> v6
f2[["?date_of_birth >= '1875-01-01T00:00:00Z^^xsd:dateTime'"]]
f2 --> v3
f3[["not regex(str(?label_de),' (von|de|le|der|die|das|dem) ')"]]
f3 --> v4
f4[["not regex(str(?label_de),'\.$')"]]
f4 --> v4
f5[["regex(str(?label_de),' ')"]]
f5 --> v4
f6[["not regex(str(?label_de),'\-')"]]
f6 --> v4
f7[["not regex(str(?label_de),'\?')"]]
f7 --> v4
f8[["not regex(str(?label_de),'#91;0-9#93;')"]]
f8 --> v4
f9[["regex(str(?label_de),'#91;^,#93;')"]]
f9 --> v4
f10[["?label_de = 'de'"]]
f10 --> v4
subgraph s1["http://www.bigdata.com/rdf#slice"]
style s1 stroke-width:4px;
v5 --"wdt:P31"--> c13
c14 --"bd:slice.offset"--> c16
c14 --"bd:slice.limit"--> c18
end
subgraph minus11["MINUS"]
style minus11 stroke-width:6px,fill:pink,stroke:red;
v5 --"wdt:P734"--> a1
end
v5 --"rdfs:label"--> v4
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v5 -."wdt:P569".-> v3
end
bind12[/"replace(?label_de,'^.* (#91;^\s#93;+)$','$1')"/]
v4 --o bind12
bind12 --as--o v6
subgraph s1["http://www.bigdata.com/rdf#slice"]
style s1 stroke-width:4px;
v6 --"wdt:P31"--> c22
c14 --"bd:slice.offset"--> c16
c14 --"bd:slice.limit"--> c23
end
subgraph s2["http://wikiba.se/ontology#label"]
style s2 stroke-width:4px;
c14 --"wikibase:language"--> c10
end