query-a7b6704f37aafd2e09d5738a96aaa8c6

rq turtle/ttl


Personen mit fehlenden Familiennamen (Result copy to QuickStatement)

----------------------------------------------------------

SELECT DISTINCT ?item_output2 ?property ?lastname_item_output2 ?c ?itemLabel ?lastname ?itemDescription WITH { SELECT ?lastname (SAMPLE(?item) AS ?lastname_item) { ?item wdt:P31 wd:Q101352 ; # family names wdt:P407 wd:Q188 ; # in German rdfs:label ?lastname FILTER(LANG(?lastname) = "de") } GROUP BY ?lastname HAVING(COUNT(?item) = 1) # non-ambiguous, just in case } AS %SURNAMES { hint:Query hint:optimizer "None" . # Enable top-to-bottom execution SERVICE bd:slice { ?item wdt:P31 wd:Q5 . # only human FILTER NOT EXISTS { ?item wdt:P734 [] } . # no family name bd:serviceParam bd:slice.offset 500000 . bd:serviceParam bd:slice.limit 10000 . }

?item rdfs:label ?itemLabel .
FILTER(LANG(?itemLabel) = 'de') . # german label FILTER NOT EXISTS { ?item wdt:P734 [] } . # no family name FILTER NOT EXISTS { ?item wdt:P1950 [] } . # no first family name in Portuguese name FILTER NOT EXISTS { ?item wdt:P742 [] } . # pseudonym

?item schema:description ?itemDescription . filter (lang(?itemDescription) = "de"). FILTER(REGEX(STR(?itemDescription), "deutsch|Schweizer|österreichisch")). # only German Person

FILTER(REGEX(STR(?itemLabel), "^\p{Lu}[\p{Ll}-]+( \p{Lu}[\p{Ll}-]+)+$")) . # like: Aaaa Bbbb Cccc BIND(REPLACE(?itemLabel, "^.* ([^\s]+)$", "$1") AS ?lastname) # get lastname FILTER(REGEX(STR(?lastname), "...")) . # minimum 3 letters

INCLUDE %SURNAMES # hashjoin!

# OUTPUT BIND(STR(?item) as ?item_output) . BIND(REPLACE(?item_output, "http://www.wikidata.org/entity/", "", "i") AS ?item_output2) . BIND(STR("P734") as ?property) . BIND(STR("#") as ?c) . BIND(STR(?lastname_item) as ?lastname_item_output) . BIND(REPLACE(?lastname_item_output, "http://www.wikidata.org/entity/", "", "i") AS ?lastname_item_output2) .

SERVICE wikibase:label { bd:serviceParam wikibase:language "de". }
} GROUP BY ?item_output2 ?property ?lastname_item_output2 ?c ?itemLabel ?lastname ?itemDescription order by ?lastname ?itemLabel

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX schema: <http://schema.org/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bd: <http://www.bigdata.com/rdf#>
#----------------------------------------------------------
#  Personen mit fehlenden Familiennamen (Result copy to QuickStatement)
#----------------------------------------------------------
SELECT DISTINCT ?item_output2 ?property ?lastname_item_output2 ?c ?itemLabel ?lastname ?itemDescription
{
                 # Enable top-to-bottom execution
  SERVICE bd:slice {
    ?item wdt:P31 wd:Q5 .                          # only human
    FILTER NOT EXISTS { ?item wdt:P734 [] } .      # no family name
    bd:serviceParam bd:slice.offset 500000 .
    bd:serviceParam bd:slice.limit 10000 .
  }                 

  ?item rdfs:label ?itemLabel .              
  FILTER(LANG(?itemLabel) = 'de') .                 # german label 
  FILTER NOT EXISTS { ?item wdt:P734 [] } .         # no family name
  FILTER NOT EXISTS { ?item wdt:P1950 [] } .        # no first family name in Portuguese name
  FILTER NOT EXISTS { ?item wdt:P742 [] } .         # pseudonym

  ?item schema:description ?itemDescription . 
  filter (lang(?itemDescription) = "de").
  FILTER(REGEX(STR(?itemDescription), "deutsch|Schweizer|österreichisch")).         # only German Person

  FILTER(REGEX(STR(?itemLabel), "^\\p{Lu}[\\p{Ll}-]+( \\p{Lu}[\\p{Ll}-]+)+$")) .    # like: Aaaa Bbbb Cccc 
  BIND(REPLACE(?itemLabel, "^.* ([^\\s]+)$", "$1") AS ?lastname)                    # get lastname
  FILTER(REGEX(STR(?lastname), "...")) .                                            # minimum 3 letters

   {
  SELECT ?lastname (SAMPLE(?item) AS ?lastname_item) {
    ?item wdt:P31 wd:Q101352 ;                     # family names
          wdt:P407 wd:Q188 ;                       # in German
          rdfs:label ?lastname FILTER(LANG(?lastname) = "de")
  } GROUP BY ?lastname HAVING(COUNT(?item) = 1)    # non-ambiguous, just in case
}                                                                # hashjoin!

  # OUTPUT
  BIND(STR(?item) as ?item_output) .
  BIND(REPLACE(?item_output, "http://www.wikidata.org/entity/", "", "i") AS ?item_output2) .
  BIND(STR("P734") as ?property) .
  BIND(STR("#") as ?c) .
  BIND(STR(?lastname_item) as ?lastname_item_output) .
  BIND(REPLACE(?lastname_item_output, "http://www.wikidata.org/entity/", "", "i") AS ?lastname_item_output2) .

  SERVICE wikibase:label { bd:serviceParam wikibase:language "de". }  
} GROUP BY ?item_output2 ?property ?lastname_item_output2 ?c ?itemLabel ?lastname ?itemDescription
order by ?lastname ?itemLabel

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v5("?_anon_42b5416610844a34809f33a099ae9de1147430") v10("?c"):::projected v4("?item") v3("?itemDescription"):::projected v2("?itemLabel"):::projected v7("?item_output") v8("?item_output2"):::projected v5("?lastname"):::projected v6("?lastname_item") v11("?lastname_item_output") v12("?lastname_item_output2"):::projected v9("?property"):::projected a4((" ")) a3((" ")) a2((" ")) a1((" ")) a5((" ")) c4(["de"]):::literal c19(["wd:Q101352"]):::iri c13(["500000^^xsd:integer"]):::literal c11(["bd:serviceParam"]):::iri c10(["wd:Q5"]):::iri c15(["10000^^xsd:integer"]):::literal c21(["wd:Q188"]):::iri f0[["regex(str(?lastname),'...')"]] f0 --> v5 f1[["regex(str(?itemLabel),'^\p{Lu}#91;\p{Ll}-#93;+( \p{Lu}#91;\p{Ll}-#93;+)+$')"]] f1 --> v2 f2[["regex(str(?itemDescription),'deutsch|Schweizer|österreichisch')"]] f2 --> v3 f3[["?itemDescription = 'de'"]] f3 --> v3 f4[["not "]] subgraph f4e0["Exists Clause"] e0v1 --"wdt:P742"--> e0a1 e0v1("?item"):::projected e0a1((" ")):::projected end f4--EXISTS--> f4e0 f4 --> v4 f4 --> c5 f4 --> a1 v4 --"wdt:P742"--> a1 f5[["not "]] subgraph f5e1["Exists Clause"] e1v1 --"wdt:P1950"--> e1a1 e1v1("?item"):::projected e1a1((" ")):::projected end f5--EXISTS--> f5e1 f5 --> v4 f5 --> c6 f5 --> a2 v4 --"wdt:P1950"--> a2 f6[["not "]] subgraph f6e2["Exists Clause"] e2v1 --"wdt:P734"--> e2a1 e2v1("?item"):::projected e2a1((" ")):::projected end f6--EXISTS--> f6e2 f6 --> v4 f6 --> c7 f6 --> a3 v4 --"wdt:P734"--> a3 f7[["?itemLabel = 'de'"]] f7 --> v2 subgraph s1["http://www.bigdata.com/rdf#slice"] style s1 stroke-width:4px; f8[["not "]] subgraph f8e3["Exists Clause"] e3v1 --"wdt:P734"--> e3a1 e3v1("?item"):::projected e3a1((" ")):::projected end f8--EXISTS--> f8e3 f8 --> v4 f8 --> c7 f8 --> a4 v4 --"wdt:P734"--> a4 v4 --"wdt:P31"--> c10 c11 --"bd:slice.offset"--> c13 c11 --"bd:slice.limit"--> c15 end v4 --"rdfs:label"--> v2 v4 --"schema:description"--> v3 bind9[/"replace(?itemLabel,'^.* (#91;^\s#93;+)$','$1')"/] v2 --o bind9 bind9 --as--o v5 f10[[" = '1^^xsd:integer'"]] f10 --> a5 f11[["?lastname = 'de'"]] f11 --> v5 v4 --"wdt:P31"--> c19 v4 --"wdt:P407"--> c21 v4 --"rdfs:label"--> v5 bind14[/"count(?item)"/] v4 --o bind14 bind14 --as--o v5 bind15[/"sample(?item)"/] v4 --o bind15 bind15 --as--o v6 bind16[/"str(?item)"/] v4 --o bind16 bind16 --as--o v7 bind17[/"replace(?item_output,'http://www.wikidata.org/entity/','','i')"/] v7 --o bind17 bind17 --as--o v8 bind18[/"str('P734')"/] bind18 --as--o v9 bind19[/"str('#')"/] bind19 --as--o v10 bind20[/"str(?lastname_item)"/] v6 --o bind20 bind20 --as--o v11 bind21[/"replace(?lastname_item_output,'http://www.wikidata.org/entity/','','i')"/] v11 --o bind21 bind21 --as--o v12 subgraph s2["http://wikiba.se/ontology#label"] style s2 stroke-width:4px; c11 --"wikibase:language"--> c4 end