Skip to content

Instantly share code, notes, and snippets.

@robertbrook
Created September 29, 2020 09:09
Show Gist options
  • Save robertbrook/ea40d7710e53c8eb0409229bc6e25db2 to your computer and use it in GitHub Desktop.
Save robertbrook/ea40d7710e53c8eb0409229bc6e25db2 to your computer and use it in GitHub Desktop.
# This query uses classes from UK Parliament's procedure ontology: https://ukparliament.github.io/ontologies/procedure/procedure-ontology.html.
# Following work done by Jeni Tennison, the following query looks for instruments that implement local coronavirus lockdowns in areas of England.
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX : <https://id.parliament.uk/schema/>
PREFIX id: <https://id.parliament.uk/>
# The above rows describe where the datasets that this query is built on come from.
select distinct ?SI ?SIname ?workPackage ?LegislationRef ?procedureId ?Procedure ?Madedate ?LaidDate ?ApprovalORObjectionPeriodBegins ?ApprovalORObjectionPeriodEnds where {
# The select row is identifying what information to return from the query. These are all variables from the query below.
?SI a :StatutoryInstrumentPaper .
?SI rdfs:label ?SIname .
# An SI is considered a workpackageable thing which is the focus of a workpackage.
?SI :laidThingHasLaying/:layingDate ?LaidDate.
# The date the instrument was laid before Parliament.
?SI :workPackagedThingHasWorkPackagedThingWebLink ?LegislationRef .
# All instruments should be published on legislation.gov.uk. In the URL for the instrument it will include the SI number and year it was published, which is usually the SI reference e.g. SI 2020/685
?SI :statutoryInstrumentPaperMadeDate ?Madedate .
# Instruments will be made before they are laid before Parliament (unless they're draft instruments), generally a few days before but sometimes the same day.
?SI :workPackagedThingHasWorkPackage ?workPackage .
# A workpackage is a group of business items under a procedure or as determined by a committee, for example: business items considered during the passage of a particular Statutory Instrument.
?workPackage :workPackageHasProcedure ?procedureId.
?procedureId :name ?Procedure.
FILTER (?procedureId IN (id:iWugpxMn, id:5S6p4YsP))
# Statutory instruments can be laid under a number of procedures with all having different routes through Parliament. This query is limited to the made negative and made affirmative procedures as all coronavirus lockdown instruments are seen as emergency legislation so will always be made rather than drafts.
FILTER (regex(str(?LegislationRef), "www.legislation.gov.uk/uksi/2020/685") ||
regex(str(?LegislationRef), "legislation.gov.uk/uksi/2020/800") ||
regex(str(?LegislationRef), "www.legislation.gov.uk/uksi/2020/822") ||
regex(str(?LegislationRef), "www.legislation.gov.uk/uksi/2020/824") ||
regex(str(?LegislationRef), "www.legislation.gov.uk/uksi/2020/828")
)
# FILTER functions like regex can be used to match the lexical forms of other literals by using the str function. The above is looking for where the strings above match the url added to :workPackagedThingHasWorkPackagedThingWebLink of the instrument. These strings come from the work Jeni Tennison has done.
OPTIONAL { ?workPackage :workPackageHasBusinessItem ?bi.
?bi :businessItemHasProcedureStep ?stepId.
?bi :businessItemDate ?ApprovalORObjectionPeriodEnds.
?stepId :procedureStepName ?stepName.
FILTER (?stepId in (id:Ksnj7JJ8, id:g8B3R2Ou))}
# A business item is an item of business conducted either within or outside Parliament. This business item is looking for where the 'Objection period ends' (id:g8B3R2Ou) or 'Approval period ends' (id:Ksnj7JJ8) steps have been added to a made instrument.
OPTIONAL { ?workPackage :workPackageHasBusinessItem ?bi2.
?bi2 :businessItemHasProcedureStep ?stepId2.
?bi2 :businessItemDate ?ApprovalORObjectionPeriodBegins.
?stepId2 :procedureStepName ?stepName2.
FILTER (?stepId2 in (id:No1qmqJ4, id:oUjmJcf5))}
# A business item is an item of business conducted either within or outside Parliament. This business item is looking for where the 'Objection period begins' (id:oUjmJcf5) or 'Approval period begins' (id:No1qmqJ4) steps have been added to a made instrument.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment