Wednesday, August 14, 2013

Quantities, Units, Dimensions and Data Types

When I was in Hyderabad, India in 2007 my then boss and mentor Edwin Kolen gave me some priceless advise. After I had ranted against him on some or other thing that frustrated me (and since we were setting up an IT offshore office from scratch, there was plenty of frustration), he took the official Indian police officer baton he had in his office and gave me - in a calm but stern voice - the following lecture :
Young man, you've spoiled a perfectly sunny morning for me now and although these are plenty in India, I never want you to do that again ! When you have an issue, you can do one of two things. Either you accept the situation or you take action and do something about it. But never complain to me again, do you hear me ?
Yes indeed Sir, I do. And heeding his advice, here's a small example on the use of QUDT (combining it with a likely candidate such as Good Relations).

Naked triples :
<http://example.com/product/id/8968411#PoS_8968411> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://purl.org/goodrelations/v1#ProductOrService>.
<http://example.com/product/id/8968411#PoS_8968411> <http://purl.org/goodrelations/v1#hasStockKeepingUnit> "896841"^^<http://www.w3.org/2001/XMLSchema#string>.
<http://example.com/product/id/8968411#PoS_8968411> <http://qudt.org/schema/qudt#quantityValue> <http://example.com/product/id/8968411#depth>.
<http://example.com/product/id/8968411#PoS_8968411> <http://qudt.org/schema/qudt#quantityValue> <http://example.com/product/id/8968411#height>.
<http://example.com/product/id/8968411#PoS_8968411> <http://qudt.org/schema/qudt#quantityValue> <http://example.com/product/id/8968411#weight>.
<http://example.com/product/id/8968411#PoS_8968411> <http://qudt.org/schema/qudt#quantityValue> <http://example.com/product/id/8968411#width>.
<http://example.com/product/id/8968411#depth> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://qudt.org/schema/qudt#QuantityValue>.
<http://example.com/product/id/8968411#depth> <http://qudt.org/schema/qudt#numericValue> "9.9"^^<http://www.w3.org/2001/XMLSchema#double>.
<http://example.com/product/id/8968411#depth> <http://qudt.org/schema/qudt#unit> <http://qudt.org/vocab/unit#Inch>.
<http://example.com/product/id/8968411#height> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://qudt.org/schema/qudt#QuantityValue>.
<http://example.com/product/id/8968411#height> <http://qudt.org/schema/qudt#numericValue> "1.2"^^<http://www.w3.org/2001/XMLSchema#double>.
<http://example.com/product/id/8968411#height> <http://qudt.org/schema/qudt#unit> <http://qudt.org/vocab/unit#Inch>.
<http://example.com/product/id/8968411#weight> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://qudt.org/schema/qudt#QuantityValue>.
<http://example.com/product/id/8968411#weight> <http://qudt.org/schema/qudt#numericValue> "5.3"^^<http://www.w3.org/2001/XMLSchema#double>.
<http://example.com/product/id/8968411#weight> <http://qudt.org/schema/qudt#unit> <http://qudt.org/vocab/unit#PoundMass>.
<http://example.com/product/id/8968411#width> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://qudt.org/schema/qudt#QuantityValue>.
<http://example.com/product/id/8968411#width> <http://qudt.org/schema/qudt#numericValue> "15.2"^^<http://www.w3.org/2001/XMLSchema#double>.
<http://example.com/product/id/8968411#width> <http://qudt.org/schema/qudt#unit> <http://qudt.org/vocab/unit#Inch>.


In rdf+xml form that looks like this :
<rdf:RDF
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:gr="http://purl.org/goodrelations/v1#"
    xmlns:qudt="http://qudt.org/schema/qudt#"
    xml:base="http://example.com/product/id/8968411">

    <gr:ProductOrService rdf:ID="PoS_8968411">
        <gr:hasStockKeepingUnit rdf:datatype="http://www.w3.org/2001/XMLSchema#string">896841</gr:hasStockKeepingUnit>
        <qudt:quantityValue rdf:resource="#depth"/>
        <qudt:quantityValue rdf:resource="#height"/>
        <qudt:quantityValue rdf:resource="#weight"/>
        <qudt:quantityValue rdf:resource="#width"/>
    </gr:ProductOrService>

    <qudt:QuantityValue rdf:about="#depth">
        <qudt:numericValue rdf:datatype="http://www.w3.org/2001/XMLSchema#double">9.9</qudt:numericValue>
        <qudt:unit rdf:resource="http://qudt.org/vocab/unit#Inch"/>
    </qudt:QuantityValue>

    <qudt:QuantityValue rdf:about="#height">
        <qudt:numericValue rdf:datatype="http://www.w3.org/2001/XMLSchema#double">1.2</qudt:numericValue>
        <qudt:unit rdf:resource="http://qudt.org/vocab/unit#Inch"/>
    </qudt:QuantityValue>

    <qudt:QuantityValue rdf:about="#weight">
        <qudt:numericValue rdf:datatype="http://www.w3.org/2001/XMLSchema#double">5.3</qudt:numericValue>
        <qudt:unit rdf:resource="http://qudt.org/vocab/unit#PoundMass"/>
    </qudt:QuantityValue>

    <qudt:QuantityValue rdf:about="#width">
        <qudt:numericValue rdf:datatype="http://www.w3.org/2001/XMLSchema#double">15.2</qudt:numericValue>
        <qudt:unit rdf:resource="http://qudt.org/vocab/unit#Inch"/>
    </qudt:QuantityValue>
</rdf:RDF>


In turtle syntax that becomes :
@prefix gr: <http://purl.org/goodrelations/v1#>.
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix qudt: <http://qudt.org/schema/qudt#>.
<http://example.com/product/id/8968411#depth> qudt:numericValue 9.9;
    qudt:unit <http://qudt.org/vocab/unit#Inch>;
    a qudt:QuantityValue.
<http://example.com/product/id/8968411#height> qudt:numericValue 1.2;
    qudt:unit <http://qudt.org/vocab/unit#Inch>;
    a qudt:QuantityValue.
<http://example.com/product/id/8968411#PoS_8968411> gr:hasStockKeepingUnit "896841"^^<http://www.w3.org/2001/XMLSchema#string>;
    qudt:quantityValue <http://example.com/product/id/8968411#depth>,
        <http://example.com/product/id/8968411#height>,
        <http://example.com/product/id/8968411#weight>,
        <http://example.com/product/id/8968411#width>;
    a gr:ProductOrService.
<http://example.com/product/id/8968411#weight> qudt:numericValue 5.3;
    qudt:unit <http://qudt.org/vocab/unit#PoundMass>;
    a qudt:QuantityValue.
<http://example.com/product/id/8968411#width> qudt:numericValue 15.2;
    qudt:unit <http://qudt.org/vocab/unit#Inch>;
    a qudt:QuantityValue.

 

And last but not least, as a graph :

Enjoy (and thanks again Edwin) !