Create a gist now

Instantly share code, notes, and snippets.

Retrieves countries
SELECT DISTINCT ?item ?countryLabel ?yearAcquired
WHERE
{
{ SELECT * WHERE {
?item ecrm:P30i_custody_transferred_through ?hasCustody .
?hasCustody ecrm:P4_has_time-span ?hasTime .
?hasTime rdfs:label ?yearAcquired .
?item ecrm:P12i_was_present_at ?placeThing .
?placeThing ecrm:P7_took_place_at ?locality .
?locality skos:prefLabel ?countryLabel .
?locality ecrm:P2_has_type ?localityType .
?localityType skos:prefLabel ?localityTypeLabel .
Filter(?localityTypeLabel = "country or city-state")
}
}
UNION { SELECT * WHERE {
?item ecrm:P30i_custody_transferred_through ?hasCustody .
?hasCustody ecrm:P4_has_time-span ?hasTime .
?hasTime rdfs:label ?yearAcquired .
?item ecrm:P12i_was_present_at ?placeThing .
?placeThing ecrm:P7_took_place_at ?locality .
?locality skos:broader ?broaderLocality .
?broaderLocality skos:prefLabel ?countryLabel .
?broaderLocality ecrm:P2_has_type ?broaderLocalityType .
?broaderLocalityType skos:prefLabel ?broaderLocalityTypeLabel .
Filter(?broaderLocalityTypeLabel = "country or city-state")
}
}
UNION { SELECT * WHERE {
?item ecrm:P30i_custody_transferred_through ?hasCustody .
?hasCustody ecrm:P4_has_time-span ?hasTime .
?hasTime rdfs:label ?yearAcquired .
?item ecrm:P12i_was_present_at ?placeThing .
?placeThing ecrm:P7_took_place_at ?locality .
?locality skos:broader ?broaderLocality .
?broaderLocality skos:prefLabel ?broad2Label .
?broaderLocality ecrm:P2_has_type ?broaderLocalityType .
?broaderLocalityType skos:prefLabel ?broaderLocalityTypeLabel .
?broaderLocality skos:broader ?broad3Locality .
?broad3Locality skos:prefLabel ?countryLabel .
?broad3Locality ecrm:P2_has_type ?broad3LocalityType .
?broad3LocalityType skos:prefLabel ?broad3LocalityTypeLabel .
Filter(?broad3LocalityTypeLabel = "country or city-state")
}
}
UNION { SELECT * WHERE {
?item ecrm:P30i_custody_transferred_through ?hasCustody .
?hasCustody ecrm:P4_has_time-span ?hasTime .
?hasTime rdfs:label ?yearAcquired .
?item ecrm:P12i_was_present_at ?placeThing .
?placeThing ecrm:P7_took_place_at ?locality .
?locality skos:broader ?broaderLocality .
?broaderLocality skos:prefLabel ?broad2Label .
?broaderLocality ecrm:P2_has_type ?broaderLocalityType .
?broaderLocalityType skos:prefLabel ?broaderLocalityTypeLabel .
?broaderLocality skos:broader ?broad3Locality .
?broad3Locality skos:prefLabel ?broad3Label .
?broad3Locality ecrm:P2_has_type ?broad3LocalityType .
?broad3LocalityType skos:prefLabel ?broad3LocalityTypeLabel .
?broad3Locality skos:broader ?broad4Locality .
?broad4Locality skos:prefLabel ?countryLabel .
?broad4Locality ecrm:P2_has_type ?broad4LocalityType .
?broad4LocalityType skos:prefLabel ?broad4LocalityTypeLabel .
Filter(?broad4LocalityTypeLabel = "country or city-state")
}
}
UNION { SELECT * WHERE {
?item ecrm:P30i_custody_transferred_through ?hasCustody .
?hasCustody ecrm:P4_has_time-span ?hasTime .
?hasTime rdfs:label ?yearAcquired .
?item ecrm:P12i_was_present_at ?placeThing .
?placeThing ecrm:P7_took_place_at ?locality .
?locality skos:broader ?broaderLocality .
?broaderLocality skos:prefLabel ?broad2Label .
?broaderLocality ecrm:P2_has_type ?broaderLocalityType .
?broaderLocalityType skos:prefLabel ?broaderLocalityTypeLabel .
?broaderLocality skos:broader ?broad3Locality .
?broad3Locality skos:prefLabel ?broad3Label .
?broad3Locality ecrm:P2_has_type ?broad3LocalityType .
?broad3LocalityType skos:prefLabel ?broad3LocalityTypeLabel .
?broad3Locality skos:broader ?broad4Locality .
?broad4Locality skos:prefLabel ?broad4Label .
?broad4Locality ecrm:P2_has_type ?broad4LocalityType .
?broad4LocalityType skos:prefLabel ?broad4LocalityTypeLabel .
?broad4Locality skos:broader ?broad5Locality .
?broad5Locality skos:prefLabel ?countryLabel .
?broad5Locality ecrm:P2_has_type ?broad5LocalityType .
?broad5LocalityType skos:prefLabel ?broad5LocalityTypeLabel .
Filter(?broad5LocalityTypeLabel = "country or city-state")
}
}
UNION { SELECT * WHERE {
?item ecrm:P30i_custody_transferred_through ?hasCustody .
?hasCustody ecrm:P4_has_time-span ?hasTime .
?hasTime rdfs:label ?yearAcquired .
?item ecrm:P12i_was_present_at ?placeThing .
?placeThing ecrm:P7_took_place_at ?locality .
?locality skos:broader ?broaderLocality .
?broaderLocality skos:prefLabel ?broad2Label .
?broaderLocality ecrm:P2_has_type ?broaderLocalityType .
?broaderLocalityType skos:prefLabel ?broaderLocalityTypeLabel .
?broaderLocality skos:broader ?broad3Locality .
?broad3Locality skos:prefLabel ?broad3Label .
?broad3Locality ecrm:P2_has_type ?broad3LocalityType .
?broad3LocalityType skos:prefLabel ?broad3LocalityTypeLabel .
?broad3Locality skos:broader ?broad4Locality .
?broad4Locality skos:prefLabel ?broad4Label .
?broad4Locality ecrm:P2_has_type ?broad4LocalityType .
?broad4LocalityType skos:prefLabel ?broad4LocalityTypeLabel .
?broad4Locality skos:broader ?broad5Locality .
?broad5Locality skos:prefLabel ?broad5Label .
?broad5Locality ecrm:P2_has_type ?broad5LocalityType .
?broad5LocalityType skos:prefLabel ?broad5LocalityTypeLabel .
?broad5Locality skos:broader ?broad6Locality .
?broad6Locality skos:prefLabel ?countryLabel .
?broad6Locality ecrm:P2_has_type ?broad6LocalityType .
?broad6LocalityType skos:prefLabel ?broad6LocalityTypeLabel .
Filter(?broad6LocalityTypeLabel = "country or city-state")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment