Skip to content

Instantly share code, notes, and snippets.

@wsalesky
Last active May 8, 2018 12:53
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 wsalesky/0c80c9a9754cbba9a915d317e2bbfa3e to your computer and use it in GitHub Desktop.
Save wsalesky/0c80c9a9754cbba9a915d317e2bbfa3e to your computer and use it in GitHub Desktop.
SPARQL query to get citations and related subjects for Syriaca.org data
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix lawd: <http://lawd.info/ontology/>
prefix skos: <http://www.w3.org/2004/02/skos/core#>
prefix dcterms: <http://purl.org/dc/terms/>
SELECT ?uri (SAMPLE(?l) AS ?label) (SAMPLE(?uriSubject) AS ?subjects) (SAMPLE(?uriCitations) AS ?citations)
{
?uri rdfs:label ?l
FILTER (?uri IN ( <http://syriaca.org/person/782>,<http://syriaca.org/person/552>,<http://syriaca.org/person/684>,<http://syriaca.org/person/492>)).
FILTER ( langMatches(lang(?l), 'en')).
OPTIONAL{
{SELECT ?uri ( count(?s) as ?uriSubject ) { ?s dcterms:relation ?uri } GROUP BY ?uri } }
OPTIONAL{
{SELECT ?uri ( count(?o) as ?uriCitations ) { ?uri lawd:hasCitation ?o
OPTIONAL{ ?uri skos:closeMatch ?o.}
} GROUP BY ?uri }
}
}
GROUP BY ?uri
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment