Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
anatoly-scherbakov opened this issue Nov 13, 2021 · 2 comments

Comments

@anatoly-scherbakov
Copy link

Such triples are illegal due to RDF standard, and they break at least some of the storage engines: see RDFLib/rdflib-sqlalchemy#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.

@majidaldo
Copy link

related #13

@majidaldo
Copy link

majidaldo commented Mar 20, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants