Skip to content

Commit

Permalink
Add unit info using qu-rec20 ontology.
Browse files Browse the repository at this point in the history
  • Loading branch information
user-cjw committed Dec 14, 2021
1 parent 4fc8709 commit 8065958
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 49 deletions.
17 changes: 12 additions & 5 deletions contrib/vspec2ttl/vspec2ttl.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def setup_graph():
g.add((ontology, RDF.type, OWL.Ontology))
g.add((ontology, OWL.versionInfo, Literal("1.0.0")))
g.add((ontology, RDFS.label, Literal("COVESA VSS ontology", lang="en")))
g.add((ontology, OWL.imports, URIRef("http://purl.oclc.org/NET/ssnx/qu/qu-rec20")))

belongsTo = VssoConcepts.BELONGS_TO.uri
g.add((belongsTo, RDF.type, OWL.ObjectProperty))
Expand All @@ -70,14 +71,21 @@ def setup_graph():
# g.add((holdsValue,RDFS.subPropertyOf, OWL.topDataProperty))
# g.add((holdsValue,RDFS.domain, VssoConcepts.VEHICLE_PROP.uri))
# g.add((holdsValue,RDFS.label, Literal(VssoConcepts.HOLDS_VALUE.value,lang="en")))
#

# partOfVehicle = VssoConcepts.PART_OF_VEHICLE.uri
# g.add((partOfVehicle, RDF.type, OWL.ObjectProperty))
# g.add((partOfVehicle,RDFS.subPropertyOf, OWL.topObjectProperty))
# g.add((partOfVehicle,RDFS.domain, VssoConcepts.VEHICLE_COMP.uri))
# g.add((partOfVehicle,RDFS.range, VssoConcepts.VEHICLE.uri))
# g.add((partOfVehicle,RDFS.label, Literal(VssoConcepts.PART_OF_VEHICLE.value,lang="en")))
#

unit = VssoConcepts.UNIT.uri
g.add((unit, RDF.type, OWL.ObjectProperty))
g.add((unit, RDFS.subPropertyOf, OWL.topObjectProperty))
g.add((unit, RDFS.domain, VssoConcepts.VEHICLE_PROP.uri))
g.add((unit, RDFS.range, URIRef(Namespaces["unit"] + "Unit")))
g.add((unit, RDFS.label, Literal(VssoConcepts.UNIT.value, lang="en")))

dataType = VssoConcepts.DATA_TYPE.uri
g.add((dataType, RDF.type, OWL.ObjectProperty))
g.add((dataType, RDFS.subPropertyOf, OWL.topObjectProperty))
Expand All @@ -104,7 +112,6 @@ def setup_graph():
# g.add((hasComponentInstance,RDFS.subPropertyOf, OWL.topDataProperty))
# g.add((hasComponentInstance,RDFS.label, Literal(VssoConcepts.HAS_COMP_INST.value,lang="en")))


# hasAttribute = VssoConcepts.HAS_ATTRIBUTE.uri
# g.add((hasAttribute, RDF.type, OWL.ObjectProperty))
# g.add((hasAttribute,RDFS.subPropertyOf, OWL.topObjectProperty))
Expand All @@ -119,7 +126,6 @@ def setup_graph():
# g.add((hasDynProp, RDFS.range, VssoConcepts.VEHICLE_PROP.uri))
# g.add((hasDynProp, RDFS.label, Literal(VssoConcepts.HAS_SIGNAL.value,lang="en")))


##
# Classes
##
Expand Down Expand Up @@ -170,7 +176,7 @@ def setup_graph():
g.bind("skos", SKOS)
g.bind("schema", SDO)
g.bind("xsd", XSD)
g.bind("qudt", URIRef(Namespaces["qudt"]))
g.bind("unit", URIRef(Namespaces["unit"]))
g.bind("cdt", URIRef(Namespaces["cdt"]))

# print all the data in the Notation3 format
Expand Down Expand Up @@ -258,6 +264,7 @@ def print_ttl_content(file, tree):
graph.add((node, VssoConcepts.DATA_TYPE.uri, DataTypes[dt]))

