-
Notifications
You must be signed in to change notification settings - Fork 0
/
SIMON SPARQL.txt
92 lines (80 loc) · 3.37 KB
/
SIMON SPARQL.txt
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#Queries for SIMON: SImple Measurement Ontology
#All queries should have the following prefixes:
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX sm: <http://www.semanticweb.org/michaeldebellis/ontologies/2021/0/measurement#>
#Displays all the instances of the Measurement class using the label
#Note: this will only work after running the SWRL rules and SPARQL transforms
SELECT ?mlbl
WHERE {?m a sm:Measurement;
rdfs:label ?mlbl.}
#Creates formatted string names for SingleUnitMeasurement instances
#Note: this and the following two transforms require that the SWRL
#rules have been run in Protege
#This and the other queries with CONSTRUCT can be used in the Protege Snap SPARQL view
CONSTRUCT {?m rdfs:label ?mname.}
WHERE {?m a sm:SingleUnitMeasurement;
sm:hasUnit1 ?u1;
sm:hasMeasuredValue ?mv.
?u1 sm:pluralName ?pn.
BIND (CONCAT(xsd:string(?mv)," ",?pn) AS ?mname). }
#Creates formatted string names for DoubleUnitMeasurement instances
CONSTRUCT {?m rdfs:label ?mname.}
WHERE {?m a sm:DoubleUnitMeasurement;
sm:hasUnit1 ?u1;
sm:hasUnit2 ?u2;
sm:hasMeasurement ?m1.
?u1 sm:pluralName ?pn.
?u2 rdfs:label ?u2lbl.
?m1 sm:hasMeasuredValue ?mv.
BIND (CONCAT(xsd:string(?mv)," ",?pn," per ",?u2lbl) AS ?mname).}
#Creates formatted string names for TripleUnitMeasurement instances
CONSTRUCT {?m rdfs:label ?mname.}
WHERE {?m a sm:TripleUnitMeasurement;
sm:hasUnit1 ?u1;
sm:hasUnit2 ?u2;
sm:hasUnit3 ?u3;
sm:hasMeasurement ?m2.
?u1 sm:pluralName ?pn.
?u2 rdfs:label ?u2lbl.
?m2 sm:hasMeasurement ?m1.
?u3 rdfs:label ?u3lbl.
?m1 sm:hasMeasuredValue ?mv.
BIND (CONCAT(xsd:string(?mv)," ",?pn," per ",?u2lbl," per ",?u3lbl) AS ?mname).}
#Creates formatted string names for SingleUnitMeasurement instances
#Note: this and the following two transforms require that the SWRL
#rules have been run in Protege and the results saving using Export
#Inferred Axioms as Ontology
#The following queries are the same as the previous ones except they use INSERT
#Since INSERT is currently not supported by any Protege SPARQL tools these need
#to be run in some other environment such as the Gruff SPARQL view in AllegroGraph
INSERT {?m rdfs:label ?mname.}
WHERE {?m a sm:SingleUnitMeasurement;
sm:hasUnit1 ?u1;
sm:hasMeasuredValue ?mv.
?u1 sm:pluralName ?pn.
BIND (CONCAT(xsd:string(?mv)," ",?pn) AS ?mname). }
#Creates formatted string names for DoubleUnitMeasurement instances
INSERT {?m rdfs:label ?mname.}
WHERE {?m a sm:DoubleUnitMeasurement;
sm:hasUnit1 ?u1;
sm:hasUnit2 ?u2;
sm:hasMeasurement ?m1.
?u1 sm:pluralName ?pn.
?u2 rdfs:label ?u2lbl.
?m1 sm:hasMeasuredValue ?mv.
BIND (CONCAT(xsd:string(?mv)," ",?pn," per ",?u2lbl) AS ?mname).}
#Creates formatted string names for TripleUnitMeasurement instances
INSERT {?m rdfs:label ?mname.}
WHERE {?m a sm:TripleUnitMeasurement;
sm:hasUnit1 ?u1;
sm:hasUnit2 ?u2;
sm:hasUnit3 ?u3;
sm:hasMeasurement ?m2.
?u1 sm:pluralName ?pn.
?u2 rdfs:label ?u2lbl.
?m2 sm:hasMeasurement ?m1.
?u3 rdfs:label ?u3lbl.
?m1 sm:hasMeasuredValue ?mv.
BIND (CONCAT(xsd:string(?mv)," ",?pn," per ",?u2lbl," per ",?u3lbl) AS ?mname).}