Skip to content

Instantly share code, notes, and snippets.

View ewg118's full-sized avatar

Ethan Gruber ewg118

  • American Numismatic Society
  • Charlottesville, Virginia
View GitHub Profile
@ewg118
ewg118 / la_display.sparql
Created July 10, 2026 18:39
Basic Linked Art display query
PREFIX la: <https://linked.art/ns/terms/>
PREFIX crm: <http://www.cidoc-crm.org/cidoc-crm/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?label ?place ?placeLabel ?coords ?creator ?creatorLabel ?type ?typeLabel ?manifest WHERE {
BIND (<https://search.lib.virginia.edu/sources/images/items/u11179> as ?object)
?object rdfs:label ?label .
OPTIONAL {?object crm:P108i_was_produced_by/crm:P7_took_place_at ?place .
?place rdfs:label ?placeLabel .
OPTIONAL {?place crm:P168_place_is_defined_by ?coords }}
OPTIONAL {
@ewg118
ewg118 / virginia_production.sparql
Last active July 9, 2026 12:50
UVA items created in Virginia, with WKT coordinates and IIIF manifest
PREFIX la: <https://linked.art/ns/terms/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX crm: <http://www.cidoc-crm.org/cidoc-crm/>
SELECT ?object ?title ?place ?placeLabel ?wkt ?manifest WHERE {
?object a crm:E22_Human-Made_Object ;
rdfs:label ?title ;
crm:P108i_was_produced_by/crm:P7_took_place_at ?place ;
crm:P129i_is_subject_of/la:digitally_carried_by/la:access_point ?manifest.
?place crm:P89_falls_within* <https://sws.geonames.org/6254928/> ; #Virginia
rdfs:label ?placeLabel .
@ewg118
ewg118 / virginia.sparql
Created July 7, 2026 20:26
Get all UVA Library special collections objects created in or are about Virginia
PREFIX la: <https://linked.art/ns/terms/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX crm: <http://www.cidoc-crm.org/cidoc-crm/>
PREFIX la: <https://linked.art/ns/terms/>
SELECT DISTINCT ?object ?label ?place ?placeLabel WHERE {
BIND (<https://sws.geonames.org/6254928/> as ?entity)
{?entity ^crm:P89_falls_within* ?place }
@ewg118
ewg118 / printers.sparql
Created July 7, 2026 15:03
The names of printers associated with UVA Library Special Collections objects
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX crm: <http://www.cidoc-crm.org/cidoc-crm/>
SELECT DISTINCT ?object ?label ?entityLabel WHERE {
?object a crm:E22_Human-Made_Object ;
rdfs:label ?label ;
{?object crm:P108i_was_produced_by ?prod}
UNION {?object crm:P108i_was_produced_by/crm:P9_consists_of ?prod}
@ewg118
ewg118 / dateRange.sparql
Created July 2, 2026 20:49
Querying CIDOC-CRM for date range from dateTime encoded dates
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX crm: <http://www.cidoc-crm.org/cidoc-crm/>
SELECT ?object ?year WHERE {
?object a crm:E22_Man-Made_Object ;
crm:P108i_was_produced_by/crm:P4_has_time-span ?timespan .
?timespan crm:P82a_begin_of_the_begin ?date
BIND (year(xsd:dateTime(?date)) as ?year)
@ewg118
ewg118 / uva-lib:602113.json
Created June 18, 2026 17:00
Linked Art JSON-LD of uva-lib:602113 derived from MARC (includes LCSH)
{
"@context": "https://linked.art/ns/v1/linked-art.json",
"id": "https://search.lib.virginia.edu/sources/images/items/uva-lib:602113",
"type": "HumanMadeObject",
"_label": "Novvelles inventions povr bien bastir et a petits fraiz, trovvees n'Agveres",
"identified_by": [
{
"type": "Name",
"content": "Novvelles inventions povr bien bastir et a petits fraiz, trovvees n'Agveres",
"classified_as": [
@ewg118
ewg118 / uva-lib:612978.json
Created June 18, 2026 16:48
Linked Art JSON-LD representation of an object that began as MARC
{
"@context": "https://linked.art/ns/v1/linked-art.json",
"id": "https://search.lib.virginia.edu/sources/images/items/uva-lib:612978",
"type": "HumanMadeObject",
"_label": "triumphes Petrarcque",
"identified_by": [
{
"type": "Name",
"content": "triumphes Petrarcque",
"classified_as": [
@ewg118
ewg118 / gist:19a29ec41b8edb76832ce51506b81c74
Last active June 18, 2026 12:09
Getty - MARC Relator template
<role
{{if(isNonBlank(cells["Activity Type"].value), 'property="' + cells["Activity Type"].value + '"', '')}}
{{if(isNonBlank(cells["URI"].value), 'marcrelator="' + cells["URI"].value + '"', '')}}
{{if(isNonBlank(cells["Getty Role"].value), 'aat="' + cells["Getty Role"].value + '"', '')}}
{{if(isNonBlank(cells["Technique URI"].value), 'technique="' + cells["Technique URI"].value + '"', '')}}
{{if(isNonBlank(cells["Technique Label"].value), 'techniqueLabel="' + cells["Technique Label"].value + '"', '')}}>
cells["Preferred Label"].value
</role>
@ewg118
ewg118 / ashmolean-coins.rdf
Last active May 26, 2026 15:58
Ashmolean coin template with hoards and findspots
<nmo:NumismaticObject rdf:about="{{cells['URI'].value}}">
<dcterms:title xml:lang="en">{{cells["Title"].value}}</dcterms:title>
<dcterms:identifier>{{cells["id"].value}}</dcterms:identifier>
<nmo:hasCollection rdf:resource="http://nomisma.org/id/ashmolean"/>
<nmo:hasTypeSeriesItem rdf:resource="{{cells["Type URI"].value}}"/>
{{forNonBlank(cells["weight"], c, '<nmo:hasWeight rdf:datatype="http://www.w3.org/2001/XMLSchema#decimal">' + c.value + '</nmo:hasWeight>', "")}}
{{forNonBlank(cells["diameter"], c, '<nmo:hasDiameter rdf:datatype="http://www.w3.org/2001/XMLSchema#decimal">' + c.value + '</nmo:hasDiameter>', "")}}
{{forNonBlank(cells["axis"], c, '<nmo:hasAxis rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">' + c.value + '</nmo:hasAxis>', "")}}
{{forNonBlank(cells["Hoard URI"], c, '<dcterms:isPartOf rdf:resource="' + c.value + '"/>', "")}}
{{forNonBlank(cells["Findspot URI"], c, '<nmo:hasFindspot>
@ewg118
ewg118 / uva-lib:2372197.xml
Created May 8, 2026 18:23
uva-lib:2372197 enriched MODS
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<mods xmlns="http://www.loc.gov/mods/v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.loc.gov/mods/v3 mods-3-6.xsd" version="3.6">
<typeOfResource>still image</typeOfResource>
<titleInfo>
<title>North Wales</title>
</titleInfo>
<name authority="lcnaf" type="personal" valueURI="http://id.loc.gov/authorities/names/n85307501">
<namePart>Johnston, Frances Benjamin, 1864-1952</namePart>
<role>
<roleTerm type="code" authority="marcrelator" valueURI="http://id.loc.gov/vocabulary/relators/pht"/>