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
139 stars 30 forks source link

Drop processing of literals with `LiteralProxies` class #18

Closed wrobell closed 5 years ago

wrobell commented 5 years ago

This is possible, because RDFLib supports literals in subject position now (see discussion in issue #13).

As a consequence

  1. The change improves performance of the library, for the script below, by about 14%.

  2. Related blocks of code, which swallow exceptions are removed.

  3. Unit tests for the following OWL 2 RL rules are implemented

    • cax-dw
    • cls-avf
    • cls-maxc1
    • cls-maxc2
    • cls-maxqc1
    • cls-maxqc2
    • cls-maxqc3
    • cls-maxqc4
  4. Unit tests for RDFS closure implemented

    • adding datatype axioms
    • one time rules
  5. Unit tests for OWL 2 RL extras closure implemented

    • one time rules

Testing script

import io
import sys
import time
import owlrl
from rdflib import Graph, Namespace, BNode, Literal, XSD

T = Namespace('http://test.net/')

DATA = """
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix owl: <http://www.w3.org/2002/07/owl#>.
@prefix : <http://test.net/>.

:C a owl:Class.
:dprop a owl:DatatypeProperty;
    rdfs:domain :C;
    rdfs:range xsd:integer.
""" 

test_name = sys.argv[1]

dprop = T.dprop
print('test,graph_size,time')
for _ in range(10):

    g = Graph()
    g.parse(io.StringIO(DATA), format='n3')

    for i in range(10):
        d = BNode()
        for j in range(200):
            b = BNode()
            g.add((b, dprop, Literal(j * 10, datatype=XSD.integer)))

    t = time.time()
    owlrl.DeductiveClosure(owlrl.OWLRL_Semantics).expand(g)
    duration = time.time() - t
    print('{},{},{:.6f}'.format(test_name, len(g), duration))
ashleysommer commented 5 years ago

@wrobell are you done pushing commits to this PR? Let us know when it is ready for review.

wrobell commented 5 years ago

Hi, sorry, I have raised this pull request too early. I will have few more fixes. I will comment once its done.

ashleysommer commented 5 years ago

@wrobell we've noticed no new commit to this branch since November 7. Is this ready to review and merge?

wrobell commented 5 years ago

Unfortunately, this still needs work. I hope to have some time to work on it today.

wrobell commented 5 years ago

This pull request is ready. Please review.