Skip to content

Instantly share code, notes, and snippets.

@wsalesky
Created June 15, 2018 13:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wsalesky/0ca92bf5315c675995e8cc1e43b87fa3 to your computer and use it in GitHub Desktop.
Save wsalesky/0ca92bf5315c675995e8cc1e43b87fa3 to your computer and use it in GitHub Desktop.
POC of facets used on SPEAR data Syriaca.org. This is a work in progress.
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix cwrc: <http://sparql.cwrc.ca/ontologies/cwrc#>
prefix dcterms: <http://purl.org/dc/terms/>
prefix lawd: <http://lawd.info/ontology/>
prefix person: <https://www.w3.org/ns/person>
prefix skos: <http://www.w3.org/2004/02/skos/core#>
prefix snap: <http://data.snapdrgn.net/ontology/snap#>
prefix syriaca: <http://syriaca.org/schema#>
SELECT distinct ?key ?facet_value ?facet_label ?facet_count
WHERE
{ # facets
{ # Event Types facet
SELECT distinct ('eventType' as ?key) (?eventValue as ?facet_value) (?eventLabel as ?facet_label) (count(distinct ?s) as ?facet_count)
WHERE{
?s rdf:type <http://syriaca.org/schema#/eventFactoid> ;
dcterms:subject ?eventValue.
FILTER CONTAINS(str(?eventValue), 'keyword').
?eventValue rdfs:label ?eventLabel.
FILTER ( langMatches(lang(?eventLabel), 'en')).
{# Main query
SELECT DISTINCT ?s WHERE {
VALUES ?event { <http://syriaca.org/keyword/anathema>}
?factoid dcterms:subject ?event;
rdf:type <http://syriaca.org/schema#/eventFactoid>.
?factoid dcterms:subject ?person.
FILTER CONTAINS(str(?person), 'person').
?person rdfs:label ?persName.
FILTER ( langMatches(lang(?persName), 'en')).
}}
} GROUP BY ?eventLabel ?eventValue
ORDER BY asc(str(?eventLabel))
}UNION
{ # sex facet
SELECT distinct ('sex' as ?key) (?sexLabel as ?facet_value) (?sexLabel as ?facet_label) (count(distinct ?s) as ?facet_count)
WHERE{
?s syriaca:sex ?sexLabel
{# Main query
SELECT DISTINCT ?s WHERE {
VALUES ?event { <http://syriaca.org/keyword/anathema>}
?factoid dcterms:subject ?event;
rdf:type <http://syriaca.org/schema#/eventFactoid>.?factoid dcterms:subject ?person.
FILTER CONTAINS(str(?person), 'person').
?person rdfs:label ?persName.
FILTER ( langMatches(lang(?persName), 'en')).
}}
} GROUP BY ?sexLabel
ORDER BY asc(str(?sexLabel))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment