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 / wikidata-hierarchy.sparql
Last active December 1, 2025 20:50
Wikidata basic hierarchy query
SELECT ?concept ?conceptLabel (GROUP_CONCAT(DISTINCT(?altLabel); separator = "|") AS ?altLabels) ?parent ?parentLabel (GROUP_CONCAT(DISTINCT(?parentAltLabel); separator = "|") AS ?parentAltLabels) WHERE {
BIND (<http://www.wikidata.org/entity/Q2102> as ?concept)
?concept wdt:P279+|wdt:P31 ?parent .
FILTER NOT EXISTS {?parent wdt:P31 wd:Q19478619}
FILTER NOT EXISTS {?parent wdt:P31 wd:Q124711104}
FILTER NOT EXISTS {?parent wdt:P279 wd:Q27043950}
OPTIONAL {?concept skos:altLabel ?altLabel FILTER (langMatches(lang(?altLabel), "en")) }
OPTIONAL {?parent skos:altLabel ?parentAltLabel FILTER (langMatches(lang(?parentAltLabel), "en")) }
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
} GROUP BY ?concept ?conceptLabel ?parent ?parentLabel
@ewg118
ewg118 / pella_gold.sparql
Last active October 24, 2025 15:22
PELLA gold coins and images
PREFIX crm: <http://www.cidoc-crm.org/cidoc-crm/>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX dcmitype: <http://purl.org/dc/dcmitype/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX nm: <http://nomisma.org/id/>
PREFIX nmo: <http://nomisma.org/ontology#>
PREFIX org: <http://www.w3.org/ns/org#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
@ewg118
ewg118 / yale-template.rdf
Last active October 14, 2025 18:02
Yale OpenRefine RDF template for Kerameikos
<crm:E22_Man-Made_Object rdf:about="{{cells['URI'].value}}">
<crm:P1_is_identified_by>
<crm:E33_E41_Linguistic_Appellation>
<crm:P190_has_symbolic_content>{{cells['Title'].value}}</crm:P190_has_symbolic_content>
<crm:P2_has_type rdf:resource="http://vocab.getty.edu/aat/300404670"/>
</crm:E33_E41_Linguistic_Appellation>
</crm:P1_is_identified_by>
<crm:P1_is_identified_by>
<crm:E42_Identifier>
<crm:P190_has_symbolic_content>{{cells['Accession number'].value}}</crm:P190_has_symbolic_content>
@ewg118
ewg118 / met-meseum-template.rdf
Last active September 5, 2025 20:21
Met Museum OpenRefine template
<crm:E22_Man-Made_Object rdf:about="{{cells['URI'].value}}">
<crm:P1_is_identified_by>
<crm:E33_E41_Linguistic_Appellation>
<crm:P190_has_symbolic_content>{{cells['Title'].value}}</crm:P190_has_symbolic_content>
<crm:P2_has_type rdf:resource="http://vocab.getty.edu/aat/300404670"/>
</crm:E33_E41_Linguistic_Appellation>
</crm:P1_is_identified_by>
<crm:P1_is_identified_by>
<crm:E42_Identifier>
<crm:P190_has_symbolic_content>{{cells['Accession'].value}}</crm:P190_has_symbolic_content>
@ewg118
ewg118 / ashmolean-template.rdf
Last active September 4, 2025 15:26
Ashmolean OpenRefine RDF template for Kerameikos
<crm:E22_Man-Made_Object rdf:about="{{cells['URI'].value}}">
<crm:P1_is_identified_by>
<crm:E33_E41_Linguistic_Appellation>
<crm:P190_has_symbolic_content>{{cells['Title'].value}}</crm:P190_has_symbolic_content>
<crm:P2_has_type rdf:resource="http://vocab.getty.edu/aat/300404670"/>
</crm:E33_E41_Linguistic_Appellation>
</crm:P1_is_identified_by>
<crm:P1_is_identified_by>
<crm:E42_Identifier>
<crm:P190_has_symbolic_content>{{cells['Accession number'].value}}</crm:P190_has_symbolic_content>
@ewg118
ewg118 / hoard_concordance.sparql
Created July 25, 2025 14:43
Get hoard concordance URIs from Nomisma SPARQL
PREFIX crm: <http://www.cidoc-crm.org/cidoc-crm/>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX dcmitype: <http://purl.org/dc/dcmitype/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX nm: <http://nomisma.org/id/>
PREFIX nmo: <http://nomisma.org/ontology#>
PREFIX org: <http://www.w3.org/ns/org#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
@ewg118
ewg118 / mints_no_regions.sparql
Last active July 2, 2025 19:38
Nomisma mints without regions
PREFIX crm: <http://www.cidoc-crm.org/cidoc-crm/>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX dcmitype: <http://purl.org/dc/dcmitype/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX nm: <http://nomisma.org/id/>
PREFIX nmo: <http://nomisma.org/ontology#>
PREFIX org: <http://www.w3.org/ns/org#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
@ewg118
ewg118 / template.rdf
Created November 20, 2024 14:59
Harvard Art Museums OpenRefine RDF template
<nmo:NumismaticObject rdf:about="{{cells['URI'].value}}">
<dcterms:title xml:lang="en">{{cells["Title"].value}}</dcterms:title>
<dcterms:identifier>{{cells["HAM accession no."].value}}</dcterms:identifier>
<nmo:hasCollection rdf:resource="http://nomisma.org/id/harvard"/>
<nmo:hasTypeSeriesItem rdf:resource="{{cells["BIGR type"].value}}"/>
{{forNonBlank(cells["Weight (g)"], c, '<nmo:hasWeight rdf:datatype="http://www.w3.org/2001/XMLSchema#decimal">' + c.value + '</nmo:hasWeight>', "")}}
{{forNonBlank(cells["Die axis"], c, '<nmo:hasAxis rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">' + c.value + '</nmo:hasAxis>', "")}}
<foaf:thumbnail rdf:resource="{{ cells["Reference Image"].value }}?width=240"/>
<foaf:depiction rdf:resource="{{ cells["Reference Image"].value }}"/>
<void:inDataset rdf:resource="http://www.harvardartmuseums.org/"/>
@ewg118
ewg118 / monogram-mint.sparql
Created September 30, 2024 20:25
Nomisma query for monograms by mint
PREFIX crm: <http://www.cidoc-crm.org/cidoc-crm/>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX dcmitype: <http://purl.org/dc/dcmitype/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX nm: <http://nomisma.org/id/>
PREFIX nmo: <http://nomisma.org/ontology#>
PREFIX org: <http://www.w3.org/ns/org#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
@ewg118
ewg118 / monogram-link.sparql
Created September 27, 2024 20:36
SPARQL query to match monogram relationships in Nomisma