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!

Project extends to Foreign Office staff other than ambassadors; and UK High Commissions, embassies and consulates.

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:

To do[edit]

  • QA and import honours from the BDD data
  • subject has role (P2868): eg chargé d'affaires (Q217713) when not formally "Ambassador" but still the head of mission with a lower rank (especially Charges d'Affaires, but also Ministers & Minister Residents may be interesting to model)
  • Fix up situations where someone did not proceed (use qualifier)
  • Update based on .gov.uk info, such as from a search for "Change of Her Majesty’s Ambassador", & from people bios - e.g. Jane Owen
  • Update based on British Diplomatic Oral History Programme (honours, education, aliases &c ... interviews 1-45 have been done)
    • if there's a wikipedia article, add an external link to the BDOH entry & transcript - e.g. Frank Roberts diff.

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?

General reports[edit]

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!

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!

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!

What awards did they receive?
# Count of P166 'award received' grouped by award type, for  
#'Wikidata entries for British ambassadors and high commissioners

 select ?awardedLabel (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:P166 ?awarded . # what award(s) were made to them
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
   } group by ?awardedLabel
#defaultView:BubbleChart

Try it!

Current Ambassadors & High Commissioners on twitter
select distinct ?person ?personLabel ?positionLabel ?start_date ?twitter_username where
{
  ?person p:P39 ?positionStatement . 
  ?positionStatement ps:P39 ?position .
  { ?position wdt:P31 wd:Q18115939 . } union { ?position wdt:P31 wd:Q56760832 } . 
  ?positionStatement pq:P580 ?start_date .
  filter not exists {?positionStatement pq:P582 ?end_date . }
  ?person wdt:P2002 ?twitter_username .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} order by ?positionLabel

Try it!

Ambassadors who were in the ODNB
# Wikidata entries for British ambassadors and high commissioners
# showing the number of those who have been deceased more than three years (=eligible for ODNB coverage)
# and the proportion of those in the ODNB, a first-order approximation of "historical significance"
# it is filtered so there must be ten or more deceased holders of a post (otherwise ones with low matching rates dominate)
# bear in mind that Wikidata does not have *complete* matching to many of these posts yet so percentages may drop

select distinct ?item ?itemLabel ?number_of_deceased_holders ?percent_odnb where
{
  { ?item wdt:P31 wd:Q18115939 . } union { ?item wdt:P31 wd:Q56760832 } . # ambassador or high commissioner
  
   { select distinct ?item (count(distinct ?holder) as ?number_of_deceased_holders) 
             where
                    {
                      { ?item wdt:P31 wd:Q18115939 . } union { ?item wdt:P31 wd:Q56760832 } .
                      ?holder p:P39 ?positionStatement . ?positionStatement ps:P39 ?item . 
                      ?holder wdt:P570 ?died . FILTER (?died < "2015-01-01T00:00:00Z"^^xsd:dateTime) .
                      # ie this person died before 1/1/2015 and so is theoretically ODNB-eligible
                    } group by ?item
            }
  { select distinct ?item (count(distinct ?holder) as ?odnbcount) 
             where
                    {
                      { ?item wdt:P31 wd:Q18115939 . } union { ?item wdt:P31 wd:Q56760832 } .
                      ?holder p:P39 ?positionStatement . ?positionStatement ps:P39 ?item . 
                      ?holder wdt:P1415 ?odnb .
                    } group by ?item
            }
  filter(?number_of_deceased_holders >= 10)
  BIND(ROUND(100*(?odnbcount/?number_of_deceased_holders)) as ?percent_odnb) .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} order by desc(?percent_odnb) desc(?number_of_deceased_holders)

Try it!

Diplomatic-political crossover[edit]

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!

