query-d1744f6941d9692c8cd1961689695b6b
TODO
Use at
- https://query.wikidata.org/sparql
PREFIX mwapi: <http://wikiba.se/ontology#>
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 ?itemlastnameLabel WHERE
{
   {
  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  
  } }  BIND (concat(?lastname," haswbstatement:P31=Q101352") as ?searchinput)
  SERVICE wikibase:mwapi {
    bd:serviceParam wikibase:api "Search";
                    wikibase:endpoint "www.wikidata.org";
                    mwapi:srsearch ?searchinput.
    ?itemlastname wikibase:apiOutputItem mwapi:title .
  }          
  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;
  v2("?date_of_birth")
  v4("?item"):::projected 
  v6("?itemlastname"):::projected 
  v3("?label_de"):::projected 
  v5("?lastname"):::projected 
  v5("?searchinput")
  a1((" "))
  c10(["de"]):::literal 
  c18(["5000^^xsd:integer"]):::literal 
  c14(["bd:serviceParam"]):::iri 
  c24(["Search"]):::literal 
  c13(["wd:Q5"]):::iri 
  c26(["www.wikidata.org"]):::literal 
  c16(["0^^xsd:integer"]):::literal 
  c29(["mwapi:title"]):::iri 
  f0[["regex(str(?lastname),'....*')"]]
  f0 --> v5
  f1[["?date_of_birth >= '1875-01-01T00:00:00Z^^xsd:dateTime'"]]
  f1 --> v2
  f2[["not regex(str(?label_de),' (von|de|le|der|die|das|dem) ')"]]
  f2 --> v3
  f3[["not regex(str(?label_de),'\.$')"]]
  f3 --> v3
  f4[["regex(str(?label_de),' ')"]]
  f4 --> v3
  f5[["not regex(str(?label_de),'\-')"]]
  f5 --> v3
  f6[["not regex(str(?label_de),'\?')"]]
  f6 --> v3
  f7[["not regex(str(?label_de),'#91;0-9#93;')"]]
  f7 --> v3
  f8[["regex(str(?label_de),'#91;^,#93;')"]]
  f8 --> v3
  f9[["?label_de = 'de'"]]
  f9 --> v3
  subgraph s1["http://www.bigdata.com/rdf#slice"]
    style s1 stroke-width:4px;
    v4 --"wdt:P31"-->  c13
    c14 --"bd:slice.offset"-->  c16
    c14 --"bd:slice.limit"-->  c18
  end
  subgraph minus10["MINUS"]
    style minus10 stroke-width:6px,fill:pink,stroke:red;
    v4 --"wdt:P734"-->  a1
  end
  v4 --"rdfs:label"-->  v3
  subgraph optional0["(optional)"]
  style optional0 fill:#bbf,stroke-dasharray: 5 5;
    v4 -."wdt:P569".->  v2
  end
  bind11[/"replace(?label_de,'^.* (#91;^\s#93;+)$','$1')"/]
  v3 --o bind11
  bind11 --as--o v5
  bind12[/"concat(?lastname,' haswbstatement:P31=Q101352')"/]
  v5 --o bind12
  bind12 --as--o v5
  subgraph s2["http://wikiba.se/ontology#mwapi"]
    style s2 stroke-width:4px;
    c14 --"mwapi:api"-->  c24
    c14 --"mwapi:endpoint"-->  c26
    c14 --"mwapi:srsearch"-->  v5
    v6 --"mwapi:apiOutputItem"-->  c29
  end
  subgraph s3["http://wikiba.se/ontology#label"]
    style s3 stroke-width:4px;
    c14 --"mwapi:language"-->  c10
  end