Riccardo Tommasini edited this page May 8, 2018 · 10 revisions

Vocal Examples


The following list map different ontologies to the prefix used to refere to them.

@base         : <http://www.example.org/vocals/examples#>
@prefix owl       : <http://www.w3.org/2002/07/owl#>
@prefix rdf       : <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
@prefix xml       : <http://www.w3.org/XML/1998/namespace>
@prefix xsd       : <http://www.w3.org/2001/XMLSchema#>
@prefix rdfs      : <http://www.w3.org/2000/01/rdf-schema#>
@prefix dcat      : <http://www.w3.org/ns/dcat>
@prefix time      : <http://www.w3.org/2006/time#>
@prefix frmt      : <http://www.w3.org/ns/formats/>
@prefix prov      : <http://www.w3.org/ns/prov#>
@prefix sao       : <http://purl.oclc.org/NET/UNIS/sao/sao#>
@prefix vsd       : <http://w3id.org/rsp/vocals-sd#>
@prefix vprov     : <http://w3id.org/rsp/vocals-prov#>
@prefix vocals    : <http://w3id.org/rsp/vocals#>
@prefix frGrid    : <http://streamreasoning.org/frappe/Grids/> 
@prefix frCell    : <http://streamreasoning.org/frappe/Cells/>  
@prefix frPixel   : <http://streamreasoning.org/frappe/Pixels/>  
@prefix frPlace   : <http://streamreasoning.org/frappe/Places/>  
@prefix frEvent   : <http://streamreasoning.org/frappe/Events/>  
@prefix frFrame   : <http://streamreasoning.org/frappe/Frames/>  
@prefix frCapture : <http://streamreasoning.org/frappe/Captures/> 

1- Using VoCaLS Core to describe RDF Stream

The following block of code shows how could VoCaLS Core module be used to provide metadata about the stream and different endpoints available for consumption.

In this example, VoCaLS Core module is used to descirbe :MilanTrafficStream, an RDF stream that is derived from other streams produced by traffic sensors spread around the city. :MilanTrafficStreamDescriptor is a document holding metadata describing :MilanTrafficStream, continously updated as the stream changes.

Avaialble endpoints can be attached to streams using vocals:hasEndpoint to reference vocals:StreamEndpoint, where each vocals:StreamEndpoint is equivalent to a vocals:StreamDistribution and can have different properties

:MilanTrafficStreamDescriptor a vocals:StreamDescriptor , vsd:CatalogService ;
	dcat:dataset :MilanTrafficStream .

:MilanTrafficStream a vocals:RDFStream ;
	dct:title "Milan Traffic Stream"^^xsd:string ;
	dct:description "Aggregated stream of different streams produced by traffic sesnors spread around Milan"^^xsd:string ;
    dct:publisher :TrafficStreamPublisher ;
    dcat:landingPage <https://example.org/traffic/milan/> ;
	vocals:hasEndpoint :MilanTrafficStreamEndpoint .

:MilanTrafficStreamEndpoint a vocals:StreamEndpoint ;
	dct:title "Milan Traffic Stream Endpoint"^^xsd:string ;
	dct:description "Streaming endpoint to consume Milan Traffic Stream via websocket"^^xsd:string ;
	dct:license <https://creativecommons.org/licenses/by-nc/4.0/> ;
	dct:format frmt:JSON-LD ;
	dcat:accessURL "ws://example.org/traffic/milan".

As illustrated in the previous code listing, the following questions can be easily answered:

  • What is the identifier/address of a stream?
SELECT ?stream
    ?stream a vocals:Stream .
  • Which are the alternative channels to access the stream?
SELECT ?endpoint
    ?stream a vocals:Stream ; vocals:hasEndpoint ?endpoint .
    FILTER(?stream = :MilanTrafficStream)
  • Who created, maintains and/or publishes the stream?
SELECT ?publisher 
    ?stream a vocals:Stream ; dct:publisher ?publisher .
    FILTER(?stream = :MilanTrafficStream)

2- Using VoCaLS Provenance to track the provenance of an RDF Stream

Back to our Milan traffic stream, the following listing shows and provide a good description of how the :MilanTrafficStream was created and how does it evolve.