Ambassadorial roles with the proportion of holders who were MPs (former or future)
select distinct ?item ?itemLabel ?number_of_holders ?percent_mp_before ?percent_mp_after ?percent_mp_ever where
{
  { ?item wdt:P31 wd:Q18115939 . } union { ?item wdt:P31 wd:Q56760832 } . # ambassador or high commissioner
   { select distinct ?item (count(distinct ?holder) as ?number_of_holders) 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 ?holder) as ?after) where
    {
      { ?item wdt:P31 wd:Q18115939 . } union { ?item wdt:P31 wd:Q56760832 } .
      ?holder p:P39 ?positionStatement . ?positionStatement ps:P39 ?item . ?positionStatement pq:P580 ?poststart .
      ?holder p:P39 ?positionStatement2 . ?positionStatement2 ps:P39 ?mp .
      { ?mp wdt:P279* wd:Q16707842 } union { ?mp wdt:P279* wd:Q18015642 } union { ?mp wdt:P279* wd:Q18018860 } . 
      ?positionStatement2 pq:P580 ?mpstart . filter (?mpstart >= ?poststart) . 
    } group by ?item
 }
 optional { select distinct ?item (count(distinct ?holder) as ?before) where
    {
      { ?item wdt:P31 wd:Q18115939 . } union { ?item wdt:P31 wd:Q56760832 } .
      ?holder p:P39 ?positionStatement . ?positionStatement ps:P39 ?item . ?positionStatement pq:P580 ?poststart .
      ?holder p:P39 ?positionStatement2 . ?positionStatement2 ps:P39 ?mp .
      { ?mp wdt:P279* wd:Q16707842 } union { ?mp wdt:P279* wd:Q18015642 } union { ?mp wdt:P279* wd:Q18018860 } . 
      ?positionStatement2 pq:P582 ?mpend . filter (?mpend <= ?poststart) . 
    } group by ?item
  } 
  { select distinct ?item (count(distinct ?holder) as ?ever) where
    {
      { ?item wdt:P31 wd:Q18115939 . } union { ?item wdt:P31 wd:Q56760832 } .
      ?holder p:P39 ?positionStatement . ?positionStatement ps:P39 ?item . 
      ?holder p:P39 ?positionStatement2 . ?positionStatement2 ps:P39 ?mp .
      { ?mp wdt:P279* wd:Q16707842 } union { ?mp wdt:P279* wd:Q18015642 }  union { ?mp wdt:P279* wd:Q18018860 } . 
	} group by ?item
  }
  BIND(ROUND(100*(?after/?number_of_holders)) as ?percent_mp_after) .
  BIND(ROUND(100*(?before/?number_of_holders)) as ?percent_mp_before) .
  BIND(ROUND(100*(?ever/?number_of_holders)) as ?percent_mp_ever) .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} order by desc(?number_of_holders)

Try it!



Reports by country - example Argentina[edit]

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". }
} order by ?startyear

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!

Metadata reports[edit]

Ambassadorial/High Commission position items counts
# Wikidata entries for British ambassadors and high commissioners
# 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 where
{
  { ?item wdt:P31 wd:Q18115939 . } union { ?item wdt:P31 wd:Q56760832 } . # ambassador or high commissioner
  
  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!

Ambassadorial/High Commission position metadata
# Wikidata entries for British ambassadors and high commissioners
# items are mostly internal linking infrastructure (is it a class of Ambassador to X, etc)

select distinct ?item ?itemLabel ?otherclass ?otherclassLabel ?startyear ?category ?categoryLabel ?list ?listLabel ?embassyLabel 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 { ?item wdt:P2389 ?embassy . } 
  
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

Try it!

List of Ambassadors items metadata
# List metadata
select distinct ?item ?list ?listLabel ?is_a_list_of ?is_a_list_ofLabel ?is_a_list_of_PQ_position_held ?is_a_list_of_PQ_position_heldLabel ?category ?categoryLabel 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}
    optional {?list wdt:P1754 ?category . }
  }  
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

Try it!

