Henriette's Notes

Home » Semantic technologies

Category Archives: Semantic technologies

The difference between Schema.org and OWL

In this blog post I describe some of the main differences between Schema.org vocabularies and OWL ontologies, the implications of these differences and the kind of steps you will need to take to translate Schema.org vocabularies to OWL ontologies.

Overall I keep this discussion at a high-level. For in-depth reviews of the differences between Schema.org and OWL I provide relevant links at the end of this post.

Key differences

There are 2 main differences between OWL and Schema.org.

  1. Intended purpose: The primary purpose of Schema.org is to enable sharing of structured data on the internet. The primary purpose of OWL is to enable sophisticated reasoning across the structure of your data.
  2. Difference in language: Due to the difference in purpose, there are substantial differences in language. The main reason being that the language for OWL can be translated into precise mathematical logic axioms, which allows for much richer inferences to be drawn. This is the reason for OWL preferring rdfs:domain/rdfs:range to schema:domainIncludes/schema:rangeIncludes. The benefit of using rdfs:domain/rdfs:range is that they have precise defined mathematical logic meaning, whereas schema:domainIncludes/schema:rangeIncludes do not have mathematical meaning.

What does this mean?

Using Schema.org you could draw some limited inferences. For example a reasoner can determine that the SNOMED concept http://purl.bioontology.org/ontology/SNOMEDCT/116154003 is a schema:Patient which is a schema:Person. But the language used in Schema.org by itself is not rich enough to detect inconsistencies. I.e., there is no way to say that schema:Person is disjoint from schema:Product. This allows for stating myexample:john a schema:Person and myexample:john a schema:Product without a reasoner being able to detect the inconsistency. Using OWL it is possible to state that schema:Person and schema:Product are disjoint.

Does this mean you should prefer OWL to Schema.org? No, not if your intended purpose of your ontology is to share data. Then it is best to use concepts from Schema.org and add the axioms that will provide the inferences you need. If reasoning is not your reason for wanting to use Schema.org/OWL, then just use Schema.org.

Can you translate Schema.org to OWL?

Strictly speaking, since RDF & RDFS is a subset of OWL, Schema.org is an OWL definition already, albeit one with limited reasoning capability. Any “translation” to OWL will mean adding axioms to Schema.org to increase the inferences that can be drawn from Schema.org documents. It is a pity that Schema.org does not (the current link to the OWL file is dead) provide an OWL file with the additional axioms that will enable richer reasoning.

  • Add rdfs:domain and rdfs:range restrictions rather than replacing schema:domainIncludes and schema:rangeIncludes. Replacing schema:domainIncludes and schema:rangeIncludes could result in search engines not finding information.
  • Add owl:disjointWith and owl:disjointObjectProperties respectively for all classes and properties that do not share individuals.
  • By looking at the documentation of Schema.org it gives the impression that classes have attributes. I.e., schema:Person has an attribute schema:givenName. However, there is nothing in the definition of schema:Person that enforces that the schema:Person class must have a schema:givenName attribute. I describe here, here and here how to define “attributes” for classes in a way that can be used by OWL reasoners.

Conclusion

Schema.org is mainly for sharing structured data on the Internet. OWL is used mainly to reason over structured data to determine inconsistencies in the schema.

For in-depth discussions on the differences between Schema.org and OWL I highly recommend reading the papers by Patel-Schneider and Hernich et al.

EquivalentTo versus SubClassOf

In creating their first OWL ontology, there are at least two aspects of EquivalentTo and SubClassOf that perplex users. The first is when to use EquivalentTo and when to use SubClassOf. The second problem is best illustrated by the following example:


ObjectProperty: a_to_b

Class: A1
   EquivalentTo: (a_to_b some B)

Class: A2
   SubClassOf: (a_to_b some B)

Class: B

Individual: b1
   Types: 
       B

Individual: x
   Facts:  
       a_to_b  b1

When running a reasoner on this example, the individual x is inferred to be of type A1. What perplex users sometimes is that x is not inferred to be of type A2 as well. This is shown in the next figure.

x inferred to be of type A1

The difference between EquivalentTo and SubClassOf

The first thing to be aware of wrt equivalentTo is that

Class: C
   	EquivalentTo: D

is an abbreviation for

Class: C
    SubClassOf: D
	
Class: D
    SubClassOf: C

The semantics of SubClassOf is subset. Thus, the above states that the set C is a subset of the set D and the set D is a subset of the set C. Which means that the sets C and D are exactly the same set. We say they are equivalent.

Note that if I know that the classes C1 and C2 are both subclasses of class C, there is nothing more I can say about how class C1 relates to class C2. This is a bit like knowing that bicycles and trucks are both vehicles – I can say nothing more about how bicycles relate to trucks beyond knowing that they are both vehicles.

Back to our initial example

