Validating RDF data against an ontology for consistency check

699 Views Asked by At

I would like to validate RDF data (irrespective of the format), against an ontology that is constructed.

Can we solve this program programmatically (model checker) to identify the consistency of the dataset ontology?

For ex,

aaa <http://bbb/date> "2004"^^<http://www.w3.org/2001/XMLSchema#integer> .

The above triple has a property date, which requires a date in the object position. Assuming this constraint is mentioned in the ontology, I would like to verify this triple automatically without human intervention programmatically.

2

There are 2 best solutions below

2
Thomas On

It's important to note that the datatype specified in the ontology is not a constraint. Instead, when a datatype is specified in an OWL definition, it's a statement about the range of that datatype. This can be used by reasoning engines to make inferences about data in the graph. This is also true for domain and range declarations. If you say that the range of the relation hasBoyfriend is a schema:Person but add a relation to the graph that says Person_A hasBoyfriend Dog_A, the inference engine will create a new predicate that says Dog_A is both a dog and schema:Person.

As Henriette mentioned in the comments, for consistency checking you'll need to use a separate but related technology: either shex or shacl. Make sure that whichever stack you're using supports one or the other before giving it a go!

1
Antoine Zimmermann On

You can test consistency of RDF data wrt an ontology by combining the ontology and the data together and using a reasoner on this. There are different approaches for this: load everything into the reasoner's data structure and test for consistency from there, or use a database where you materialise inferred data and look for contradicting facts.

For instance, if you have an ontology that says:

onto:date  a  owl:DatatypeProperty;
  rdfs:range  xsd:date .

and your data has:

ex:aaa  onto:date  "2004"^^xsd:integer .

then the merge of the two will be inconsistent according to an OWL reasoner, or even an RDFS reasoner that supports datatypes xsd:date and xsd:integer. If you are using materialisation, the contradiction becomes apparent because the data entails:

ex:aaa  onto:date  _:bnode .
_:bnode  rdf:type  xsd:integer .

and the combination of this data with the ontology entails:

_:bnode  rdf:type  xsd:date .

We thus have a node that belongs to two incompatible datatypes, which is a direct contradiction.

If you know you are only dealing with certain kinds of inconsistencies, such as datatype inconsistencies, then using a full-fledged reasoner is not the most efficient option. Also, from your question, it is not clear whether you want to test logical consistency or some kind of integrity constraints, because the case of datatypes is special. A lot of people confuse axioms and constraints. This is why both Henriette Hamrse in her comment, and Thomas in his answer are referring to ShEx and SHACL, which would be much more appropriate for testing constraints.