Category of Ambassadors items metadata
# Category metadata
select distinct ?item ?category ?categoryLabel ?P31Label ?topic ?topicLabel ?list ?listLabel ?commons_sitelink 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 . }
  optional { ?commons_sitelink schema:about ?category ;
          schema:isPartOf <https://commons.wikinedia.org/> . }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

Try it!

Embassy, High Commission & consulate items metadata
SELECT distinct ?item ?itemLabel ?P31Label ?P17Label ?P131Label  ?P137Label ?P361Label ?P2388Label ?Twitter WHERE 
{
  ?item wdt:P31/wdt:P279* wd:Q213283 .
  ?item wdt:P137 wd:Q145.
    optional {?item wdt:P31 ?P31 . }
    optional {?item wdt:P17 ?P17 . }
    optional {?item wdt:P131 ?P131 . } 
    optional {?item wdt:P137 ?P137 .  }
    optional {?item wdt:P361 ?P361 . }
    optional {?item wdt:P2388 ?P2388 . }
    optional {?item wdt:P2002 ?Twitter . }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

Try it!

QA reports[edit]

QA - multiple start/end dates
select ?person ?personLabel ?positionLabel ?start ?end ?start2 ?end2 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
    ?positionStatement pq:P580 ?start .  # id start year
    ?positionStatement pq:P582 ?end .   # id end year
    optional {?positionStatement pq:P580 ?start2 . filter(?start!=?start2)} # id start year
    optional {?positionStatement pq:P582 ?end2 . filter(?end!=?end2)}   # id end year
    bind(coalesce(?start2,?end2) as ?keep)
    filter (bound(?keep))
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

Try it!

QA - position dates outside person's lifespan
select ?person ?personLabel ?positionLabel ?dob ?dod ?start ?end 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
    ?positionStatement pq:P580 ?start .  # id start year
    optional {?positionStatement pq:P582 ?end .}   # id end year
    optional {?person wdt:P569 ?dob.}
    optional {?person wdt:P570 ?dod.} 
    filter(bound(?dob) && bound(?start) && ?start<?dob|| bound(?dod) && bound(?end) && ?end>?dod)
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}   # Note - does not deal with date precision

Try it!

QA - have we removed redundant position=ambassador?
select distinct ?person ?personLabel 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:P39 wd:Q121998.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

Try it!

QA - No start-date; or end-date before start-date; or no end-date and Ambassador in post since 2012 (i.e. maybe too long?)
select ?person ?personLabel ?positionLabel ?start ?end 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 .}  # id start year
    optional {?positionStatement pq:P582 ?end .}   # id end year
    filter(!bound(?start)|| ?end<?start || (!bound(?end) && ?start<2012 )) 
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

Try it!

QA - ambassador lacks either of gender or occupation=diplomat
select distinct ?person ?personLabel ?lacking_gender ?lacking_occ

with { select ?person 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
} } as %persons

with { select ?person  ?lacking_gender where
{
  include %persons
  filter not exists {?person wdt:P21 [].}      #gender
  bind("1" as ?lacking_gender)
} } as %no_gender

with { select ?person ?lacking_occ where
{
  include %persons
  filter not exists {?person wdt:P106 wd:Q193391.}  #occupation
  bind("1" as ?lacking_occ)
} } as %no_occupation

where
{
  {include %no_gender} union {include %no_occupation}
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

Try it!

Not an ambassador?[edit]

# Wikidata entries for FO & FCO employees who are not British ambassadors and high commissioners
select distinct ?person ?personLabel ?birthyear ?deathyear where
{
  values ?employer {wd:Q358834 wd:Q58211956}              # Foreign Office or Foreign & Commonwealth Office
  ?person wdt:P108 ?employer .                            # FO or FCO employs the person
  filter not exists {?person p:P39 ?positionStatement . 
                     ?positionStatement ps:P39 ?position . 
                     ?position wdt:P31 wd:Q56760832 .}    # Person not a High Commissioner
  filter not exists {?person p:P39 ?positionStatement . 
                     ?positionStatement ps:P39 ?position . 
                     ?position wdt:P31 wd:Q18115939 .}    # Person not an ambassador 
  optional { ?person wdt:P569 ?born . bind(year(?born) as ?birthyear) } # birthyear
  optional { ?person wdt:P570 ?died . bind(year(?died) as ?deathyear) } # deathyear  
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} order by ?personLabel

Try it!