How to read an ontology

You have now enough information to basically understand how the semantic world works, all there is left for you is to be able to read ontologies.

Coming back to IRI, it looks like this :

https://w3id.org/saref#Sensor

A simple rule to work with, if there is separation with a # you have the IRI of a resource (Class, Datatype Property, Object Property, Individual) if not, you have the namespace of an ontology :

https://w3id.org/saref#Sensor <-- IRI of the class Sensor defined in the Saref ontology
https://w3id.org/saref <-- namespace of the Saref ontology

Most of the ontologies are written in xml and are structured by a root node defining the ontology itself. The root node have childrens which defines resources belonging to that particular ontology, a class definition looks like this :

<owl:Class rdf:about="https://w3id.org/saref#Sensor">

<rdfs:subClassOf rdf:resource="https://w3id.org/saref#Device"/>

<rdfs:subClassOf rdf:resource="https://w3id.org/saref#FunctionRelated"/>

</owl:Class>

The IRI reserved for that particular class is stored in the rdf:about. This is the exact same thing for Datatype Property, Object Property and individuals :

<owl:DatatypeProperty rdf:about="https://w3id.org/saref#hasDescription">

   <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>

   <rdfs:comment rdf:datatype="http://www.w3.org/2001/XMLSchema#string">A relationship providing a description of an entity (e.g., device)</rdfs:comment>

   <rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string">has description</rdfs:label>

</owl:DatatypeProperty>

Sometimes there may be variations :

<owl:DatatypeProperty rdf:about="#hasDescription">

   <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>

   <rdfs:comment rdf:datatype="http://www.w3.org/2001/XMLSchema#string">A relationship providing a description of an entity (e.g., device)</rdfs:comment>

   <rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string">has description</rdfs:label>

</owl:DatatypeProperty>

The datatype property above is the same as the previous one as long as it is defined in the right ontology. When the namespace is not defined in a rdf:about but the IRI starts with #, the resource will be automaticaly prefixed with the namespace of the ontology. Also you can define prefix in ontologies. You could describe the datatype property #hasDescription like this :

<!DOCTYPE rdf:RDF [
   <!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" >
]>
<owl:DatatypeProperty rdf:about="#hasDescription">

   <rdfs:range rdf:resource="{{&xsd;}}string"/>

   <rdfs:comment rdf:datatype="{{&xsd;}}string">A relationship providing a description of an entity (e.g., device)</rdfs:comment>

   <rdfs:label rdf:datatype="{{&xsd;}}string">has description</rdfs:label>

</owl:DatatypeProperty>

Thanks to the prefix &xsd;, which are usually defined at the top of the ontology file, we are able to say the same things but in a more compact way.

In the semantic world IRI are used in order to avoid duplicata, meaning that when you will create your own projections (yes, you.), you will have to decide for your own IRI namespace.

Sadly enough there is no namespace authority, that is currently one of our biggest grudge against the semantic world. So even if you do some research on google to check if the namespace you are intesrested in is safe, you will never be completely sure no one is already using it. Bear with it ¯_(ツ)_/¯.

There is, of course, a lot of things which we didn’t spoke about, i tried to keep it at a minimum. Thank you for keeping up with us, we may now speak business, how to find data in Thing’in !