aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFederico Igne <federico.igne@cs.ox.ac.uk>2020-12-06 09:51:48 +0000
committerFederico Igne <federico.igne@cs.ox.ac.uk>2020-12-06 09:51:48 +0000
commit9dd3da94d106fed295ab7bef167f35fab0050d95 (patch)
tree1298380a5420e33012488626a7f8276ba5e36686
parent4950c9a78eda022c5342efbc77eb1135881f11ac (diff)
downloadRSAComb-9dd3da94d106fed295ab7bef167f35fab0050d95.tar.gz
RSAComb-9dd3da94d106fed295ab7bef167f35fab0050d95.zip
Reintroduce previous implementation of `cycle`
At the time of writing, the naïve implementation of `cycle` produces too many rules, which are not efficiently handled by RDFox.
-rw-r--r--src/main/scala/uk/ac/ox/cs/rsacomb/RSAOntology.scala61
1 files 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) {
382 } 382 }
383 } 383 }
384 384
385 // def cycle(axiom: OWLSubClassOfAxiom): Set[Term] = {
386 // // Assuming just one role in the signature of a T5 axiom
387 // val roleR = axiom.objectPropertyExpressionsInSignature(0)
388 // val conflR = this.confl(roleR)
389 // // We just need the TBox to find
390 // val tbox = ontology
391 // .tboxAxioms(Imports.INCLUDED)
392 // .collect(Collectors.toSet())
393 // .asScala
394 // for {
395 // axiom1 <- tbox
396 // // TODO: is this an optimization or an error?
397 // if axiom1.isT5
398 // // We expect only one role coming out of a T5 axiom
399 // roleS <- axiom1.objectPropertyExpressionsInSignature
400 // // Triples ordering is among triples involving safe roles.
401 // if !unsafeRoles.contains(roleS)
402 // if conflR.contains(roleS)
403 // individual =
404 // if (axiom.hashCode < axiom1.hashCode) {
405 // RSA.rsa("v0_" ++ axiom1.hashCode.toString())
406 // } else {
407 // RSA.rsa("v1_" ++ axiom1.hashCode.toString())
408 // }
409 // } yield individual
410 // }
411
412 def cycle(axiom: OWLSubClassOfAxiom): Set[Term] = { 385 def cycle(axiom: OWLSubClassOfAxiom): Set[Term] = {
413 // TODO: we can actually use `toTriple` from `RSAAxiom` 386 // TODO: we can actually use `toTriple` from `RSAAxiom`
414 val classes = 387 val classes =
@@ -418,10 +391,10 @@ class RSAOntology(val ontology: OWLOntology) {
418 .objectPropertyExpressionsInSignature(0) 391 .objectPropertyExpressionsInSignature(0)
419 .asInstanceOf[OWLObjectProperty] 392 .asInstanceOf[OWLObjectProperty]
420 val classB = classes(1) 393 val classB = classes(1)
421 cycle_aux(classA, roleR, classB) 394 cycle_aux1(classA, roleR, classB)
422 } 395 }
423 396
424 def cycle_aux( 397 def cycle_aux0(
425 classA: OWLClass, 398 classA: OWLClass,
426 roleR: OWLObjectProperty, 399 roleR: OWLObjectProperty,
427 classB: OWLClass 400 classB: OWLClass
@@ -450,6 +423,36 @@ class RSAOntology(val ontology: OWLOntology) {
450 } yield individual 423 } yield individual
451 } 424 }
452 425
426 def cycle_aux1(
427 classA: OWLClass,
428 roleR: OWLObjectProperty,
429 classB: OWLClass
430 ): Set[Term] = {
431 val conflR = this.confl(roleR)
432 // We just need the TBox to find
433 val terms = for {
434 axiom1 <- tbox
435 // TODO: is this an optimization or an error?
436 if axiom1.isT5
437 // We expect only one role coming out of a T5 axiom
438 roleS <- axiom1.objectPropertyExpressionsInSignature
439 // Triples ordering is among triples involving safe roles.
440 if !unsafeRoles.contains(roleS)
441 if conflR.contains(roleS)
442 tripleARB = RSAAxiom.hashed(classA, roleR, classB)
443 tripleDSC = axiom1.hashed
444 individual =
445 if (tripleARB > tripleDSC) {
446 RSA("v1_" ++ tripleDSC)
447 } else {
448 // Note that this is also the case for
449 // `tripleARB == tripleDSC`
450 RSA("v0_" ++ tripleDSC)
451 }
452 } yield individual
453 terms to Set
454 }
455
453 def unfold(axiom: OWLSubClassOfAxiom): Set[Term] = 456 def unfold(axiom: OWLSubClassOfAxiom): Set[Term] =
454 this.self(axiom) | this.cycle(axiom) 457 this.self(axiom) | this.cycle(axiom)
455 458