Project:SPARQL/examples: Difference between revisions

Line 836: Line 836:
ORDER BY ?person ?date
ORDER BY ?person ?date


</sparql>
=== Where did women who published in Folklore/Folk-lore Record live? ===
<sparql tryit="1">
# Map of all places of residence for women who had publications in Folklore/Folk-lore Record
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwds: <https://beyond-notability.wikibase.cloud/entity/statement/>
PREFIX bnwdv: <https://beyond-notability.wikibase.cloud/value/>
PREFIX bnwdt: <https://beyond-notability.wikibase.cloud/prop/direct/>
PREFIX bnp: <https://beyond-notability.wikibase.cloud/prop/>
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
#defaultView:Map{"hide":["?geo", "?count"]}
SELECT  ?person ?personLabel ?residenceLabel ?residence ?geo (count( ?person) as ?count)  (concat(str(?count), " publication") as ?count_lbl)
WHERE { 
  ?person bnwdt:P3 bnwd:Q3 . # select women
  FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
  ?person bnwdt:P76 bnwd:Q419 . # people with publications listed in indexes of archaeological papers. [262]
  ?person bnp:P76 ?s . 
 
  ## works published in P101. folklore / folk-lore record q487 q490
      ?s bnpq:P101 ?in .
      {?s bnpq:P101 bnwd:Q487 } union { ?s bnpq:P101 bnwd:Q490 . }
      # why does above pick up these two journals as well?
      FILTER ( ?in not in ( bnwd:Q665 , bnwd:Q636 ) ) .
 
  ?person bnwdt:P29  ?residence .
 
  optional {
   
      ?residence bnp:P117 ?ws .  # wikidata id P117
           
        ?ws bnpq:P14 ?wikidata_url .
        BIND(IRI(REPLACE(?wikidata_url, "https://www.wikidata.org/wiki/", "http://www.wikidata.org/entity/")) as ?wikidata )
 
      SERVICE <https://query.wikidata.org/sparql> {
   
      optional {?wikidata wdt:P625 ?geo1 .  } # geocoords if available
      optional {?wikidata wdt:P131 ?terr . # admin territory of place if available
                    ?terr wdt:P625 ?terr_geo . # get geo for the admin territory to use as a fallback
                    filter exists { ?wikidata wdt:P131 wd:Q84 . } # (only applies to the London postal areas at the moment)
                }
      BIND(IF(BOUND(?geo1),?geo1,?terr_geo) AS ?geo) .  # if geo1 available, use that, if not use terr_geo
    } # /wikidata service 
    } #/wikidata optional
 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }
}
group by ?person ?personLabel ?residenceLabel ?residence ?geo
ORDER BY ?geo
</sparql>
</sparql>


586

edits