Wikidata:WikiProject Scotland's Accused Witches/Queries

From Wikidata
Jump to navigation Jump to search

List of accused witches and gender if known

[edit]

The query displays all items whose value of instance of (P31) is human (Q5) and any Survey of Scottish Witchcraft - Accused witch ID (P4478) with sex or gender (P21). The results are displayed as a list.

#added 2023-06
# gender of accused witches in Scotland
SELECT ?item ?itemLabel ?genderLabel
WHERE 
{
  ?item wdt:P31 wd:Q5. # Must be of a human
  ?item wdt:P4478 ?survey . # must be in the Survey of Scottish witchcraft
  OPTIONAL
  {
  ?item wdt:P21 ?gender . # may or may not have a known gender
    }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } # Helps get the label in your language, if not, then en language
}
Try it!

Map of accused witches in Scotland colour coded by gender

[edit]

The query displays all items with a Survey of Scottish Witchcraft - Accused witch ID (P4478) and sex or gender (P21) and a place of residence (P551) has a coordinate location (P625). The results are displayed as a map with a colour coded layer for the gender split.

#added 2023-06
#Map of places of residence of accused witches.
#defaultView:Map
#You need to use the name ?layer as the variable you are colour coding by 
#It's much easier to change later if you do this in the SELECT area, using e.g. (?Gender as ?layer)
SELECT ?person ?personLabel ?accusedwitch ?precision ?coords ?Occupation ?Residence ?image (?Gender as ?layer) 
WHERE {
  ?person wdt:P4478 ?accusedwitch .
  ?person wdt:P31 wd:Q5.
  ?person wdt:P21 ?gender .
  ?person wdt:P551 ?residence .
  ?residence wdt:P625 ?coords.
  OPTIONAL { ?article schema:about ?person. }
  SERVICE wikibase:label {
    bd:serviceParam wikibase:language "en".
    ?person rdfs:label ?personLabel.
    ?residence rdfs:label ?Residence .
    ?occupation rdfs:label ?Occupation.
    ?gender rdfs:label ?Gender.
  }
}
Try it!

Map of accused witches in Scotland accused of shapeshifting

[edit]

The query displays all items with a Survey of Scottish Witchcraft - Accused witch ID (P4478) and sex or gender (P21) and a place of residence (P551) has a coordinate location (P625) but combined with a charge (P1595) of shapeshifting (Q30172593) where there is a qualifier statement of appears in the form of (P4675). The results are displayed as a map with a colour coded layer for the what they were accused of shapeshifting into.

#added 2023-06
#Accused witches in Scotland accused of shapeshifting
#defaultView:Map
#You need to use the name ?layer as the variable you are colour coding by 
#It's much easier to change later if you do this in the SELECT area, using e.g. (?Appears as ?layer)
SELECT DISTINCT ?item ?itemLabel ?accusedurl ?chargeLabel ?residenceLabel ?coords ?image (?Appears as ?layer) 
WHERE 
{
  ?item wdt:P31 wd:Q5.
  ?item wdt:P4478 ?accused .
  wd:P4478 wdt:P1630 ?formatterurl .
   BIND(IRI(REPLACE(?accused, '^(.+)$', ?formatterurl)) AS ?accusedurl).

  ?item wdt:P1595 wd:Q30172593   . 
  ?item wdt:P551 ?residence .
  ?residence wdt:P625 ?coords.
   {?item p:P1595 ?ChargeStatement . 
              ?ChargeStatement ps:P1595 ?charge ; 
                 pq:P4675 ?appears .
            OPTIONAL { ?appears wdt:P18 ?image }  #end time qualifier value .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".  
                          ?appears rdfs:label ?Appears .
                          ?charge rdfs:label ?chargeLabel .
                          ?residence rdfs:label ?residenceLabel .
                          ?item rdfs:label ?itemLabel .
                          ?accused rdfs:label ?accusedLabel .}
}
}
Try it!