OWL-RL icon indicating copy to clipboard operation
OWL-RL copied to clipboard

OWL RL creates triples with a Literal as Subject when evaluating PROV-O ontology

Open anatoly-scherbakov opened this issue 4 years ago • 2 comments

Such triples are illegal due to RDF standard, and they break at least some of the storage engines: see https://github.com/RDFLib/rdflib-sqlalchemy/issues/85

The full working example is here: https://gist.github.com/anatoly-scherbakov/ebde3d6b70ddde7f7b3baadb65d8464b

I am not entirely clear why these are created. I am willing to help by writing a PR if you could please explain the reason of those triples to be asserted.

anatoly-scherbakov avatar Nov 13 '21 14:11 anatoly-scherbakov

related https://github.com/RDFLib/OWL-RL/issues/13

majidaldo avatar Mar 20 '23 16:03 majidaldo

patch hack: capture the offensive triples.

from rdflib import Literal, Graph as _Graph
class Graph(_Graph):

    def __init__(self, *p, **k):
        self._offensive = set()
        super().__init__(*p, **k)

    def add(self, t):
        if isinstance(t[0], Literal):
            self._offensive.add(t)
        # so that it keeps working as usual
        return super().add(t)

   # could patch __iter__ to filter out the offensive triples.

this is the 'last defense' procedure but there should be some config for this.

majidaldo avatar Mar 20 '23 20:03 majidaldo