Commit a74242b2 authored by Maxime Lefrançois's avatar Maxime Lefrançois
Browse files

added commodities pattern in saref-core

parent f8fec858
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -5,6 +5,8 @@ saref:
    - Electricity
    - Gas
    - Water

saref-patterns:
  property_classes:
    - name: Energy
      comment: A saref:Property related to some measurements that are characterized by a certain value measured in an energy unit (such as Kilowatt_Hour or Watt_hour). Furter specializations of the saref:Energy class can be found in the SAREF4ENER extension, where classes such as EnergyMax, EnergyMin and EnergyExpected are defined. 
+4 −0
Original line number Diff line number Diff line
# Commodities

The SAREF ontology reference pattern `Commodities` defines the saref:Commodity class and its subclasses.
+14 −0
Original line number Diff line number Diff line
@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 foaf: <http://xmlns.com/foaf/0.1/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix saref: <https://saref.etsi.org/core/> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix vann: <http://purl.org/vocab/vann/> .
@base <https://saref.etsi.org/core/> .

saref:Commodity rdf:type owl:Class ;
    rdfs:comment "A marketable item for which there is demand, but which is supplied without qualitative differentiation across a market. SAREF refers to energy commodities such as electricity, gas, coal and oil. "@en ;
    rdfs:label "Commodity"@en .
+9 −0
Original line number Diff line number Diff line
PREFIX owl:   <http://www.w3.org/2002/07/owl#>
PREFIX rdfs:  <http://www.w3.org/2000/01/rdf-schema#>
PREFIX saref: <https://saref.etsi.org/core/>
SELECT * WHERE {
 ?commodity a owl:Class ;
   rdfs:subClassOf saref:Commodity ;
   rdfs:label ?label ;
   rdfs:comment ?comment .
}
 No newline at end of file
+19 −0
Original line number Diff line number Diff line
from saref_patterns import SAREF, check_patterns
from rdflib import Graph, Literal, RDF, RDFS, OWL

schema = {
    'description': 'The name of the commodity. Will be used as the local name of the IRI and the label',
    'title': 'label',
    'type': 'string'
}

def specialize(namespace, execution):
    g = Graph()
    g.add((namespace[execution], RDF.type, OWL.Class))
    g.add((namespace[execution], RDFS.subClassOf, SAREF.Commodity))
    g.add((namespace[execution], RDFS.label, Literal(execution, "en")))
    g.add((namespace[execution], RDFS.comment, Literal("A type of commodity", "en")))
    return g

if __name__ == "__main__":
    check_patterns(specialize, schema)