OWL-RL
OWL-RL copied to clipboard
OWL RL creates triples with a Literal as Subject when evaluating PROV-O ontology
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.
related https://github.com/RDFLib/OWL-RL/issues/13
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.