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

RDFS_Semantics add predicate datatype values from unrelated subjects #61

Closed
senevoldsen opened this issue Apr 25, 2023 · 1 comment · Fixed by #68
Closed

RDFS_Semantics add predicate datatype values from unrelated subjects #61

senevoldsen opened this issue Apr 25, 2023 · 1 comment · Fixed by #68

Comments

@senevoldsen
Copy link

Running version 6.0.2. In this example, after running the closure, both ex:alpha and ex:beta has both 42 and 22 under the ex:hasValue predicate.

from rdflib import Graph
from owlrl import DeductiveClosure, RDFS_Semantics

input_ttl = """
@prefix ex: <urn:example#> .
ex:alpha ex:hasValue "42"^^ex:Blorb .
ex:beta ex:hasValue "22"^^ex:Blorb .
"""

g = Graph()
g.parse(data=input_ttl, format='turtle')
DeductiveClosure(RDFS_Semantics).expand(g)
print(g.serialize(format='turtle'))
@senevoldsen
Copy link
Author

It looks like it may be caused by using normal Python semantics to infer literals with same value. In my case ex:Blorb is not understood by Rdflib so it assigns it the value None. However, since both are None they compare equal and they add the attributes.

Another example shows the same happen with integers and booleans:

@prefix ex: <urn:example#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
ex:alpha ex:hasValue "false"^^xsd:boolean .
ex:beta ex:hasValue "0"^^xsd:integer .

Here both ex:alpha and ex:beta ends up with ex:hasValue for both xsd:boolean and xsd:integer even though (at least I think) they are different values in RDF(S) interpretations.

  • I think the issue might be caused by the following lines. Line 124 applies Python semantics to the value equality check: I am not sure what a good fix for this is.
  • The other part is that literals with unknown datatypes receive value None from the self._literals() call: those literals with value of None should probably be filtered away before the comparison.

    OWL-RL/owlrl/RDFSClosure.py

    Lines 120 to 125 in a77e179

    literals = self._literals()
    items = (
    (lt1, lt2)
    for lt1, lt2 in product(literals, literals)
    if lt1.value == lt2.value
    )

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

Successfully merging a pull request may close this issue.

1 participant