query-9b332e260460ddf5c1af641821ede4f0

rq turtle/ttl

TODO

Use at

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#>
SELECT ?item ?name ?en_a ?en_t ?fr_a ?fr_t WHERE {
  ?item wdt:P5008 wd:Q85931561.

  FILTER NOT EXISTS { ?article_nl schema:about ?item ;
                                  schema:isPartOf <https://nl.wikipedia.org/>. }

  OPTIONAL {  
  ?article_en schema:about ?item ;
              schema:isPartOf <https://en.wikipedia.org/> ;
              schema:name ?sitelink_en.
  OPTIONAL { ?item rdfs:label ?itemLabel_nl . FILTER(lang(?itemLabel_nl)='nl') }
  BIND(COALESCE(?itemLabel_nl,?sitelink_en) as ?target_en_nl)  
  BIND(CONCAT("[https://nl.wikipedia.org/wiki/Special:ContentTranslation?title=Special:ContentTranslation&page=", 
              ENCODE_FOR_URI(?sitelink_en), "&from=nl&to=pap&targettitle=", ENCODE_FOR_URI(?target_en_nl), 
              " T]") AS ?en_t)
  BIND(CONCAT("[",STR(?article_en)," A]") as ?en_a)
  }

  OPTIONAL {  
  ?article_fr schema:about ?item ;
              schema:isPartOf <https://fr.wikipedia.org/> ;
              schema:name ?sitelink_fr .
  OPTIONAL { ?item rdfs:label ?itemLabel_nl . FILTER(lang(?itemLabel_nl)='nl') }
  BIND(COALESCE(?itemLabel_nl,?sitelink_fr) as ?target_fr_nl)  
  BIND(CONCAT("[https://nl.wikipedia.org/wiki/Special:ContentTranslation?title=Special:ContentTranslation&page=", 
              ENCODE_FOR_URI(?sitelink_fr), "&from=nl&to=pap&targettitle=", ENCODE_FOR_URI(?target_fr_nl), 
              " T]") AS ?fr_t)
   BIND(CONCAT("[",STR(?article_fr)," A]") as ?fr_a)
  }

  BIND(COALESCE(?itemLabel_nl, ?sitelink_en, ?sitelink_fr) as ?name) # name for this row in the table
  BIND(COALESCE(?article_en,?article_fr) as ?test) # check there is an article to translate from
  FILTER(BOUND(?test))                             # if ?test is null, there is not, so no row.
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v5("?article_en") v10("?article_fr") v2("?article_nl") v9("?en_a"):::projected v8("?en_t"):::projected v14("?fr_a"):::projected v13("?fr_t"):::projected v3("?item"):::projected v4("?itemLabel_nl") v15("?name"):::projected v6("?sitelink_en") v11("?sitelink_fr") v7("?target_en_nl") v12("?target_fr_nl") v16("?test") c7([https://en.wikipedia.org/]):::iri c5(["wd:Q85931561"]):::iri c10([https://fr.wikipedia.org/]):::iri c3([https://nl.wikipedia.org/]):::iri f0[["bound(?test)"]] f0 --> v16 f1[["not "]] subgraph f1e0["Exists Clause"] e0v1 --"schema:about"--> e0v2 e0v1 --"schema:isPartOf"--> e0c3 e0v1("?article_nl"):::projected e0v2("?item"):::projected e0c3([https://nl.wikipedia.org/]):::iri end f1--EXISTS--> f1e0 f1 --> v2 f1 --> c1 f1 --> v3 f1 --> c2 f1 --> c3 v2 --"schema:about"--> v3 v2 --"schema:isPartOf"--> c3 v3 --"wdt:P5008"--> c5 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v5 -."schema:about".-> v3 v5 --"schema:isPartOf"--> c7 v5 --"schema:name"--> v6 subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v3 -."rdfs:label".-> v4 end bind2[/"?itemLabel_nl?sitelink_en"/] v4 --o bind2 v6 --o bind2 bind2 --as--o v7 bind3[/"concat('#91;https://nl.wikipedia.org/wiki/Special:ContentTranslation?title=Special:ContentTranslation&page=',encode-for-uri(?sitelink_en),'&from=nl&to=pap&targettitle=',encode-for-uri(?target_en_nl),' T#93;')"/] v6 --o bind3 v7 --o bind3 bind3 --as--o v8 bind4[/"concat('#91;',str(?article_en),' A#93;')"/] v5 --o bind4 bind4 --as--o v9 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v10 -."schema:about".-> v3 v10 --"schema:isPartOf"--> c10 v10 --"schema:name"--> v11 subgraph optional3["(optional)"] style optional3 fill:#bbf,stroke-dasharray: 5 5; v3 -."rdfs:label".-> v4 end bind5[/"?itemLabel_nl?sitelink_fr"/] v4 --o bind5 v11 --o bind5 bind5 --as--o v12 bind6[/"concat('#91;https://nl.wikipedia.org/wiki/Special:ContentTranslation?title=Special:ContentTranslation&page=',encode-for-uri(?sitelink_fr),'&from=nl&to=pap&targettitle=',encode-for-uri(?target_fr_nl),' T#93;')"/] v11 --o bind6 v12 --o bind6 bind6 --as--o v13 bind7[/"concat('#91;',str(?article_fr),' A#93;')"/] v10 --o bind7 bind7 --as--o v14 end bind8[/"?itemLabel_nl?sitelink_en?sitelink_fr"/] v4 --o bind8 v6 --o bind8 v11 --o bind8 bind8 --as--o v15 bind9[/"?article_en?article_fr"/] v5 --o bind9 v10 --o bind9 bind9 --as--o v16