RDFLib / OWL-RL

A simple implementation of the OWL2 RL Profile on top of RDFLib: it expands the graph with all possible triples that OWL RL defines. It can be used together with RDFLib to expand an RDFLib Graph object, or as a stand alone service with its own serialization.
http://www.ivan-herman.net/Misc/2008/owlrl/
Other
140 stars 30 forks source link

Remove `LiteralProxies` class to improve the performance of processing #13

Open wrobell opened 5 years ago

wrobell commented 5 years ago

The RDFClosure/Literals.py states

The issue is that pure literals cannot appear in subject position according to the current rules on RDF. That means that different types of conclusions cannot properly finish.

However, rdflib seems to support literals in subject position.

I wonder if we could remove LiteralProxies class and therefore speedup the whole processing?

ashleysommer commented 5 years ago

This would be a rather large architectural change to the tool. I believe the original author @iherman would need to comment on this.

iherman commented 5 years ago

@wrobell, if rdflib supports literals as subjects today (it did not when this code was written...), then, of course, LiteralProxies may go, I agree. As @ashleysommer says, it is a rather large architectural change, but probably the rest of the code may be oblivious to the change...

wrobell commented 5 years ago

The following script works. Is there any other RDFlib feature which should be tested with literals in subject position?

import io

from pprint import pprint
from rdflib import Graph, Literal, RDF, XSD

DATA = """  
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.

1 a xsd:integer.                    
"""                                 

g = Graph()                         
g.parse(io.StringIO(DATA), format='n3')
g.add((Literal(1.1), RDF.type, XSD.float))
pprint(list(g))                     

pprint(list(g.objects(Literal(1), RDF.type)))
pprint(list(g.objects(Literal(1.1), RDF.type)))

pprint(list(g.subjects(RDF.type, XSD.integer)))
pprint(list(g.subjects(RDF.type, XSD.float)))
wrobell commented 5 years ago

In pull request #16 I have implemented two tests for semantic of datatypes (table 8 at https://www.w3.org/TR/owl2-profiles/#Reasoning_in_OWL_2_RL_and_RDF_Graphs_using_Rules).

I believe dt-type2, dt-eq and dt-diff rules are skipped on purpose?

Do you mind if I ask you to suggest others tests to be implemented before I start removal of LiteralProxies class?