Skip to content

Instantly share code, notes, and snippets.

@ewg118
Created November 11, 2016 00:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ewg118/8a9797a77b77c628be4c36cead153121 to your computer and use it in GitHub Desktop.
Save ewg118/8a9797a77b77c628be4c36cead153121 to your computer and use it in GitHub Desktop.
Get the distribution of shapes for Red Figure vases in Kerameikos.org
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX crm: <http://www.cidoc-crm.org/cidoc-crm/>
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX kid: <http://kerameikos.org/id/>
PREFIX kon: <http://kerameikos.org/ontology#>
PREFIX spatial: <http://jena.apache.org/spatial#>
SELECT DISTINCT ?concept ?label (count(?concept) as ?count) WHERE {
{
SELECT ?1 WHERE { kid:red_figure skos:exactMatch ?1}
}
?object crm:P32_used_general_technique ?1.
?object kon:hasShape ?dist
{
SELECT ?dist ?label ?concept WHERE {
?concept skos:exactMatch ?dist;
skos:prefLabel ?label FILTER langMatches(lang(?label), "en")}
}
} GROUP BY ?concept ?label ORDER BY ?label
@Conal-Tuohy
Copy link

Could you eliminate ?1 and boil it down a bit using a Property Path to do the traversal of the (optional) skos:exactMatch property?

@Conal-Tuohy
Copy link

Conal-Tuohy commented Nov 12, 2016

How about this:

PREFIX skos:	<http://www.w3.org/2004/02/skos/core#>
PREFIX crm:	<http://www.cidoc-crm.org/cidoc-crm/>
PREFIX kid:	<http://kerameikos.org/id/>
PREFIX kon: <http://kerameikos.org/ontology#>

SELECT DISTINCT ?concept ?label (count(?concept) as ?count) WHERE {
    kid:red_figure skos:exactMatch*/^crm:P32_used_general_technique/kon:hasShape/^skos:exactMatch* ?concept.
    ?concept skos:prefLabel ?label FILTER langMatches(lang(?label), "en")
} GROUP BY ?concept ?label ORDER BY ?label

Maybe those * tokens should be +?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment