units of measurement in owl and rdf
Asked Answered
S

2

6

I'm creating linked data of materials and their physical properties, and I'm having trouble with setting units for certain properties. My individual material :AlMg3 has some mechanical properties like:

:AlMg3 prop:hasTensileStrength "300" .
:AlMg3 prop:hasYieldStrength   "2" .
:alMg3 prop:hasDensity         "2200" .

How to put units for that values? My first idea was to make new datatypes, e.g.:

unit:megaPascal rdf:type   rdfs:datatype ;
                rdfs:label "MPa" .

unit:Pascal rdf:type   rdfs:datatype ;
                rdfs:label "Pa" .

and then use them like this:

:AlMg3 prop:hasTensileStrength "300"^^unit:megaPascal .
:AlMg3 prop:hasYieldStrength   "2"^^unit:Pascal .

Then I'd want to relate these units like this:

unit:megaPascal prop:hasBaseUnit   unit:Pascal .
unit:pascal     prop:hasBaseSIUnit unit:kilogramPerMeterSecondSquared .

Is this possible? The units would be datatypes, and I can't put datatype properties between them, except for annotation properties? Is it possible to make those units individuals (or even classes) and use them like that a datatype after some value?

I saw OWL ontologies for QUDT (Quantities, Units, Dimensions and Data Types), but I was going to try to create something simpler myself.

Scauper answered 27/11, 2013 at 16:51 Comment(0)
F
8

You can use whatever datatypes you like, but the problem if you do that (e.g., using "300"^^unit:megaPascal) is that you can no longer do arithmetic on them, and you can't get any validation of the lexical forms from any of the standard tools. Better options are to add some documentation to your properties and use literals with supported datatypes, or use some structured values for these measurements.

Documentation and standard datatypes

What is probably makes more sense to do is just add a comment to the relevant properties that their values should be specified as numbers in some particular unit. E.g.,

prop:hasYieldStrength rdfs:comment "YieldStrength of material in Pascals"@en .

Structured values (perhaps using rdf:value)

The other option is to make the range of those properties some sort of entity that specifies both the measurement and the unit, so that your data would be like:

:AlMg3 prop:hasTensileStrength [ rdf:value "300"^^xsd:integer ;
                                 unit:units unit:megaPascal ] .

If you're working in OWL, I'm not sure whether it's OK to use rdf:value or not, but you can certainly use your own vocabulary to do the same thing. If you can use rdf:value, this is actually one the ways that the the RDF documentation says it can be used:

5.4.3 rdf:value

rdf:value is an instance of rdf:Property that may be used in describing structured values.

rdf:value has no meaning on its own. It is provided as a piece of vocabulary that may be used in idioms such as illustrated in example 16 of the RDF primer [RDF-PRIMER]. Despite the lack of formal specification of the meaning of this property, there is value in defining it to encourage the use of a common idiom in examples of this kind.

The RDF Primer has relevant material too; measurements are one of the explicit examples:

4.4 More on Structured Values: rdf:value

… For instance, in Example 9 in Section 3.2, the weight of a particular tent was given as the decimal value 2.4 using a typed literal, i.e.,

exproduct:item10245   exterms:weight   "2.4"^^xsd:decimal .

In fact, a more complete description of the weight would have been 2.4 kilograms rather than just the decimal value 2.4. To state this, the value of the exterms:weight property would need to have two components, the typed literal for the decimal value and an indication of the unit of measure (kilograms). In this situation the decimal value could be considered the "main" value of the exterms:weight property, because frequently the value would be recorded simply as the typed literal (as in the triple above), relying on an understanding of the context to fill in the unstated units information.

In the RDF model a qualified property value of this kind can be considered as simply another kind of structured value. To represent this, a separate resource could be used to represent the structured value as a whole (the weight, in this case), and to serve as the object of the original statement. That resource could then be given properties representing the individual parts of the structured value. In this case, there should be a property for the typed literal representing the decimal value, and a property for the unit. RDF provides a predefined rdf:value property to describe the main value (if there is one) of a structured value. So in this case, the typed literal could be given as the value of the rdf:value property, and the resource exunits:kilograms as the value of an exterms:units property (assuming the resource exunits:kilograms is defined as part of example.org's vocabulary). The resulting triples would be:

exproduct:item10245   exterms:weight   _:weight10245 .
_:weight10245         rdf:value        "2.4"^^xsd:decimal .
_:weight10245         exterms:units    exunits:kilograms .

Note that that last example can be written as:

exproduct:item10245 exterms:weight [ rdf:value "2.4"^^xsd:decimal ;
                                     exterms:units exunits:kilograms ] .
Furbelow answered 27/11, 2013 at 21:8 Comment(0)
J
1

without inferences

i.e. no unit conversion is needed.
i.e. the same unit is used for the same type of measurement.
-> then, go to Joshua's answer. It's clear simple and use explicit declaration.
note: please take a look at UCUM documentation (Unified Code for Units of Measure code system) for naming convention at least.

with the power of inferences

i.e. unit conversion is needed.
e.g. some of the measurement are in meter, others in millimeters, others in international inches and you need to query them all together.

Inferences (unit conversion in our case) is an important feature of RDF.
Without inferences, SPARQL filtering may be return false negatives if different units are in use.

-> then take a look at this project: https://ci.mines-stetienne.fr/lindt/v4/custom_datatypes.html proposing a custom datatype cdt: prefix for units and classes by measurements.
A fork of Jena implements the proposal.
A sandbox is available here: https://ci.mines-stetienne.fr/lindt/playground.html. (with request example and outputs)

SPARQL example input:

PREFIX cdt: <http://w3id.org/lindt/custom_datatypes#> 

SELECT ?value ?normalized 

WHERE{ 

  VALUES ?value {

    "1 m2"^^cdt:area # square meter
    "1 ar"^^cdt:area # are
    "1 [sin_i]"^^cdt:area # square inch International customary units
    "1 [in_i]2"^^cdt:area # square inch International customary units
    "1 [smi_us]"^^cdt:area # square mile Older U.S. “survey” lengths (also called "statute" lengths)

  }

  # normalize
  BIND("0 m2"^^cdt:area + ?value AS ?normalized )
  
}

output

-------------------------------------------------------------
| value                  | normalized                       |
=============================================================
| "1 m2"^^cdt:area       | "1.0 m2"^^cdt:area               |
| "1 ar"^^cdt:area       | "100.0 m2"^^cdt:area             |
| "1 [sin_i]"^^cdt:area  | "6.4516E-4 m2"^^cdt:area         |
| "1 [in_i]2"^^cdt:area  | "6.4516E-4 m2"^^cdt:area         |
| "1 [smi_us]"^^cdt:area | "2589998.470319521 m2"^^cdt:area |
-------------------------------------------------------------

The related research article is here: https://link.springer.com/chapter/10.1007/978-3-319-98192-5_37

Japha answered 4/10, 2023 at 10:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.