query-85c78ada03ea087a3523cfa1d3558172

rq turtle/ttl

TODO

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#>
#villages with tewiki or enwiki articles but without wikidata in OSM in a specific district
# when updating district, be sure to update the same value in subquery (Minus) section
#defaultView:Map
SELECT DISTINCT ?2011censuscode ?wd_label_village ?wd_label_village_te  ?wd_qid_village ?wd_loc_village ?wd_label_mandal ?wd_qid_mandal WHERE {

  wd:Q110876712 wdt:P150 ?mandal.  
  ?village wdt:P131 ?mandal; 
    (wdt:P31/(wdt:P279*)) wd:Q56436498;
    wdt:P625 ?wd_loc_village.

  MINUS {
  wd:Q110876712 wdt:P150 ?mandal.  
  ?village wdt:P131 ?mandal; 
      (wdt:P31/(wdt:P279*)) wd:Q56436498;
      wdt:P625 [].
    SERVICE <https://sophox.org/sparql> {
      ?osmid <https://wiki.openstreetmap.org/wiki/Key:wikidata> ?village;
        <https://www.openstreetmap.org/meta/loc> ?osmloc.
    }
  }
  ?village    wdt:P131 ?wd_mandal.
  OPTIONAL {
  ?village  wdt:P5578 ?2011censuscode.
  }
  SERVICE wikibase:label {
    bd:serviceParam wikibase:language "en".
    ?village rdfs:label ?wd_label_village.
    ?wd_mandal rdfs:label ?wd_label_mandal.
  }
  OPTIONAL {
    ?village rdfs:label ?wd_label_village_te FILTER(LANG(?wd_label_village_te)="te").
  }  
  OPTIONAL {
    ?article schema:about ?village;
      schema:isPartOf <https://te.wikipedia.org/>;
      schema:name ?page_titleTE.
  }
  OPTIONAL {
    ?article schema:about ?village;
      schema:isPartOf <https://en.wikipedia.org/>;
      schema:name ?page_titleEN.
  }
  FILTER((BOUND(?page_titleEN))|| (BOUND(?page_titleTE)))
  BIND(REPLACE(STR(?village), "^.*/([^/]*)$", "$1") AS ?wd_qid_village)
  BIND(REPLACE(STR(?wd_mandal), "^.*/([^/]*)$", "$1") AS ?wd_qid_mandal)   
}
ORDER BY ?2011censuscode ?wd_label_mandal ?wd_label_village

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v1("?2011censuscode"):::projected v13("?article") v7("?mandal") v10("?osmid") v11("?osmloc") v4("?page_titleEN") v5("?page_titleTE") v8("?village") v2("?wd_label_mandal"):::projected v3("?wd_label_village"):::projected v6("?wd_label_village_te"):::projected v9("?wd_loc_village"):::projected v12("?wd_mandal") v15("?wd_qid_mandal"):::projected v14("?wd_qid_village"):::projected a3((" ")) a1((" ")) a2((" ")) c2(["wd:Q110876712"]):::iri c16(["en"]):::literal c20([https://te.wikipedia.org/]):::iri c22([https://en.wikipedia.org/]):::iri c14(["bd:serviceParam"]):::iri c7(["wd:Q56436498"]):::iri f0[["(bound(?page_titleEN) || bound(?page_titleTE))"]] f0 --> v4 f0 --> v5 c2 --"wdt:P150"--> v7 v8 --"wdt:P131"--> v7 v8 --"wdt:P31"--> a1 a1 --"wdt:P279"--> c7 v8 --"wdt:P625"--> v9 subgraph minus1["MINUS"] style minus1 stroke-width:6px,fill:pink,stroke:red; c2 --"wdt:P150"--> v7 v8 --"wdt:P131"--> v7 v8 --"wdt:P31"--> a2 a2 --"wdt:P279"--> c7 v8 --"wdt:P625"--> a3 subgraph s1["https://sophox.org/sparql"] style s1 stroke-width:4px; v10 --https://wiki.openstreetmap.org/wiki/Key:wikidata--> v8 v10 --https://www.openstreetmap.org/meta/loc--> v11 end end v8 --"wdt:P131"--> v12 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v8 -."wdt:P5578".-> v1 end subgraph s2["http://wikiba.se/ontology#label"] style s2 stroke-width:4px; c14 --"wikibase:language"--> c16 v8 --"rdfs:label"--> v3 v12 --"rdfs:label"--> v2 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v8 -."rdfs:label".-> v6 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v13 -."schema:about".-> v8 v13 --"schema:isPartOf"--> c20 v13 --"schema:name"--> v5 end subgraph optional3["(optional)"] style optional3 fill:#bbf,stroke-dasharray: 5 5; v13 -."schema:about".-> v8 v13 --"schema:isPartOf"--> c22 v13 --"schema:name"--> v4 end bind2[/"replace(str(?village),'^.*/(#91;^/#93;*)$','$1')"/] v8 --o bind2 bind2 --as--o v14 bind3[/"replace(str(?wd_mandal),'^.*/(#91;^/#93;*)$','$1')"/] v12 --o bind3 bind3 --as--o v15