Skip to content

Commit 908f3ed

Browse files
Merge pull request #10 from KNowledgeOnWebScale/json
spec: use JSON instead
2 parents 5f9241d + 4425bb9 commit 908f3ed

File tree

1 file changed

+47
-26
lines changed

1 file changed

+47
-26
lines changed

spec.bs

Lines changed: 47 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ Repository: KNowledgeOnWebScale/rdf-timeseriessnippets
88
URL: https://knowledgeonwebscale.github.io/rdf-timeseriessnippets/
99
Editor: Dylan Van Assche, https://dylanvanassche.be/#me
1010
Editor: Pieter Colpaert, https://pietercolpaert.be
11-
Abstract: An RDF Time Series Snippet is a segment of data points from a time series dataset, typically used for analysis or visualization. The specification uses [SPARQL Common Data Types](https://awslabs.github.io/SPARQL-CDTs/spec/latest.html) coined by AWS Lab to encode the data points in a values literal. The entity can then be used for annotating this snippet, which is a time interval subset of a potentially larger time series.
11+
Abstract: An RDF Time Series Snippet is a segment of data points from a time series dataset, typically used for analysis or visualization. The specification uses JSON to store the data points to allow re-usability of existing tooling for analyzing time series. The entity can then be used for annotating this snippet, which is a time interval subset of a potentially larger time series.
1212
Markup Shorthands: markdown yes, css no
1313
</pre>
1414

1515
# Introduction # {#intro}
1616

1717
Sensor observations, positioning data, measurements, mobility information... are commonly published as Time Series data with a timestamp and a value.
1818
Representing Time Series data in RDF drastically raises the verbosity, as each data point is often given its own identifier, for which contextual information is repeated on all data points.
19-
With Time Series Snippets, we allow a data publisher to compact the data points in subsets of a Time Series, called the Snippet, by using [SPARQL Common Data Types](https://awslabs.github.io/SPARQL-CDTs/spec/latest.html) such as `cdt:List` and `cdt:Map`.
19+
With Time Series Snippets, we allow a data publisher to compact the data points in subsets of a Time Series, called the Snippet with JSON objects, allowing to re-use existing tooling for analyzing time series.
2020
This way, you can greatly reduce the amount of triples when describing a Time Series.
2121

2222
Time Series Snippets use the following prefix and namespace:
@@ -32,16 +32,27 @@ A first example illustrates the features of a `tss:Snippet`:
3232
<snippet/2026-01-01>
3333
a tss:Snippet;
3434
tss:points """[
35-
{ "time": "2026-01-01T06:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime>, "value": "5.4"^^<http://www.w3.org/2001/XMLSchema#double>, "id": "https://example.org/0"},
36-
{ "time": "2026-01-01T06:59:59Z"^^<http://www.w3.org/2001/XMLSchema#dateTime>, "value": "5.2"^^<http://www.w3.org/2001/XMLSchema#double>, "id": "https://example.org/1"},
37-
{ "time": "2026-01-01T08:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime>, "value": "5.2"^^<http://www.w3.org/2001/XMLSchema#double>, "id": "https://example.org/2"},
38-
{ "time": "2026-01-01T09:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime>, "value": "6.1"^^<http://www.w3.org/2001/XMLSchema#double>, "id": "https://example.org/3"},
39-
]"""^^cdt:List;
35+
{ "time": "2026-01-01T06:00:00Z", "value": "5.4", "id": "https://example.org/0"},
36+
{ "time": "2026-01-01T06:59:59Z", "value": "5.2", "id": "https://example.org/1"},
37+
{ "time": "2026-01-01T08:00:00Z", "value": "5.2", "id": "https://example.org/2"},
38+
{ "time": "2026-01-01T09:00:00Z", "value": "6.1", "id": "https://example.org/3"},
39+
]"""^^rdf:JSON;
4040
tss:from "2026-01-01T00:00:00Z"^^xsd:dateTime;
4141
tss:until "2026-01-02T00:00:00Z"^^xsd:dateTime;
4242
tss:pointType sosa:Observation;
43-
tss:timePath sosa:resultTime;
44-
tss:valuePath sosa:hasSimpleResult;
43+
tss:context """{
44+
"@context":{
45+
"time": {
46+
"@id":"http://www.w3.org/ns/sosa/resultTime",
47+
"@type":"http://www.w3.org/2001/XMLSchema#dateTime"
48+
},
49+
"value": {
50+
"@id":"http://www.w3.org/ns/sosa/simpleValue",
51+
"@type":"http://www.w3.org/2001/XMLSchema#integer"
52+
},
53+
"id": "@id"
54+
}
55+
}"""^^rdf:JSON;
4556
tss:about [
4657
sosa:madeBySensor <temp_sensor_1>;
4758
sosa:observedProperty <temperature>;
@@ -97,45 +108,55 @@ A <dfn>Data Point</dfn> is a single point of a [=Time Series=] containing an ISO
97108

98109
Each [=Snippet=] SHOULD have the following properties:
99110

100-
- `tss:points`: a `cdt:List` of data points where each data point is a `cdt:Map` with a `time` key using `xsd:dateTime` value, with a `value` key for which the value is annotated with a datatype, and optionally an `id` key for which the value is an IRI for the current data point.
111+
- `tss:points`: a JSON array (datatype `rdf:JSON`) of data points where each data point is a JSON object with a `time` key using `xsd:dateTime` value, with a `value` key for which the value is annotated with a datatype, and optionally an `id` key for which the value is an IRI for the current data point.
101112
- `tss:from`: starting timestamp (including) of the period covered by `tss:points` using an `xsd:dateTime`.
102113
- `tss:until`: until this timestamp (excluding) of the period covered by `tss:points` using an `xsd:dateTime`.
103114
- `tss:about`: contains statements about a blank node. The statements can be asserted on top of all data points in `tss:points` when expanding the Snippet.
104115
- `tss:pointType`: the RDF type of all data points in `tss:points`.
105-
- `tss:timePath`: the path to use for expanding the `time` property in `tss:points`.
106-
- `tss:valuePath`: the path to use for expanding the `value` property in `tss:points`.
116+
- `tss:context`: JSON-LD context describing the JSON array of `tss:points`.
107117

108-
Issue: Discuss whether these properties are required or optional. E.g., a publisher might decide to do a lossy conversion for their goal, and not include valuePath, pointType and timePath. However, we can still analyze and visualize the data without that information.
118+
Issue: Discuss whether these properties are required or optional. E.g., a publisher might decide to do a lossy conversion for their goal, and not include a JSON-LD context or pointType. However, we can still analyze and visualize the data without that information.
109119

110120
## Data Points ## {#points}
111121

112-
`tss:points` MUST have a `cdt:List` as datatype. Each [=Data Point=] itself MUST be a `cdt:Map` consisting
113-
of 2 required properties and 1 optional property:
122+
`tss:points` MUST be a JSON array with JSON objects (`rdf:JSON` as datatype).
123+
Each [=Data Point=] itself MUST be a JSON object consisting of 2 required properties and 1 optional property:
114124
- `time`: the timestamp of the data point using an `xsd:dateTime`.
115125
- `value`: the value of the data point with corresponding datatype.
116126
- `id`: the data point identifier is optionally. When set, this MUST be a named node.
117127

118128
<div class="example" id="ex_points">
119129
```turtle
120-
[
121-
{ "time": "2026-01-01T06:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime>, "value": "5.4"^^<http://www.w3.org/2001/XMLSchema#double>, "id": "https://example.org/0" },
122-
{ "time": "2026-01-01T06:59:59Z"^^<http://www.w3.org/2001/XMLSchema#dateTime>, "value": "5.2"^^<http://www.w3.org/2001/XMLSchema#double>, "id": "https://example.org/1" },
123-
{ "time": "2026-01-01T08:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime>, "value": "5.2"^^<http://www.w3.org/2001/XMLSchema#double>, "id": "https://example.org/2" },
124-
{ "time": "2026-01-01T09:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime>, "value": "6.1"^^<http://www.w3.org/2001/XMLSchema#double>, "id": "https://example.org/3" },
125-
]
130+
"""[
131+
{ "time": "2026-01-01T06:00:00Z", "value": "5.4", "id": "https://example.org/0" },
132+
{ "time": "2026-01-01T06:59:59Z", "value": "5.2", "id": "https://example.org/1" },
133+
{ "time": "2026-01-01T08:00:00Z", "value": "5.2", "id": "https://example.org/2" },
134+
{ "time": "2026-01-01T09:00:00Z", "value": "6.1", "id": "https://example.org/3" },
135+
]"""^^rdf:JSON;
126136
```
127137
</div>
128138

129139
## Expanding data points ## {#expanding}
130140

131-
When `tss:timePath` and `tss:valuePath` are set (mind this is not required), a [=Snippet=] can be expanded to a verbose RDF representation, for example using its original vocabulary.
141+
When the optional JSON-LD context is provided through `tss:context`, a [=Snippet=] can be expanded to a verbose RDF representation, for example using its original vocabulary as defined in the JSON-LD specification to transform JSON-LD into RDF quads. The following default JSON-LD context is used if no context is specified:
142+
143+
```json
144+
{
145+
"@context": {
146+
"id": "@id",
147+
"time": {
148+
"@id": "https://w3id.org/tss#time",
149+
"@type":"http://www.w3.org/2001/XMLSchema#dateTime"
150+
},
151+
"value": "https://w3id.org/tss#value"
152+
}
153+
}
154+
```
132155
The properties `tss:about` and `tss:pointType` will influence that process.
133156

134157
For each [=Data Point=], it can be mapped as follows:
135158
1. When the `id` is set and it is a valid IRI, set this id as the subject. If it is not, create a new blank node and set this as the subject.
136159
2. When `tss:pointType` is set, create a triple stating this id is of `rdf:type` the object of the pointType triple.
137-
3. Create a triple for the time based on the `tss:timePath`. For unknown intermediary named nodes, a blank node is to be created.
138-
4. Similarly, create a triple for the value based on the `tss:valuePath`.
160+
3. Create a triple for the time based on the JSON-LD context. For unknown intermediary named nodes, a blank node is to be created.
161+
4. Similarly, create a triple for the value based on the JSON-LD context.
139162
5. Now apply the `tss:about` blank node entity to this point.
140-
141-
Issue: Discuss whether a SHACL Path makes sense to use as the intermediary steps will be mapped to blank nodes. Probably we could simplify here and make this a `tss:timeProperty` instead?

0 commit comments

Comments
 (0)