query-6417b8ab3f9778ed42ac2a65912b0a80

rq turtle/ttl

Reciprocal named_after and lead_ship for ship classesI've made sure that the ship_class and the ship its named after have reciprocal named_after and subject_has_role lead_ship properties, using searches like

Use at

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 ?itemLabel ?ship ?shipLabel WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]". }
  {
    SELECT DISTINCT ?item ?namedafter ?class ?ship ?shipLabel WHERE {
      ?item wdt:P31 wd:Q559026;
      rdfs:label ?itemlabel.
      MINUS {?item wdt:P138 ?namedafter.    
      ?namedafter wdt:P289 ?class.}
      ?item wdt:P137 wd:Q172771.
      ?ship wdt:P289 ?item;
      rdfs:label ?shiplabel.
      FILTER(LANG(?shiplabel) = "en").
      FILTER (CONTAINS(?itemlabel, ?shiplabel))
    }
  }
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v5("?class") v3("?item"):::projected v1("?itemlabel") v4("?namedafter") v6("?ship"):::projected v2("?shiplabel") c2(["bd:serviceParam"]):::iri c4(["#91;AUTO_LANGUAGE#93;"]):::literal c7(["wd:Q559026"]):::iri c12(["wd:Q172771"]):::iri subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c2 --"wikibase:language"--> c4 end f0[["contains(?itemlabel,?shiplabel)"]] f0 --> v1 f0 --> v2 f1[["?shiplabel = 'en'"]] f1 --> v2 v3 --"wdt:P31"--> c7 v3 --"rdfs:label"--> v1 subgraph minus2["MINUS"] style minus2 stroke-width:6px,fill:pink,stroke:red; v3 --"wdt:P138"--> v4 v4 --"wdt:P289"--> v5 end v3 --"wdt:P137"--> c12 v6 --"wdt:P289"--> v3 v6 --"rdfs:label"--> v2