Skip to content

Instantly share code, notes, and snippets.

@abargnesi
Created November 10, 2015 17:07
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 abargnesi/d0a0b298bde7940a1411 to your computer and use it in GitHub Desktop.
Save abargnesi/d0a0b298bde7940a1411 to your computer and use it in GitHub Desktop.
Infer exactMatch using case-insensitive string match on prefLabel
Select
PREFIX belv: <http://www.openbel.org/vocabulary/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX fn: <http://www.w3.org/2005/xpath-functions#>
# Bind ?namespaceConceptScheme to the URI of the namespace resource whose concepts you would like equivalenced via concept type and case-insensitive string match.
# Bind ?namespaceConceptType to the URI of the most-specific concept type within ?namespaceConceptScheme. If this isn't provided then concepts will match when they are both Concept, NamespaceConcept, etc.
SELECT *
WHERE {
?source skos:inScheme ?namespaceConceptScheme .
?source rdf:type ?namespaceConceptType .
?source skos:prefLabel ?sourceLabel .
?target rdf:type ?namespaceConceptScheme .
?target skos:prefLabel ?targetLabel .
FILTER (fn:lower-case(?sourceLabel) = fn:lowercase(?targetLabel))
}
-----
Select - With example bindings
PREFIX belv: <http://www.openbel.org/vocabulary/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX fn: <http://www.w3.org/2005/xpath-functions#>
# Bind ?namespaceConceptScheme to the URI of the namespace resource whose concepts you would like equivalenced via concept type and case-insensitive string match.
# Bind ?namespaceConceptType to the URI of the most-specific concept type within ?namespaceConceptScheme. If this isn't provided then concepts will match when they are both Concept, NamespaceConcept, etc.
SELECT *
WHERE {
?source skos:inScheme <http://www.openbel.org/bel/namespace/mesh-processes> .
?source rdf:type <http://www.openbel.org/vocabulary/BiologicalProcessConcept> .
?source skos:prefLabel ?sourceLabel .
?target rdf:type <http://www.openbel.org/vocabulary/BiologicalProcessConcept> .
?target skos:prefLabel ?targetLabel .
FILTER (fn:lower-case(?sourceLabel) = fn:lowercase(?targetLabel))
}
-----
Construct
PREFIX belv: <http://www.openbel.org/vocabulary/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX fn: <http://www.w3.org/2005/xpath-functions#>
# Bind ?namespaceConceptScheme to the URI of the namespace resource whose concepts you would like equivalenced via concept type and case-insensitive string match.
# Bind ?namespaceConceptType to the URI of the most-specific concept type within ?namespaceConceptScheme. If this isn't provided then concepts will match when they are both Concept, NamespaceConcept, etc.
CONSTRUCT {
?source skos:exactMatch ?target .
}
WHERE {
?source skos:inScheme ?namespaceConceptScheme .
?source rdf:type ?namespaceConceptType .
?source skos:prefLabel ?sourceLabel .
?target rdf:type ?namespaceConceptScheme .
?target skos:prefLabel ?targetLabel .
FILTER (fn:lower-case(?sourceLabel) = fn:lowercase(?targetLabel))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment