aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFederico Igne <federico.igne@cs.ox.ac.uk>2022-06-01 17:46:38 +0100
committerFederico Igne <federico.igne@cs.ox.ac.uk>2022-06-01 17:46:38 +0100
commitf2ea699de24108f2ad1209e16a1ca35fc114f91a (patch)
tree664273089567d3ad35fc97062402419b20d64172
parentf480a850161445bb3dd9ead500810db21dfa1451 (diff)
downloadRSAComb-f2ea699de24108f2ad1209e16a1ca35fc114f91a.tar.gz
RSAComb-f2ea699de24108f2ad1209e16a1ca35fc114f91a.zip
refactor(upperbound): improve choice function
-rw-r--r--src/main/scala/uk/ac/ox/cs/rsacomb/approximation/Upperbound.scala20
1 files changed, 6 insertions, 14 deletions
diff --git a/src/main/scala/uk/ac/ox/cs/rsacomb/approximation/Upperbound.scala b/src/main/scala/uk/ac/ox/cs/rsacomb/approximation/Upperbound.scala
index 2c3bdc4..567691f 100644
--- a/src/main/scala/uk/ac/ox/cs/rsacomb/approximation/Upperbound.scala
+++ b/src/main/scala/uk/ac/ox/cs/rsacomb/approximation/Upperbound.scala
@@ -1,7 +1,5 @@
1package uk.ac.ox.cs.rsacomb.approximation 1package uk.ac.ox.cs.rsacomb.approximation
2 2
3// import java.io.File
4
5import org.semanticweb.owlapi.apibinding.OWLManager 3import org.semanticweb.owlapi.apibinding.OWLManager
6import org.semanticweb.owlapi.model.{IRI => _, _} 4import org.semanticweb.owlapi.model.{IRI => _, _}
7 5
@@ -52,34 +50,28 @@ class Upperbound(implicit fresh: DataFactory)
52 toRSA( 50 toRSA(
53 new Ontology( 51 new Ontology(
54 ontology.origin, 52 ontology.origin,
55 ontology.axioms flatMap toConjuncts, 53 ontology.axioms map chooseDisjunct,
56 ontology.datafiles 54 ontology.datafiles
57 ) 55 )
58 ) 56 )
59 57
60 /** Turn disjuncts into conjuncts 58 /** Choose a single disjunct
61 * 59 *
62 * This is a very naïve way of getting rid of disjunction preserving 60 * This is a very naïve way of getting rid of disjunction preserving
63 * completeness of CQ answering. 61 * completeness of CQ answering.
64 *
65 * @todo implement a choice function that decides which disjunct to
66 * keep instead of keeping all of them. Note that PAGOdA is currently
67 * doing something similar.
68 */ 62 */
69 private def toConjuncts(axiom: OWLLogicalAxiom): List[OWLLogicalAxiom] = 63 private def chooseDisjunct(axiom: OWLLogicalAxiom): OWLLogicalAxiom =
70 axiom match { 64 axiom match {
71 case a: OWLSubClassOfAxiom => { 65 case a: OWLSubClassOfAxiom => {
72 val sub = a.getSubClass.getNNF 66 val sub = a.getSubClass.getNNF
73 val sup = a.getSuperClass.getNNF 67 val sup = a.getSuperClass.getNNF
74 sup match { 68 sup match {
75 case sup: OWLObjectUnionOf => 69 case sup: OWLObjectUnionOf =>
76 sup.asDisjunctSet.map( 70 Upperbound.factory.getOWLSubClassOfAxiom(sub, sup.asDisjunctSet.head)
77 Upperbound.factory.getOWLSubClassOfAxiom(sub, _) 71 case _ => axiom
78 )
79 case _ => List(axiom)
80 } 72 }
81 } 73 }
82 case _ => List(axiom) 74 case _ => axiom
83 } 75 }
84 76
85 /** Approximate a Horn-ALCHOIQ ontology to RSA 77 /** Approximate a Horn-ALCHOIQ ontology to RSA