-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path10_findNarrowestWithoutNarrowerStatements.sparql
35 lines (27 loc) · 1.6 KB
/
10_findNarrowestWithoutNarrowerStatements.sparql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#this query will find all the concepts that do not have narrower(child) concepts when using a conceptScheme that only explicitly declares skos:broader relationships.
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
#Display everything available from the query
SELECT *
WHERE {
#Define the Primary Subject: return all skos Concepts and use the ?prefix to label them concepturi
?concepturi a skos:Concept ;
#Inclue skos:preflabels that relate directly to each Concept. ";" breaks each line
skos:prefLabel ?preflabel ;
#specify which vocabulary scheme the concepts belong to. Use '.' to close this subject within the query.
skos:inScheme <http://linked.data.gov.au/def/geo-commodities> .
#Set Optional returns (to ignore sparql null rule), i.e. return blank instead of preventing result
OPTIONAL {?concepturi skos:definition ?definition}. #optional definitions
OPTIONAL {?concepturi skos:notation ?notation} . #optional notations
#Apply filters and exceptions
# from the above query remove (MINUS) all the results from the following query
MINUS {SELECT
?broaderuri #select all concepts in the knowledge graph as broaderuri
?concepturi #that have skos:broader concepts. But call all the broader concepts concepturi to make the equivalent to the main query so they can be MINUSed from the main query.
WHERE
{?broaderuri a skos:Concept ;
skos:broader ?concepturi .
}}
#in effect, get all the concepts in the target conceptScheme then remove all the concepts that are a skos:broader concept to any other concept.
}
#Display in order of: the uri of the concept
ORDER BY ?concepturi