Skip to content

Commit 902ce8e

Browse files
author
philblackwood
committed
uom data conversion explanation and queries
1 parent c05bf36 commit 902ce8e

29 files changed

+1005
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# sanity check: see if you have found all of the Aspects returned by this query
2+
#
3+
# some possibilities:
4+
#
5+
# - Aspect defined but never used
6+
# - Aspect used by pattern not included in the queries (investigate and write custom queries)
7+
#
8+
select ?possibleAspect
9+
where {
10+
11+
{
12+
?possibleAspect (rdfs:subClassOf|(owl:equivalentClass/owl:intersectionOf/rdf:first))+ gist:Magnitude .
13+
14+
filter(?possibleAspect != gist:ReferenceValue)
15+
}
16+
union
17+
{
18+
?possibleAspect rdfs:subClassOf+ gist:Aspect .
19+
}
20+
21+
}
22+
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# find existing Aspects that are represented as either:
2+
#
3+
# - a property of a Magnitude
4+
# - or the value of a property of a Magnitude
5+
#
6+
# use this query iteratively as follows:
7+
#
8+
# - run the query
9+
# - pick a few lines of output
10+
# - update the upper section of the query with concepts that do NOT involve an Aspect
11+
# - update the lower section of the query (filter not exists) with properties and values that DO represent Aspects
12+
# - repeat
13+
#
14+
# this iterative process accounts for every property and value associated with a Magnitude
15+
# when the query returns no results, every row of the original output has been accounted for
16+
17+
select distinct ?magnitudeProperty ?magnitudePropertyValue
18+
19+
where {
20+
21+
?magnitude gist:hasUnitOfMeasure ?unit ;
22+
?magnitudeProperty ?magnitudePropertyValue ;
23+
.
24+
25+
filter(?magnitudeProperty not in ( # properties that do not involve an Aspect
26+
gist:hasUnitOfMeasure,
27+
gist:numericValue,
28+
skos:definition,
29+
skos:scopeNote,
30+
skos:prefLabel,
31+
rdfs:isDefinedBy
32+
))
33+
34+
filter(?magnitudePropertyValue not in ( # values that do not represent Aspects
35+
gist:Magnitude,
36+
owl:Thing,
37+
owl:NamedIndividual
38+
))
39+
40+
41+
filter not exists {
42+
43+
values (?magnitudeProperty ?magnitudePropertyValue) { # property/value pairs with a property or value that represents an Aspect
44+
45+
(rdf:type gist:Duration) # sample value
46+
}
47+
}
48+
}
49+
order by ?magnitudeProperty ?magnitudePropertyValue
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# find existing Aspects that are represented as either:
2+
#
3+
# - a property of a Thing with a Magnitude or
4+
# - the value of the property
5+
#
6+
# use this query iteratively as follows:
7+
#
8+
# - run the query
9+
# - pick a few lines of output
10+
# - update the upper section of the query with concepts that do NOT involve an Aspect
11+
# - update the lower section of the query (filter not exists) with properties and values that DO represent Aspects
12+
# - repeat
13+
#
14+
# this iterative process accounts for every property and value associated with a Magnitude
15+
# when the query returns no results, every row of the original output has been accounted for
16+
17+
18+
19+
select distinct ?thingProperty ?thingPropertyValue
20+
21+
where {
22+
23+
?magnitude gist:hasUnitOfMeasure ?unit .
24+
25+
?thing gist:hasMagnitude ?magnitude ;
26+
?thingProperty ?thingPropertyValue ;
27+
.
28+
29+
filter(?thingProperty not in ( # properties that do not represent and Aspect and never have a value that represents an Aspect
30+
gist:actualEndMicrosecond,
31+
gist:actualEndMinute,
32+
gist:actualStartAtDate,
33+
gist:actualStartMinute,
34+
gist:conformsTo,
35+
gist:containedText,
36+
gist:description,
37+
gist:hasDirectPart,
38+
gist:hasGoal,
39+
gist:hasMagnitude,
40+
gist:hasPart,
41+
gist:hasPhysicalLocation,
42+
gist:isAffectedBy,
43+
gist:isBasedOn,
44+
gist:isConnectedTo,
45+
gist:isRecognizedBy,
46+
gist:isRecordedAt,
47+
gist:name,
48+
gist:plannedEndDate,
49+
gist:plannedStartDate,
50+
gist:uniqueText,
51+
rdfs:comment,
52+
rdfs:isDefinedBy,
53+
skos:altLabel,
54+
skos:definition,
55+
skos:prefLabel,
56+
skos:scopeNote
57+
58+
))
59+
60+
filter(?thingPropertyValue not in ( # values that do not represent Aspects
61+
62+
gist:Event, # sample value
63+
owl:NamedIndividual,
64+
owl:Thing
65+
))
66+
67+
filter not exists {
68+
69+
values (?thingProperty ?thingPropertyValue) { # property/value pairs with a property or value that represents an Aspect
70+
71+
72+
}
73+
}
74+
}
75+
order by ?thingProperty ?thingPropertyValue
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# find existing Aspects that are represented as a property with a Magnitude as object
2+
# (e.g. hasMass)
3+
#
4+
# use this query iteratively as follows:
5+
#
6+
# - run the query
7+
# - pick a few lines of output
8+
# - update the upper section of the query with properties that do NOT represent an Aspect
9+
# - update the lower section of the query (filter not exists) with properties that DO represent Aspects
10+
# - repeat
11+
#
12+
# this iterative process accounts for every property that has a a Magnitude as object
13+
# when the query returns no results, every row of the original output has been accounted for
14+
15+
16+
select distinct ?thingToMagnitudeProperty
17+
18+
where {
19+
20+
?magnitude gist:hasUnitOfMeasure ?unit .
21+
22+
?thing ?thingToMagnitudeProperty ?magnitude .
23+
24+
filter (?thingToMagnitudeProperty != gist:hasMagnitude) # properties that do not represent an Aspect
25+
26+
filter not exists {
27+
28+
values ?thingToMagnitudeProperty { # properties that represent a Magnitude
29+
30+
}
31+
}
32+
} order by ?thingToMagnitudeProperty
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# find Aspects that are the subject of gist:isAspectOf
2+
3+
select ?aspect
4+
5+
where { ?aspect gist:isAspectOf ?x .}
6+
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# find Aspects that are represented within the name of a Magnitude or Thing with a Magnitude
2+
#
3+
# fill in the upper section from the filter-not-exists conditions of the first 4 queries
4+
#
5+
# the use this query iteratively as follows:
6+
#
7+
# - run the query
8+
# - pick a few lines of output
9+
# - update the lower section of the query with strings embedded in Magnitude IRI or Thing IRI that represent an Aspect
10+
# - repeat
11+
#
12+
# this iterative process accounts for every Magnitude and Thing with a Magnitude
13+
# when the query returns no results, every row of the original output has been accounted for
14+
15+
select distinct ?magnitude ?thing
16+
17+
where {
18+
19+
?magnitude gist:hasUnitOfMeasure ?unit .
20+
21+
optional {?thing gist:hasMagnitude ?magnitude . }
22+
23+
filter not exists {
24+
25+
?magnitude ?magnitudeProperty ?magnitudePropertyValue .
26+
27+
############# copy values from findAspects1.rq ###################
28+
values (?magnitudeProperty ?magnitudePropertyValue) { # pairs where the property or the value represents a Magnitude
29+
30+
(rdf:type gist:Duration) # sample value
31+
32+
}
33+
34+
####################################################
35+
36+
}
37+
38+
filter not exists { # filter out things for which an Aspect has been identified
39+
40+
?thing ?thingProperty ?thingPropertyValue .
41+
42+
############## copy values from findAspects2.rq ###################
43+
values (?thingProperty ?thingPropertyValue) { # more pairs with a property or value that represents an Aspect
44+
45+
}
46+
####################################################
47+
}
48+
49+
filter not exists { # filter out properties that represent an Aspect and have a Magnitude as object
50+
51+
?thing ?thingToMagnitudeProperty ?magnitude .
52+
53+
############## copy from findAspects3.rq ###################
54+
values ?thingToMagnitudeProperty {
55+
56+
}
57+
####################################################
58+
}
59+
60+
filter not exists { # filter out cases where an Aspect has the property gist:isAspectOf
61+
62+
{?aspect gist:isAspectOf ?magnitude .} union {?aspect gist:isAspectOf ?thing.}
63+
64+
############## copy from findAspects4.rq ###################
65+
values ?aspect {
66+
67+
}
68+
####################################################
69+
}
70+
71+
72+
# in this section, include substrings of a Magnitude IRI or Thing IRI that represent an Aspect
73+
#########################################################################################################
74+
75+
filter(!contains(str(?magnitude), "abc")) # embedded strings that indicate an Aspect
76+
77+
filter(!contains(str(?thing), "xyz"))
78+
79+
#########################################################################################################
80+
}
81+
order by ?magnitude ?thing
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# find Magnitudes with no gist:hasAspect
2+
3+
select ?magnitude
4+
5+
where {
6+
7+
?magnitude gist:hasUnitOfMeasure ?unit .
8+
9+
filter not exists {?magnitude gist:hasAspect ?anything .}
10+
11+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# find subclasses of Magnitude that represent Aspects
2+
# note: the subclass ReferenceValue does not represent an Aspect
3+
#
4+
# use the output to customize the values list of removeSubclassesOfMagnitude
5+
6+
select distinct ?subclass
7+
8+
where {
9+
10+
?subclass (rdfs:subClassOf|(owl:equivalentClass/owl:intersectionOf/rdf:first))+ gist:Magnitude .
11+
filter(?subclass != gist:ReferenceValue)
12+
13+
}
14+
order by ?subclass
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# find subclasses of Unit of Measure
2+
#
3+
# use the output to customize the values list of removeSubclassesOfUnitOfMeasure
4+
5+
select distinct ?subclass
6+
7+
where {
8+
9+
?subclass (rdfs:subClassOf|(owl:equivalentClass/owl:intersectionOf/rdf:first))+ gist:UnitOfMeasure .
10+
11+
}
12+
order by ?subclass
13+
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# insert new Aspects into the graph, where the old Aspect was represented as a property of a Magnitude, or its value
2+
3+
# test
4+
select distinct ?magnitude ?aspect ?newAspect
5+
# select distinct ?magnitude ?magnitudeProperty ?magnitudePropertyValue ?newAspect
6+
# select distinct ?magnitude ?magnitudeProperty ?newAspect
7+
8+
# insert { ?magnitude gist:hasAspect ?newAspect . }}
9+
10+
where {
11+
12+
?magnitude gist:hasUnitOfMeasure ?unit ;
13+
?magnitudeProperty ?magnitudePropertyValue ;
14+
.
15+
16+
filter not exists {?magnitude gist:hasAspect ?anything . } # to prevent duplicates (idempotent)
17+
18+
{
19+
################ copy ?magnitudePropertyValue from findAspects1, and add new Aspect #################
20+
values (?magnitudePropertyValue ?newAspect) {
21+
22+
(gist:Duration gistd:_Aspect_duration) # sample value
23+
}
24+
25+
##################################################
26+
27+
bind(?magnitudePropertyValue as ?aspect)
28+
}
29+
30+
union
31+
{
32+
################ copy ?magnitudeProperty from findAspects1, and add new Aspect #################
33+
values (?magnitudeProperty ?newAspect) {
34+
35+
}
36+
##################################################
37+
38+
bind(?magnitudeProperty as ?aspect)
39+
}
40+
41+
}
42+
order by ?magnitude ?newAspect

0 commit comments

Comments
 (0)