if hasattr(tree_node, "unit"):
graph.add((node, VssoConcepts.UNIT.uri, DataUnits[tree_node.unit.value]))
if tree_node.unit in units.keys():
units[tree_node.unit] += 1
else:
Expand Down
89 changes: 45 additions & 44 deletions contrib/vspec2ttl/vssotypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class VssoConcepts (Enum):
HAS_COMP_INST = "hasInstance"
DATA_TYPE = "vehiclePropertyDatatype"
BASE_DATA_TYPE = "baseDatatype"
UNIT = "unit"
VEHICLE = "Vehicle"
VEHICLE_SIGNAL = "ObservableVehicleProperty"
VEHICLE_ACT = "ActuatableVehicleProperty"
Expand Down Expand Up @@ -54,50 +55,50 @@ def uri_string(self):
}

Namespaces = {
'qudt': "http://qudt.org/schema/qudt/",
'unit': "http://purl.oclc.org/NET/ssnx/qu/unit#",
'cdt': "http://w3id.org/lindt/custom_datatypes#"
}
DataUnits = {
'N.m': URIRef(Namespaces["cdt"]+'ucum'),
'cm3': URIRef(Namespaces["cdt"]+'volume'),
'cm^3': URIRef(Namespaces["cdt"]+'volume'),
'kw': URIRef(Namespaces["cdt"]+'power'),
'l': URIRef(Namespaces["cdt"]+'volume'),
'mm': URIRef(Namespaces["cdt"]+'length'),
'kg': URIRef(Namespaces["cdt"]+'mass'),
'inch': URIRef(Namespaces["cdt"]+'length'),
'A': URIRef(Namespaces["qudt"]+'ElectricCurrentUnit'),
'Nm': URIRef(Namespaces["qudt"]+'BendingMomentOrTorqueUnit'),
'N.m': URIRef(Namespaces["qudt"]+'BendingMomentOrTorqueUnit'),
'V': URIRef(Namespaces["qudt"]+'EnergyPerElectricChargeUnit'),
'celsius': URIRef(Namespaces["qudt"]+'TemperatureUnit'),
'cm/s': URIRef(Namespaces["qudt"]+'LinearVelocityUnit'),
'degree': URIRef(Namespaces["qudt"]+'AngleUnit'),
'degrees': URIRef(Namespaces["qudt"]+'AngleUnit'),
'degrees/s': URIRef(Namespaces["qudt"]+'AngularVelocityUnit'),
'g/s': URIRef(Namespaces["qudt"]+'MassPerTimeUnit'),
'inch': URIRef(Namespaces["qudt"]+'LengthUnit'),
'kW': URIRef(Namespaces["qudt"]+'PowerUnit'),
'kilometer': URIRef(Namespaces["qudt"]+'LengthUnit'),
'km': URIRef(Namespaces["qudt"]+'LengthUnit'),
'km/h': URIRef(Namespaces["qudt"]+'LinearVelocityUnit'),
'kpa': URIRef(Namespaces["qudt"]+'PressureOrStressUnit'),
'kPa': URIRef(Namespaces["qudt"]+'PressureOrStressUnit'),
'l': URIRef(Namespaces["qudt"]+'VolumeUnit'),
'l/h': URIRef(Namespaces["qudt"]+'VolumePerTimeUnit'),
'm': URIRef(Namespaces["qudt"]+'LengthUnit'),
'm/s': URIRef(Namespaces["qudt"]+'LinearVelocityUnit'),
'm/s2': URIRef(Namespaces["qudt"]+'LinearAccelerationUnit'),
'm/s^2': URIRef(Namespaces["qudt"]+'LinearAccelerationUnit'),
'mbar': URIRef(Namespaces["qudt"]+'PressureOrStressUnit'),
'min': URIRef(Namespaces["qudt"]+'TimeUnit'),
'ml': URIRef(Namespaces["qudt"]+'VolumeUnit'),
'mm': URIRef(Namespaces["qudt"]+'LengthUnit'),
'pa': URIRef(Namespaces["qudt"]+'PressureOrStressUnit'),
'Pa': URIRef(Namespaces["qudt"]+'PressureOrStressUnit'),
'percent': URIRef(Namespaces["qudt"]+'DimensionlessUnit'),
'percentage': URIRef(Namespaces["qudt"]+'DimensionlessUnit'),
'ratio': URIRef(Namespaces["qudt"]+'DimensionlessUnit'),
'rpm': URIRef(Namespaces["qudt"]+'AngularVelocityUnit'),
's': URIRef(Namespaces["qudt"]+'TimeUnit')

DataUnits = {
'A': URIRef(Namespaces["unit"] + "ampere"),
'celsius': URIRef(Namespaces["unit"] + "degreeCelsius"),
'cm/s': URIRef(Namespaces["unit"] + "centimetrePerSecond"),
'cm^3': URIRef(Namespaces["unit"] + "cubicCentimetre"),
'cm3': URIRef(Namespaces["unit"] + "cubicCentimetre"),
'degree': URIRef(Namespaces["unit"] + "degreeUnitOfAngle"),
'degrees': URIRef(Namespaces["unit"] + "degreeUnitOfAngle"),
'degrees/s': URIRef(Namespaces["unit"] + "degreePerSecond"),
'g/km': URIRef(Namespaces["unit"] + "gramPerKilometre"), # Not available in qu-rec20
'g/s': URIRef(Namespaces["unit"] + "gramPerSecond"),
'inch': URIRef(Namespaces["unit"] + "inch"),
'kg': URIRef(Namespaces["unit"] + "kilogram"),
'kilometer': URIRef(Namespaces["unit"] + "kilometre"),
'km/h': URIRef(Namespaces["unit"] + "kilometrePerHour"),
'km': URIRef(Namespaces["unit"] + "kilometre"),
'kpa': URIRef(Namespaces["unit"] + "kilopascal"),
'kPa': URIRef(Namespaces["unit"] + "kilopascal"),
'kw': URIRef(Namespaces["unit"] + "kilowatt"),
'kW': URIRef(Namespaces["unit"] + "kilowatt"),
'kWh': URIRef(Namespaces["unit"] + "kilowattHour"),
'l/100km': URIRef(Namespaces["unit"] + "litrePerHundredKilometre"), # Not available in qu-rec20
'l/h': URIRef(Namespaces["unit"] + "litrePerHour"), # Not available in qu-rec20
'l': URIRef(Namespaces["unit"] + "litre"),
'm/s': URIRef(Namespaces["unit"] + "metrePerSecond"),
'm/s^2': URIRef(Namespaces["unit"] + "metrePerSecondSquared"),
'm/s2': URIRef(Namespaces["unit"] + "metrePerSecondSquared"),
'm': URIRef(Namespaces["unit"] + "metre"),
'mbar': URIRef(Namespaces["unit"] + "millibar"),
'min': URIRef(Namespaces["unit"] + "minuteUnitOfTime"),
'ml': URIRef(Namespaces["unit"] + "millilitre"),
'mm': URIRef(Namespaces["unit"] + "millimetre"),
'N.m': URIRef(Namespaces["unit"] + "newtonMetre"),
'Nm': URIRef(Namespaces["unit"] + "newtonMetre"),
'pa': URIRef(Namespaces["unit"] + "pascal"),
'Pa': URIRef(Namespaces["unit"] + "pascal"),
'percent': URIRef(Namespaces["unit"] + "percent"),
'percentage': URIRef(Namespaces["unit"] + "percent"),
'ratio': URIRef(Namespaces["unit"] + "ratio"),
'rpm': URIRef(Namespaces["unit"] + "revolutionPerMinute"), # Not available in qu-rec20
's': URIRef(Namespaces["unit"] + "secondUnitOfTime"),
'V': URIRef(Namespaces["unit"] + "volt")
}

1 comment on commit 8065958

@jdacoello
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any particular reason for using the qu-rec20 ontology instead of qudt or om ontologies?

Please sign in to comment.