Skip to content

Instantly share code, notes, and snippets.

@dmccreary
Last active July 14, 2017 18:28
Show Gist options
  • Save dmccreary/eb8f100c5db8ccbe23a2efaef8deb9eb to your computer and use it in GitHub Desktop.
Save dmccreary/eb8f100c5db8ccbe23a2efaef8deb9eb to your computer and use it in GitHub Desktop.
Sample Keyword Expansion SPARQL Query
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX skosxl: <http://www.w3.org/2008/05/skos-xl#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
SELECT (str(?prefTerm) AS ?pTerm) (str(?altTerm) AS ?aTerm)
FROM <urn:x-evn-master:BenefitSectionDetails0>
FROM <urn:x-evn-master:BenefitSection>
WHERE {
?s (skosxl:prefLabel | skosxl:altLabel) / skosxl:literalForm ?allTerms .
FILTER (LCASE(str(?allTerms)) = LCASE('IUD'))
{?s skosxl:prefLabel/skosxl:literalForm ?prefTerm .
?s skosxl:altLabel/skosxl:literalForm ?altTerm .
}
UNION
{
?s skos:broader* ?pConcept .
?pConcept skosxl:prefLabel/skosxl:literalForm ?prefTerm .
?pConcept skosxl:altLabel/skosxl:literalForm ?altTerm .
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment