Skip to content

Commit

Permalink
ttlser add no_reorder_rdf_star to fix owl:annotatedTarget reordering
Browse files Browse the repository at this point in the history
there are some property chin axioms in ro.owl that have been annotated
and before this fix the annotated target was reordered causing owlapi
to include the reordered property chain axioms from the targets which
not surprisingly produced a bunch of unsatisfiable classes

no_reorder_rdf_start is a dict where the keys are the direct linking
predicate to the list that should not be reordered and the values are
the secondary linking predicate that connects to the predicate that
will be tested as a member of no_reorder_list, in which case the list
will not be reordered since its target will not be reordered (if this
paragraph was confusing look at test/no-reorder.ttl for an example).

vbump for release and bump the nifttl version
  • Loading branch information
tgbugs committed Jan 16, 2023
1 parent 338d099 commit 864e390
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 8 deletions.
8 changes: 4 additions & 4 deletions ttlser/test/good.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -450,16 +450,16 @@ sco:8 a owl:Class .
owl:annotatedSource BLX:20 ;
owl:annotatedProperty owl:propertyChainAxiom ;
owl:annotatedTarget (
BLX:18
BLX:21 ) ;
BLX:21
BLX:18 ) ;
rdfs:label "lol you have got to be kidding me" .

[] a owl:Axiom ;
owl:annotatedSource BLX:21 ;
owl:annotatedProperty owl:propertyChainAxiom ;
owl:annotatedTarget (
BLX:18
BLX:21 ) ;
BLX:21
BLX:18 ) ;
rdfs:label "lol you have got to be kidding me" .

[] a owl:Axiom ;
Expand Down
25 changes: 25 additions & 0 deletions ttlser/test/no-reorder.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
@prefix : <file:///ERROR/EMPTY/PREFIX/BANNED/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix partOf: <http://purl.obolibrary.org/obo/BFO_0000050> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix RO: <http://purl.obolibrary.org/obo/RO_> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

### Object Properties

RO:0002216 a owl:ObjectProperty ;
owl:propertyChainAxiom (
RO:0002215
partOf: ) .

### Axioms

[] a owl:Axiom ;
owl:annotatedSource RO:0002216 ;
owl:annotatedProperty owl:propertyChainAxiom ;
owl:annotatedTarget (
RO:0002215
partOf: ) ;
RO:0002582 true .

### Serialized using the ttlser deterministic serializer v1.2.0
8 changes: 8 additions & 0 deletions ttlser/test/test_ttlser.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,14 @@ class TestSCO(Simple, TestTtlser): # TODO TestDet, but not ready yet
actualpath2 = 'test/scoactual2.ttl'


class TestNoReorderRdfStar(Simple, TestTtlser):
format = 'nifttl'
serializer = CustomTurtleSerializer
goodpath = 'test/no-reorder.ttl'
actualpath = 'test/no-reorder-actual.ttl'
actualpath2 = 'test/no-reorder-actual-2.ttl'


class TestMultiBNode(unittest.TestCase):

format = 'nifttl'
Expand Down
2 changes: 1 addition & 1 deletion ttlser/ttlser/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .serializers import *
from .serializers import __all__

__version__ = '1.1.4'
__version__ = '1.1.5'
13 changes: 10 additions & 3 deletions ttlser/ttlser/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,11 @@ def __init__(self, node, serializer):
@staticmethod
def test_reorder(node, serializer):
try:
_, linking_predicate = next(serializer.store[::node])
s, linking_predicate = next(serializer.store[::node])
if linking_predicate in serializer.no_reorder_rdf_star:
p = serializer.no_reorder_rdf_star[linking_predicate]
linking_predicate = next(serializer.store[s:p:])

reorder = linking_predicate not in serializer.no_reorder_list
return reorder
except StopIteration:
Expand Down Expand Up @@ -173,13 +177,16 @@ class CustomTurtleSerializer(TurtleSerializer):
roundtrip_prefixes = '',
short_name = 'nifttl'
_name = 'ttlser deterministic'
__version = 'v1.2.0'
__version = 'v1.2.1'
_newline = True
_nl = '\n'
_space = ' '
sortkey = staticmethod(natsort)
make_litsortkey = staticmethod(make_litsort)
no_reorder_list = OWL.propertyChainAxiom,
no_reorder_list = (OWL.propertyChainAxiom,)
no_reorder_rdf_star = {
OWL.annotatedTarget: OWL.annotatedProperty,
}

topClasses = [OWL.Ontology,
RDF.Property,
Expand Down

0 comments on commit 864e390

Please sign in to comment.