query-73152e795713b2b82319f603df6dc3f9

rq turtle/ttl

Propertiesinstance of (P31)family name (P734)

Use at

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#>
SELECT DISTINCT ?nameitem ?nameitem_label ?disambigitem ?disambigitem_label WHERE {
  #Family names that are just family names
  {
    SELECT DISTINCT ?nameitem ?nameitem_label (COUNT(?type) as ?nb) WHERE {
      ?nameitem wdt:P31 wd:Q101352 .
      ?nameitem wdt:P31 ?type . 
      ?nameitem rdfs:label ?nameitem_label . FILTER (LANG(?nameitem_label) = "en") .
    } GROUP BY ?nameitem ?nameitem_label HAVING (?nb = 1)
  }

  #Family names that are both family names and disambig pages
  {
    SELECT DISTINCT ?disambigitem ?disambigitem_label WHERE {
      ?disambigitem wdt:P31 wd:Q101352 .
      ?disambigitem wdt:P31 wd:Q4167410 .
      ?person wdt:P734 ?disambigitem .

      ?disambigitem rdfs:label ?disambigitem_label . FILTER (LANG(?disambigitem_label) = "en") .
    }
  }

  FILTER(?nameitem_label = ?disambigitem_label)
} LIMIT 10

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v6("?disambigitem"):::projected v2("?disambigitem_label"):::projected v4("?nameitem"):::projected v1("?nameitem_label"):::projected v6("?nb") v7("?person") v5("?type") c4(["wd:Q101352"]):::iri c6(["wd:Q4167410"]):::iri f0[["?nameitem_label = ?disambigitem_label"]] f0 --> v1 f0 --> v2 f1[["?nb = '1^^xsd:integer'"]] f1 --> v6 f2[["?nameitem_label = 'en'"]] f2 --> v1 v4 --"wdt:P31"--> c4 v4 --"wdt:P31"--> v5 v4 --"rdfs:label"--> v1 bind4[/"count(?type)"/] v5 --o bind4 bind4 --as--o v6 f5[["?disambigitem_label = 'en'"]] f5 --> v2 v6 --"wdt:P31"--> c4 v6 --"wdt:P31"--> c6 v7 --"wdt:P734"--> v6 v6 --"rdfs:label"--> v2