Wikidata:WikiProject British Politicians/ambassadors

From Wikidata
Jump to navigation Jump to search

A spin-off of the British MPs project looking at ambassadors (part of the FCOhack event in September 2018, London. The Winning hack!). Hopefully we can tie the two sets of records together!

Data model[edit]

The best way to handle ambassadorial posts is as positions (rather than eg occupations or fields of work).

Items on ambassadors should be structured like:

Potential qualifiers for future work:

Process[edit]

The maintenance scripts are here, and synchronisation is done against the mix-and-match catalogue.

Queries[edit]

For examples of what can potentially be done, see the sample queries for MPs. Can we make these work with ambassadors?

Individual ambassadors/High Commissioners, their posts, and dates
# Wikidata entries for British ambassadors and high commissioners
# all people who held at least one such position
# one line per position held (so many people appear repeatedly)
# start/end dates for that particular position

select ?person ?personLabel ?positionLabel ?startyear ?endyear where
{
  { ?position wdt:P31 wd:Q18115939 . } union { ?position wdt:P31 wd:Q56760832 } . # position is UK ambassador or high commissioner
    ?person p:P39 ?positionStatement . ?positionStatement ps:P39 ?position . # find positions they held
    optional { ?positionStatement pq:P580 ?start . bind(year(?start) as ?startyear) } # id start year
    optional { ?positionStatement pq:P582 ?end . bind(year(?end) as ?endyear) } # id end year
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

Try it!

All ambssadors to Argentina only
# ambassadors to Argentina

select ?person ?personLabel ?startyear ?endyear where
{
  ?person p:P39 ?positionStatement . ?positionStatement ps:P39 wd:Q29898729 . # held position of Ambassador to Argentina
 
  optional { ?positionStatement pq:P580 ?start . bind(year(?start) as ?startyear) } # id start year
  optional { ?positionStatement pq:P582 ?end . bind(year(?end) as ?endyear) } # id end year
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

Try it!

Ambassadors who were also MPs
# Ambassadors who were also MPs

select distinct ?person ?personLabel ?birthyear ?deathyear where
{
  ?person p:P39 ?positionStatement . ?positionStatement ps:P39 ?position .
  { ?position wdt:P31 wd:Q18115939 . } union { ?position wdt:P31 wd:Q56760832 } . 
  # person held a position as UK Ambassador or UK High Commissioner
  ?person p:P39 ?positionStatement2 . ?positionStatement2 ps:P39 ?position2 . 
  { ?position2 wdt:P279* wd:Q16707842 . } union { ?position wdt:P279* wd:Q18015642 }  union { ?position wdt:P279* wd:Q18018860 }
  # person held a position as a UK, GB, or English MP (breakpoints at 1707 and 1801)
  optional { ?person wdt:P569 ?born . bind(year(?born) as ?birthyear) } .
  optional { ?person wdt:P570 ?died . bind(year(?died) as ?deathyear) } .
  
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

Try it!

Places ambassadors died
# places Ambassadors died

select ?person ?personLabel ?coordinates where
{
  ?person p:P39 ?positionStatement . ?positionStatement ps:P39 ?position. 
  { ?position wdt:P31 wd:Q18115939 . } union { ?position wdt:P31 wd:Q56760832 } 
  ?person wdt:P20 ?died. ?died wdt:P625 ?coordinates .
  
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
#defaultView:Map

Try it!

Birthplaces of ambassadors to Argentina
# birthplaces of ambassadors to Argentina

select ?person ?personLabel ?coordinates where
{
  ?person p:P39 ?positionStatement . ?positionStatement ps:P39 wd:Q29898729 . # held position of Ambassador to Argentina
  ?person wdt:P19 ?born. ?born wdt:P625 ?coordinates .
  
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
#defaultView:Map

Try it!

Grand display
# Wikidata entries for British ambassadors and high commissioners
# all people who held at least one such position
# one line per position held (so many people appear repeatedly)
# start/end dates for that particular position

select distinct ?person ?personLabel ?positionLabel ?startyear ?endyear ?birthyear ?deathyear ?image ?otherpositionLabel ?otherstartyear ?otherendyear where
{
  { ?position wdt:P31 wd:Q18115939 . } union { ?position wdt:P31 wd:Q56760832 } . # position is UK ambassador or high commissioner
    
    ?person p:P39 ?positionStatement . ?positionStatement ps:P39 ?position . # find positions they held
  { ?person wdt:P18 ?image . } .  
    optional { ?positionStatement pq:P580 ?start . bind(year(?start) as ?startyear) } # id start year
    optional { ?positionStatement pq:P582 ?end . bind(year(?end) as ?endyear) } # id end year
    optional { ?person wdt:P569 ?born . bind(year(?born) as ?birthyear) } # id start year
    optional { ?person wdt:P570 ?died . bind(year(?died) as ?deathyear) } # id end year
    optional { ?person p:P39 ?otherpositionStatement . ?otherpositionStatement ps:P39 ?otherposition . 
              filter not exists { ?otherposition wdt:P31 wd:Q18115939 . } 
              filter not exists { ?otherposition wdt:P31 wd:Q56760832 . } 
              filter not exists { ?otherpositionStatement ps:P39 wd:Q121998 . }
              optional { ?otherpositionStatement pq:P580 ?otherstart . bind(year(?otherstart) as ?otherstartyear) }
              optional { ?otherpositionStatement pq:P580 ?otherend . bind(year(?otherend) as ?otherendyear) }
             }

  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

Try it!

Ambassadors who died in the same year they left office
select distinct ?person ?personLabel ?positionLabel ?startyear ?endyear ?birthyear ?deathyear
where
{
  { ?position wdt:P31 wd:Q18115939 . } union { ?position wdt:P31 wd:Q56760832 } . # position is UK ambassador or high commissioner
    
    ?person p:P39 ?positionStatement . ?positionStatement ps:P39 ?position . # find positions they held

    optional { ?positionStatement pq:P580 ?start . bind(year(?start) as ?startyear) } # id start year
    optional { ?positionStatement pq:P582 ?end . bind(year(?end) as ?endyear) } # id end year
    optional { ?person wdt:P569 ?born . bind(year(?born) as ?birthyear) } # id start year
    optional { ?person wdt:P570 ?died . bind(year(?died) as ?deathyear) } # id end year
  filter (?deathyear = ?endyear )

  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

Try it!

Ambassadors descended from William the Conqueror
# Ambassadors descended from William I 
SELECT distinct ?person ?personLabel ?born ?died WHERE {
    { ?position wdt:P31 wd:Q18115939 . } union { ?position wdt:P31 wd:Q56760832 } . # position is UK ambassador or high commissioner
      ?person p:P39 ?positionStatement . ?positionStatement ps:P39 ?position 
  OPTIONAL { ?person wdt:P569 ?born } .
  OPTIONAL { ?person wdt:P570 ?died } .
  {  wd:Q37594 wdt:P40* ?person . } # person's child, or their child's child, and so on
  union
  { ?person (wdt:P25|wdt:P22)* wd:Q37594 . } # person's parent, or their parent's parent, and so on
  #
  # must replace Q37594 in both of the above lines to make this work properly
  # 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } }

Try it!

Ambassadors in the Olympics
select distinct ?person ?personLabel ?thingLabel WHERE 
{
 ?person wdt:P1344 ?thing . # person did a thing
 { ?thing wdt:P31 wd:Q159821 } UNION { ?thing wdt:P31 wd:Q82414 }  # thing was the olympics
    { ?position wdt:P31 wd:Q18115939 . } union { ?position wdt:P31 wd:Q56760832 } . # position is UK ambassador or high commissioner
      ?person p:P39 ?positionStatement . ?positionStatement ps:P39 ?position 
 SERVICE wikibase:label { bd:serviceParam wikibase:language 'en' }
}

Try it!

Where were Ambassadors educated?
# Count of P69 'educated at' grouped by educational establishment, for  
#'Wikidata entries for British ambassadors and high commissioners

 select ?educatedLabel (count(distinct ?person) as ?count)
   where {
     { ?position wdt:P31 wd:Q18115939 . } union { ?position wdt:P31 wd:Q56760832 } . 
    ?person p:P39 ?positionStatement . ?positionStatement ps:P39 ?position . 
   ?person wdt:P69 ?educated . # where were they educated
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
   } group by ?educatedLabel
#defaultView:BubbleChart

Try it!

Ambassadorial/High Commission posts and associated metadata
# Wikidata entries for British ambassadors and high commissioners
# items are mostly internal linking infrastructure (is it a class of Ambassador to X, etc)
# count is number of distinct individuals in Wikidata known to hold the role
# and number sourced to the FCO database

select distinct ?item ?itemLabel ?count ?importedcount ?otherclass ?otherclassLabel ?startyear ?category ?categoryLabel ?list ?listLabel where
{
  { ?item wdt:P31 wd:Q18115939 . } union { ?item wdt:P31 wd:Q56760832 } . # ambassador or high commissioner
  optional { ?item wdt:P31 ?otherclass . ?otherclass wdt:P279* wd:Q121998 . minus {?otherclass wdt:P17 wd:Q145 } . }
  optional { ?item wdt:P2354 ?list } .
  optional { ?item wdt:P910 ?category } .
  optional { ?item wdt:P571 ?start . bind(year(?start) as ?startyear) } .
  
  optional { select distinct ?item (count(distinct ?holder) as ?count) 
             where
                    {
                      { ?item wdt:P31 wd:Q18115939 . } union { ?item wdt:P31 wd:Q56760832 } .
                      ?holder p:P39 ?positionStatement . ?positionStatement ps:P39 ?item . 
                    } group by ?item
            }
  optional { select distinct ?item (count(distinct ?importedholder) as ?importedcount) 
             where
                    {
                      { ?item wdt:P31 wd:Q18115939 . } union { ?item wdt:P31 wd:Q56760832 } .
                      ?importedholder p:P39 ?positionStatement . ?positionStatement ps:P39 ?item . 
                          ?positionStatement prov:wasDerivedFrom ?ref . ?ref pr:P248 wd:Q56808876 .
                    } group by ?item
            }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

Try it!

List of Ambassadors metadata
# List metadata
select distinct ?item ?itemLabel ?list ?listLabel ?is_a_list_of ?is_a_list_ofLabel ?is_a_list_of_PQ_position_held ?is_a_list_of_PQ_position_heldLabel where
{
  { ?item wdt:P31 wd:Q18115939 . } union { ?item wdt:P31 wd:Q56760832 } . # ambassador or high commissioner
  ?item wdt:P2354 ?list  .
  optional 
  {
    ?list p:P360 ?statement.
    ?statement ps:P360 ?is_a_list_of.
    optional {?statement pq:P39 ?is_a_list_of_PQ_position_held}
  }  
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

Try it!

Category of Ambassadors metadata
# Category metadata
select distinct ?item ?itemLabel ?P31Label ?topic ?topicLabel ?list ?listLabel where
{
  { ?item wdt:P31 wd:Q18115939 . } union { ?item wdt:P31 wd:Q56760832 } . # ambassador or high commissioner
  ?item wdt:P910 ?category .
  optional { ?category wdt:P31 ?P31 . }
  optional { ?category wdt:P301 ?topic . }
  optional { ?category wdt:P1753 ?list . }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

Try it!