From 9dd3da94d106fed295ab7bef167f35fab0050d95 Mon Sep 17 00:00:00 2001 From: Federico Igne Date: Sun, 6 Dec 2020 09:51:48 +0000 Subject: Reintroduce previous implementation of `cycle` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit At the time of writing, the naïve implementation of `cycle` produces too many rules, which are not efficiently handled by RDFox. --- .../scala/uk/ac/ox/cs/rsacomb/RSAOntology.scala | 61 ++++++++++++---------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/src/main/scala/uk/ac/ox/cs/rsacomb/RSAOntology.scala b/src/main/scala/uk/ac/ox/cs/rsacomb/RSAOntology.scala index 8fae4c8..52d4905 100644 --- a/src/main/scala/uk/ac/ox/cs/rsacomb/RSAOntology.scala +++ b/src/main/scala/uk/ac/ox/cs/rsacomb/RSAOntology.scala @@ -382,33 +382,6 @@ class RSAOntology(val ontology: OWLOntology) { } } - // def cycle(axiom: OWLSubClassOfAxiom): Set[Term] = { - // // Assuming just one role in the signature of a T5 axiom - // val roleR = axiom.objectPropertyExpressionsInSignature(0) - // val conflR = this.confl(roleR) - // // We just need the TBox to find - // val tbox = ontology - // .tboxAxioms(Imports.INCLUDED) - // .collect(Collectors.toSet()) - // .asScala - // for { - // axiom1 <- tbox - // // TODO: is this an optimization or an error? - // if axiom1.isT5 - // // We expect only one role coming out of a T5 axiom - // roleS <- axiom1.objectPropertyExpressionsInSignature - // // Triples ordering is among triples involving safe roles. - // if !unsafeRoles.contains(roleS) - // if conflR.contains(roleS) - // individual = - // if (axiom.hashCode < axiom1.hashCode) { - // RSA.rsa("v0_" ++ axiom1.hashCode.toString()) - // } else { - // RSA.rsa("v1_" ++ axiom1.hashCode.toString()) - // } - // } yield individual - // } - def cycle(axiom: OWLSubClassOfAxiom): Set[Term] = { // TODO: we can actually use `toTriple` from `RSAAxiom` val classes = @@ -418,10 +391,10 @@ class RSAOntology(val ontology: OWLOntology) { .objectPropertyExpressionsInSignature(0) .asInstanceOf[OWLObjectProperty] val classB = classes(1) - cycle_aux(classA, roleR, classB) + cycle_aux1(classA, roleR, classB) } - def cycle_aux( + def cycle_aux0( classA: OWLClass, roleR: OWLObjectProperty, classB: OWLClass @@ -450,6 +423,36 @@ class RSAOntology(val ontology: OWLOntology) { } yield individual } + def cycle_aux1( + classA: OWLClass, + roleR: OWLObjectProperty, + classB: OWLClass + ): Set[Term] = { + val conflR = this.confl(roleR) + // We just need the TBox to find + val terms = for { + axiom1 <- tbox + // TODO: is this an optimization or an error? + if axiom1.isT5 + // We expect only one role coming out of a T5 axiom + roleS <- axiom1.objectPropertyExpressionsInSignature + // Triples ordering is among triples involving safe roles. + if !unsafeRoles.contains(roleS) + if conflR.contains(roleS) + tripleARB = RSAAxiom.hashed(classA, roleR, classB) + tripleDSC = axiom1.hashed + individual = + if (tripleARB > tripleDSC) { + RSA("v1_" ++ tripleDSC) + } else { + // Note that this is also the case for + // `tripleARB == tripleDSC` + RSA("v0_" ++ tripleDSC) + } + } yield individual + terms to Set + } + def unfold(axiom: OWLSubClassOfAxiom): Set[Term] = this.self(axiom) | this.cycle(axiom) -- cgit v1.2.3