:MilanTafficStream is constructed by aggregation different streams produced by traffic sensors spread around the city, the process of is represented as a vprov:Task, which contains a sequence of vprov:Operators.

More in details, the :AggregationTask consist of sequence vprov:Operators: (i):WindowOp1 and :WindowOp2 representing operators producing the windows on smaller stream, producing a couple of windows :W1 & :W2, followed by the (ii) :AlgebraicOp which is applied to both windows producing a vocals:FiniteStatePartition which is then fed to (iii) :R2SOp to produce the stream.

:CentraleTrafficStream a vocals:RDFStream .
:CardornaTrafficStream a vocals:RDFStream .
:AggregationTask a vprov:Task ;
	vprov:contains  :WindowOp1 ;
	vprov:contains  :WindowOp2 ;
	vprov:contains  :AlgebraicOp ;
	vprov:hasOutput :MilanTafficStream .
:WindowOp1 a vprov:S2ROperator ;
	prov:uses :CentraleTrafficStream ;
	vprov:hasStep  "2" ;
	vprov:hasStartingTime :instant1 ;
	vprov:hasUnit time:unitMinute . 
:WindowOp2 a vprov:S2ROperator ;
	prov:uses :CardornaTrafficStream ;
	vprov:hasStep  "2" ;
	vprov:hasStartingTime :instant1 ;
	vprov:hasUnit time:unitMinute . 
:AlgebraicOp a vprov:R2ROperator ;
	prov:uses :W1 ;
	prov:uses :W2 ;
	vprov:precededBy :WindowOp1 ;
	vprov:precededBy :WindowOp2 .
:instant1 a time:Instant ; time:inXSDDateTimeStamp  2017-04-12T10:30:00+00:00.
:instant2 a time:Instant ; time:inXSDDateTimeStamp  2017-04-12T10:32:00+00:00.
:W1 a vsd:Window ; 
	prov:wasGeneratedBy :WindowOp1 ;
	vsd:namedGraph :G11 , :G12 ;
	vsd:startedAt :instant1 ;
	vsd:endedAt :instant2 . 
:W2 a vsd:Window ; 
	prov:wasGeneratedBy :WindowOp2 ;
	vsd:namedGraph :G21 , :G22 ;
	vsd:startedAt :instant1 ;
	vsd:endedAt :instant2 . 
:R1 a vocals:FiniteStatePartition ;
	prov:wasGeneratedBy :AlgebraicOp .
:R2SOp a vprov:R2sOperator ; 
	prov:uses :R1  ;
	vprov:precededBy :AlgebraicOp .
:MilanTafficStream a vocals:RDFStream ;
	prov:wasGeneratedBy :R2SOp .

This listing shows, which streams where used to derive :MilanTafficStream, which operators where used to process :CentraleTrafficStream and :CardornaTrafficStream

With VoCaLS Provenance modules, we can answer questions about the provenance of the stream, such as

  • How can we describe the process that generated stream?
SELECT ?task ?operator 
    ?stream a vocals:Stream .
    ?task a vprov:Task; vprov:hasOutput ?stream ; vprov:contains ?operator.
    FILTER(?stream = :MilanTrafficStream)
  • How can we describe the process that generated stream windows?
SELECT ?window ?operator 
    ?window a vsd:Window ; prov:wasGeneratedBy ?operator .
    ?operator a vprov:WindowOperator .
    FILTER(?window = :w1)
  • Which datasets or streams were used to derive the stream?
SELECT ?ds  
    ?task a vprov:Task; vprov:hasOutput ?stream ; vprov:contains ?operator.
    ?operator prov:uses ?ds .
    FILTER(?stream = :MilanTrafficStream)

3- Using VoCaLS Service Descriptor to describe service an RDF Stream

As shown in the below listing, VoCaLS Service Descriptor is used to descibe streaming services, there capabilities as well as relating streams to service

:MilanTrafficStream is processed and produced by :RSPEngine which is a vsd:ProcessingService, on the other hand :CadornaTrafficStream is published by a :TripleWave a vsd:PublishingService.

For each of the services defined, a list of features are defined, which make easier to discover and select service.