Understanding the semantics of EquivalentTo we can see that indeed the individual x is an instance of A1. Understanding the semantics of SubClassOf helps us to understand why x is not inferred to be of type A2. We know that A2 is a subclass of a_to_b some B and that x is an instance of a_to_b some B, but there is nothing that can force the reasoner to infer that x is necessarily an instance of the class A2. This is illustrated in the next figure.

A2 and x wrt the set (a_to_b some B)

When to use EquivalentTo versus SubClassOf

EquivalentTo is used for definitions. That is when you want to state the necessary and sufficient conditions for a concept.

SubClassOf is used when you want to define a hierarchy from the most general to the most specific. I.e., it is typically what you see in taxonomies or in object oriented programming languages where one can define class hierarchies. In fact there is a strong relation between OWL 2 ontologies and object orientation which I explore here in more detail.

Conclusion

In this post I explained the difference between EquivalentTo versus SubClassOf and how they are used, as well as some inferences thatmay be confusing to new users. You can find the example ontology on GitHub.

Setting up Virtuoso on Ubuntu 18.04

I recently needed to setup a local instance of Virtuoso on my Ubuntu 18.04 laptop. In particular I needed to be able to specify the directory that Virtuoso is installed. This meant that using a Linux package manager was not an option. I therefore opted to install Virtuoso from source.

  1. Here are the steps I followed to do this:
    We are using Virtuoso 7.2.2. in our production environment, hence I downloaded virtuoso-opensource-7.2.2.tar.gz from Virtuoso downloads.
  2. Then I followed the instructions to build Virtuoso from Building from Upstream Source.
    1. Check build environment by running the following commands:
      sudo apt-get install dpkg-dev build-essential 
      sudo apt-get install autoconf automake libtool flex bison gperf gawk m4 make odbcinst libxml2-dev libssl-dev libreadline-dev
      
    2. Extract the file:
      tar xvpfz virtuoso-opensource-7.2.2.tar.gz
    3. Now to configure Virtuoso to install to a directory of your choice, in the directory you extracted the .tar.gz, run the following:
      ./configure --prefix=directory_of_choice
      
    4. To build Virtuoso, run:
      make nice
      

      This step failed for me with an error message that looks something like the following

      make[3]: Entering directory '~/virtuoso-opensource/libsrc/Wi'
      /bin/bash ../../libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I. -I../../libsrc/Dk    -fno-strict-aliasing -O2  -Wall  -DNDEBUG -DPOINTER_64   -I/home/klimek/virtuoso-opensource/libsrc/Xml.new  -DOPENSSL_NO_KRB5 -Dlinux -D_GNU_SOURCE -DFILE64 -D_LARGEFILE64_SOURCE   -I../../libsrc -I../../libsrc/Dk -I../../libsrc/zlib -I. -I../../libsrc/langfunc -I../../libsrc/plugin -I../../libsrc/Tidy -I../../libsrc/Xml.new -I../../libsrc/odbcsdk/include -DVAD -DDBP -DBIF_XPER -DOPSYS=\"Linux\" -DHOST=\"x86_64-unknown-linux-gnu\" -g -O2 -MT libwi_la-bif_crypto.lo -MD -MP -MF .deps/libwi_la-bif_crypto.Tpo -c -o libwi_la-bif_crypto.lo `test -f 'bif_crypto.c' || echo './'`bif_crypto.c
      libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../../libsrc/Dk -fno-strict-aliasing -O2 -Wall -DNDEBUG -DPOINTER_64 -I/home/klimek/virtuoso-opensource/libsrc/Xml.new -DOPENSSL_NO_KRB5 -Dlinux -D_GNU_SOURCE -DFILE64 -D_LARGEFILE64_SOURCE -I../../libsrc -I../../libsrc/Dk -I../../libsrc/zlib -I. -I../../libsrc/langfunc -I../../libsrc/plugin -I../../libsrc/Tidy -I../../libsrc/Xml.new -I../../libsrc/odbcsdk/include -DVAD -DDBP -DBIF_XPER -DOPSYS=\"Linux\" -DHOST=\"x86_64-unknown-linux-gnu\" -g -O2 -MT libwi_la-bif_crypto.lo -MD -MP -MF .deps/libwi_la-bif_crypto.Tpo -c bif_crypto.c  -fPIC -DPIC -o .libs/libwi_la-bif_crypto.o
      bif_crypto.c: In function ‘box_hmac’:
      bif_crypto.c:184:12: error: storage size of ‘ctx’ isn’t known
         HMAC_CTX ctx;
                  ^~~
      bif_crypto.c:190:3: warning: ‘HMAC_Init’ is deprecated [-Wdeprecated-declarations]
         HMAC_Init (&ctx, key, box_length (key) - DV_STRINGP (key) ? 1 : 0, md);
       ...

      which I fixed by installing libssl1.0-dev with

      sudo apt-get install libssl1.0-dev
      

      You can read more on this error here.
      After this re-run make nice.

    5. Lastly, I ran
      make install
      

      because I installed Virtuoso in my home directory. If you are not installing it in you home directory, you will need to run

      sudo make install
      
  3. To test your installation, go to localhost:8890.