From 78966faa10b2ca4f93724e062ba6984a4a4ba956 Mon Sep 17 00:00:00 2001 From: Federico Igne Date: Fri, 2 Oct 2020 12:18:45 +0200 Subject: Implement `cycle()` and `unfold()` methods --- src/main/scala/rsacomb/RSAOntology.scala | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'src/main/scala/rsacomb') diff --git a/src/main/scala/rsacomb/RSAOntology.scala b/src/main/scala/rsacomb/RSAOntology.scala index fbb5f8a..0acf2a6 100644 --- a/src/main/scala/rsacomb/RSAOntology.scala +++ b/src/main/scala/rsacomb/RSAOntology.scala @@ -239,7 +239,7 @@ trait RSAOntology { ) } - def self(axiom: OWLSubClassOfAxiom): Set[Term] = { + private def self(axiom: OWLSubClassOfAxiom): Set[Term] = { // Assuming just one role in the signature of a T5 axiom val role = axiom.objectPropertyExpressionsInSignature(0) if (this.confl(role).contains(role)) { @@ -252,6 +252,34 @@ trait RSAOntology { } } + // TODO: this implementation is not correct when taking into + // account equality. + 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 + if axiom1.isT5 + roleS <- axiom1.objectPropertyExpressionsInSignature // Just 1 + if conflR.contains(roleS) + individual = + if (axiom.hashCode < axiom1.hashCode) { + RSA.internal("v0_" ++ axiom1.hashCode.toString()) + } else { + RSA.internal("v1_" ++ axiom1.hashCode.toString()) + } + } yield individual + } + + def unfold(axiom: OWLSubClassOfAxiom): Set[Term] = + this.self(axiom) | this.cycle(axiom) + } // implicit class RSAOntology } // trait RSAOntology -- cgit v1.2.3