:MilanTrafficStream vsd:registeredBy :RSPEngine .
:CadornaTrafficStream vsd:publishedBy :Triplewave .
:RSPEngine a vsd:ProcessingService ; 
	vsd:hasFeature vsd:event_time ;
	vsd:hasFeature vsd:internal_time_controll ;
	vsd:hasFeature vsd:periodic ;
	vsd:hasFeature vsd:filtering ;
	vsd:hasFeature vsd:windowing ;
	vsd:availableGraphs :G11 , :G21 ;
	vsd:resultFormat frmt:N3 ; 
	vsd:rspEndpoint "http://example.org/rspEndpoint" .

:Triplewave a vsd:PublishingService ; 
	vsd:hasFeature vsd:replaying ;
	vsd:hasFeature vsd:filtering ;
	vsd:hasFeature vsd:union ;
	vsd:hasFeature vsd:external_time_control ;
	vsd:resultFormat frmt:JSON-LD . 

With VoCaLS Service Descriptor module, we can answer to question like

  • What are the available streaming services?
SELECT ?service  
    ?service a vsd:StreamingService .
  • What are the capabilities/features of a streaming service?
SELECT ?service  ?feature
    ?service a vsd:StreamingService ; vsd:hasFeature ?feature.
  • Which service describe, publish and/or register a stream ?
SELECT ?service 
    ?service a vsd:StreamingService .
    ?stream a vocals:Stream ; vsd:registeredBy ?service .
    FILTER(?stream = :MilanTrafficStream)

4- VoCaLS + SSN + SAO

In this example, we will show how can we use VoCaLS to describe a stream generated by a sensor described with SSN ontology.

  gs:sfContains frCell:Cell_1 .

  a fr:Cell ;
  rdfs:label "12345"^^xsd:long ; 
  fr:isReferredBy frPixel:1356995100000_12345 ; 
  gs:sfContains frPlace:A ;
  gs:sfWithin frGrid:Grid_1 .

  a sf:Point ;
  fr:isLocationOf frEvent:E_B ;
  gs:asWKT "POINT( 40.715008 -73.96244 )"^^gs:wktLiteral ; 
  gs:sfWithin frCell:Cell_1 .

:TrafficFlow a ssn:Property .

:TrafficFlowSensing a ssn:sensing , sao:StreamEvent ;
    prov:used :CadornaTrafficFlow
    ssn:hasOutput :CadornaTrafficStream.

:CadornaTrafficSensor a ssn:SensingDevice ; 
    ssn:observes :TrafficFlow ;
    ssn:implements :TrafficFlowSensing .

:CadornaTrafficSensorOutput a ssn:SensorOutput .

:CadornaTrafficFlow a ssn:ObservationValue, sao:StreamData
    prov:wasDerivedFrom :CadornaTrafficObservation .

:CadornaTrafficObservation a ssn:Observation, vsd:TimeVaryingGraph, event:Event ; 
    ssn:observedProperty :TrafficFlow ;
    ssn:observationResult :CadornaTrafficSensorOutput ;event:time [ 
    a time:Instant ;
    time:inXSDDateTime "2013-01-01T00:00:00"^^xsd:dateTime ] ; 
    fr:location frPlace:A> .

  a fr:Pixel ; 
  fr:isIn frFrame :1356995100000 ; 
  fr:refers frCell:Cell_1 .

frFrame :1356995100000
  a fr:CapturedFrame ;
  fr:contains frPixel:1356995100000_12345 ; 
  fr:samplingTime [ 
    a time:Instant ;
    time:inXSDDateTime "2013-01-01T00:05:00"^^xsd:dateTime ]; 
  fr:wasCapturedFrom frGrid:Grid_1 ;
  prov:wasGeneratedBy frCapture:1356995100000 .

:CadornaTrafficStream a ssn:Output, vocals:Stream .

As anticipated above, we used VoCaLS to describe :CadornaTrafficStream that was generated by :CadornaTrafficSensor. With every new observation, a new sao:StreamData is created which is then used by sao:StreamEvent to flow in the stream.

With such integration, sensor can publish vocals:StreamDescriptor to offer needed metadata about the observations they sensing and how can consumer use them.

For sure this example is missing a lot of metadata about the sensor capabilities and properties, however it is ignored here as it won't have any affect on the integration with vocals.

Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.