query-2457df4c6252db0d56b5d59bc2f72a6c

rq turtle/ttl

Redundant classifications SELECT DISTINCT ?item ?label ?class_a ?label_a ?class_b ?label_b WHERE { # Working set: american ships ?item wdt:P31/wdt:P279* wd:Q11446; wdt:P8047 wd:Q30. # Rest of query ?item wdt:P31 ?class_a; wdt:P31 ?class_b. ?class_a wdt:P279+ ?class_b. # Labels ?item rdfs:label ?label_nb. FILTER(LANG(?label_nb) = "nb") ?item rdfs:label ?label_en. FILTER(LANG(?label_en) = "en") BIND(COALESCE(?label_nb, ?label_en) AS ?label) ?class_a rdfs:label ?label_a_nb. FILTER(LANG(?label_a_nb) = "nb") ?class_a rdfs:label ?label_a_en. FILTER(LANG(?label_a_en) = "en") BIND(COALESCE(?label_a_nb, ?label_a_en) AS ?label_a) ?class_b rdfs:label ?label_b_nb. FILTER(LANG(?label_b_nb) = "nb") ?class_b rdfs:label ?label_b_en. FILTER(LANG(?label_b_en) = "en") BIND(COALESCE(?label_b_nb, ?label_b_en) AS ?label_b) }

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#>
# Redundant classifications
SELECT DISTINCT ?item ?label ?class_a ?label_a ?class_b ?label_b
WHERE {
  # Working set: american ships
  ?item wdt:P31/wdt:P279* wd:Q11446;
    wdt:P8047 wd:Q30.
  # Rest of query
  ?item wdt:P31 ?class_a;
    wdt:P31 ?class_b.
  ?class_a wdt:P279+ ?class_b.
  # Labels
  ?item rdfs:label ?label_nb. FILTER(LANG(?label_nb) = "nb")
  ?item rdfs:label ?label_en. FILTER(LANG(?label_en) = "en")
  BIND(COALESCE(?label_nb, ?label_en) AS ?label)
  ?class_a rdfs:label ?label_a_nb. FILTER(LANG(?label_a_nb) = "nb")
  ?class_a rdfs:label ?label_a_en. FILTER(LANG(?label_a_en) = "en")
  BIND(COALESCE(?label_a_nb, ?label_a_en) AS ?label_a)
  ?class_b rdfs:label ?label_b_nb. FILTER(LANG(?label_b_nb) = "nb")
  ?class_b rdfs:label ?label_b_en. FILTER(LANG(?label_b_en) = "en")
  BIND(COALESCE(?label_b_nb, ?label_b_en) AS ?label_b)
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v8("?class_a"):::projected v9("?class_b"):::projected v7("?item"):::projected v10("?label"):::projected v11("?label_a"):::projected v3("?label_a_en") v4("?label_a_nb") v12("?label_b"):::projected v1("?label_b_en") v2("?label_b_nb") v5("?label_en") v6("?label_nb") a1((" ")) c7(["wd:Q30"]):::iri c5(["wd:Q11446"]):::iri f0[["?label_b_en = 'en'"]] f0 --> v1 f1[["?label_b_nb = 'nb'"]] f1 --> v2 f2[["?label_a_en = 'en'"]] f2 --> v3 f3[["?label_a_nb = 'nb'"]] f3 --> v4 f4[["?label_en = 'en'"]] f4 --> v5 f5[["?label_nb = 'nb'"]] f5 --> v6 v7 --"wdt:P31"--> a1 a1 --"wdt:P279"--> c5 v7 --"wdt:P8047"--> c7 v7 --"wdt:P31"--> v8 v7 --"wdt:P31"--> v9 v8 --"wdt:P279"--> v9 v7 --"rdfs:label"--> v6 v7 --"rdfs:label"--> v5 bind6[/"?label_nb?label_en"/] v6 --o bind6 v5 --o bind6 bind6 --as--o v10 v8 --"rdfs:label"--> v4 v8 --"rdfs:label"--> v3 bind7[/"?label_a_nb?label_a_en"/] v4 --o bind7 v3 --o bind7 bind7 --as--o v11 v9 --"rdfs:label"--> v2 v9 --"rdfs:label"--> v1 bind8[/"?label_b_nb?label_b_en"/] v2 --o bind8 v1 --o bind8 bind8 --as--o v12