Querying: Difference between revisions

m
 
(7 intermediate revisions by the same user not shown)
Line 162: Line 162:
   #enter same year twice
   #enter same year twice
   FILTER(YEAR(?starttime) <= 1700 && YEAR(?endtime) > 1700)
   FILTER(YEAR(?starttime) <= 1700 && YEAR(?endtime) > 1700)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
}
=== Map of nahiye seats, colored by vilayet, in 1900 ===
This is a variation on the sancak seat map on the main page. [http://tinyurl.com/2ae3rfxb run]
SELECT ?vilayet3Label ?nahiyeSeat_ota ?nahiyeSeat ?nahiyeCoord ?nahiyeSeatLabel
WHERE
{   
  # nahiye
  ?nahiye ogp:P15 ?statement4.
  ?statement4 ogps:P15 og:Q2.
  ?statement4 ogpq:P7 ?starttime4.
  ?statement4 ogpq:P34 ?kaza2.
  ?nahiye ogt:P14 ?nahiyeSeat.
  ?nahiyeSeat ogt:P10 ?nahiyeCoord.
  OPTIONAL{?statement4 ogpq:P8 ?endtime4.}
  OPTIONAL{?statement4 ogpq:P22 ?endtime4.}
           
  # find sanckas for kazas
  ?kaza2 ogp:P15 ?statement5.
  ?statement5 ogps:P15 og:Q3.
  ?statement5 ogpq:P7 ?starttime5.
  ?statement5 ogpq:P34 ?sancak3.
  OPTIONAL{?statement5 ogpq:P8 ?endtime5.}
  OPTIONAL{?statement5 ogpq:P22 ?endtime5.}
             
  # find vilayets for kazas
  ?sancak3 ogp:P15 ?statement6.
  ?statement6 ogps:P15 og:Q4.
  ?statement6 ogpq:P7 ?starttime6.
  ?statement6 ogpq:P34 ?vilayet3.
  OPTIONAL{?statement6 ogpq:P8 ?endtime6.}
  OPTIONAL{?statement6 ogpq:P22 ?endtime6.}
 
  # get ottoman label
  ?nahiyeSeat rdfs:label ?nahiyeSeat_ota filter (lang(?nahiyeSeat_ota) = "ota")
           
  #enter same year twice
  FILTER(YEAR(?starttime4) <= 1900 && YEAR(?endtime4) > 1900)
  FILTER(YEAR(?starttime5) <= 1900 && YEAR(?endtime5) > 1900)
  FILTER(YEAR(?starttime6) <= 1900 && YEAR(?endtime6) > 1900)
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
  }
  }


== Federated query with Wikidata ==
== Federated query with Wikidata ==
=== Wikidata version of vilayet from Ottgaz sancaks ===


For every sanjak in Ottgaz, this query fetches the vilayet or eyalet to which Wikidata says it belongs. Thanks to Lucas Werkmeister for help. [https://tinyurl.com/2eokop65 run]
For every sanjak in Ottgaz, this query fetches the vilayet or eyalet to which Wikidata says it belongs. Thanks to Lucas Werkmeister for help. [https://tinyurl.com/2eokop65 run]
Line 193: Line 237:


=== Fetch missing geocoordinates from Wikidata ===
=== Fetch missing geocoordinates from Wikidata ===
This query is not working yet.  
This query for some reason won't supply a shortlink. Model for fetching information from Wikidata. Thanks for help from Wikibase telegram group users Tuukka Hastrup and Nikki. Note the crucial and mysterious `hint:Query hint:optimizer "None" .` [https://ottgaz.org/query/#%23Seat%20with%20Wikidata%20Qids%20but%20without%20geolocation%0APREFIX%20og%3A%20%3Chttps%3A%2F%2Fottgaz.org%2Fentity%2F%3E%0APREFIX%20ogs%3A%20%3Chttps%3A%2F%2Fottgaz.org%2Fentity%2Fstatement%2F%3E%0APREFIX%20ogv%3A%20%3Chttps%3A%2F%2Fottgaz.org%2Fvalue%2F%3E%0APREFIX%20ogt%3A%20%3Chttps%3A%2F%2Fottgaz.org%2Fprop%2Fdirect%2F%3E%0APREFIX%20ogp%3A%20%3Chttps%3A%2F%2Fottgaz.org%2Fprop%2F%3E%0APREFIX%20ogps%3A%20%3Chttps%3A%2F%2Fottgaz.org%2Fprop%2Fstatement%2F%3E%0APREFIX%20ogpq%3A%20%3Chttps%3A%2F%2Fottgaz.org%2Fprop%2Fqualifier%2F%3E%0APREFIX%20wd%3A%20%3Chttp%3A%2F%2Fwww.wikidata.org%2Fentity%2F%3E%0APREFIX%20wdt%3A%20%3Chttp%3A%2F%2Fwww.wikidata.org%2Fprop%2Fdirect%2F%3E%0ASELECT%20%20%3Fseat%20%3FseatLabel%20%3FwdURL%20%3Fcoords%0AWHERE%20%0A%7B%0A%20VALUES%20%3Fcenter%20%7Bog%3AQ287%20og%3AQ497%20og%3AQ6421%7D%0A%20%3Fseat%20ogt%3AP6%20%3Fcenter.%0A%20%3Fseat%20ogt%3AP3%20%3FwdQid.%0A%20MINUS%20%7B%3Fseat%20ogt%3AP10%20%3Fgeo.%7D%0A%20BIND%20%28URI%28CONCAT%28%22http%3A%2F%2Fwww.wikidata.org%2Fentity%2F%22%2C%0A%20ENCODE_FOR_URI%28%3FwdQid%29%29%29%20as%20%3FwdURL%29.%0A%20hint%3AQuery%20hint%3Aoptimizer%20%22None%22%20.%0A%20SERVICE%20%3Chttps%3A%2F%2Fquery.wikidata.org%2Fsparql%3E%20%7B%0A%20%20%20SELECT%20%3FwdURL%20%3Fcoords%20%7B%0A%20%20%20%3FwdURL%20wdt%3AP625%20%3Fcoords%20.%0A%20%20%20%7D%0A%20%7D%0A%20SERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22%5BAUTO_LANGUAGE%5D%2Cen%22%20%7D%0A%7D run]


  #Seat with Wikidata Qids but without geolocation
  #Seat with Wikidata Qids but without geolocation
Line 212: Line 256:
   ?seat ogt:P3 ?wdQid.
   ?seat ogt:P3 ?wdQid.
   MINUS {?seat ogt:P10 ?geo.}
   MINUS {?seat ogt:P10 ?geo.}
   BIND (URI(CONCAT("https://www.wikidata.org/wiki/",
   BIND (URI(CONCAT("http://www.wikidata.org/entity/",
   ENCODE_FOR_URI(?wdQid))) as ?wdURL).
   ENCODE_FOR_URI(?wdQid))) as ?wdURL).
  hint:Query hint:optimizer "None" .
   SERVICE <https://query.wikidata.org/sparql> {
   SERVICE <https://query.wikidata.org/sparql> {
     SELECT ?wdURL ?coords {
     SELECT ?wdURL ?coords {