Skip to content

Instantly share code, notes, and snippets.

@danizen
Created December 29, 2020 20:00
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 danizen/8975c279b304ff35a90e5e986a86e7c2 to your computer and use it in GitHub Desktop.
Save danizen/8975c279b304ff35a90e5e986a86e7c2 to your computer and use it in GitHub Desktop.
Non-authorized mechanism to export/convert MeSH RDF to SKOs
prefixes: |
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX meshv: <http://id.nlm.nih.gov/mesh/vocab#>
PREFIX mesh: <http://id.nlm.nih.gov/mesh/>
PREFIX meshsv: <http://id.nlm.nih.gov/mesh/skos/>
tree:
preamble: |
meshsv:Tree rdf:type owl:Ontology ;
rdf:type skos:ConceptScheme ;
rdfs:comment "MESH Tree As SKOS" ;
rdfs:label "Dan's MESH Tree" ;
owl:imports <http://www.w3.org/2004/02/skos/core> ;
owl:versionInfo "0.1" .
count:
SELECT (COUNT(?resource) as ?count)
FROM <http://id.nlm.nih.gov/mesh>
WHERE {
?resource a meshv:TreeNumber .
?resource meshv:active "true"^^xsd:boolean .
}
roots:
SELECT ?resource ?label
FROM <http://id.nlm.nih.gov/mesh>
WHERE {
?resource a meshv:TreeNumber .
?resource meshv:active "true"^^xsd:boolean .
?resource rdfs:label ?llabel .
BIND(STR(?llabel) AS ?label) .
MINUS {
?resource meshv:parentTreeNumber ?parent .
}
}
ORDER BY ?resource
kids: |
SELECT ?resource ?label
FROM <http://id.nlm.nih.gov/mesh>
WHERE {
?resource a meshv:TreeNumber .
?resource meshv:active "true"^^xsd:boolean .
?resource rdfs:label ?llabel .
BIND(STR(?llabel) AS ?label) .
?resource meshv:parentTreeNumber ?parent .
}
ORDER BY ?resource
topical:
preamble:
meshsv:Topical rdf:type owl:Ontology ;
rdf:type skos:ConceptScheme ;
rdfs:comment "MESH Topical Descriptors as SKOS" ;
rdfs:label "Dan's MESH Topical Descriptors" ;
owl:imports <http://www.w3.org/2004/02/skos/core> ;
owl:versionInfo "0.1" .
count:
SELECT (COUNT(?resource) as ?count)
FROM <http://id.nlm.nih.gov/mesh>
WHERE {
?resource a meshv:TopicalDescriptor .
?resource meshv:active "true"^^xsd:boolean .
}
roots:
SELECT ?resource ?label
FROM <http://id.nlm.nih.gov/mesh>
WHERE {
?resource a meshv:TopicalDescriptor .
?resource meshv:active "true"^^xsd:boolean .
?resource rdfs:label ?llabel .
BIND(STR(?llabel) AS ?label) .
MINUS {
?resource meshv:broaderDescriptor ?parent .
}
}
ORDER BY ?resource
kids: |
SELECT ?resource ?label
FROM <http://id.nlm.nih.gov/mesh>
WHERE {
?resource a meshv:TopicalDescriptor .
?resource meshv:active "true"^^xsd:boolean .
?resource rdfs:label ?llabel .
BIND(STR(?llabel) AS ?label) .
?resource meshv:broaderDescriptor ?parent .
}
ORDER BY ?resource
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment