diff options
| author | Federico Igne <git@federicoigne.com> | 2021-07-22 10:29:49 +0100 |
|---|---|---|
| committer | Federico Igne <git@federicoigne.com> | 2021-07-22 10:29:49 +0100 |
| commit | b8b8a69ec1d1c93d5cfcfba4dbd002d5c90dd4c6 (patch) | |
| tree | 62c66038b679b3065c6fdbe4f7e861959b56debe | |
| parent | cb8572606f8951213bcfe9e6667caa208ad3d189 (diff) | |
| download | RSAComb-b8b8a69ec1d1c93d5cfcfba4dbd002d5c90dd4c6.tar.gz RSAComb-b8b8a69ec1d1c93d5cfcfba4dbd002d5c90dd4c6.zip | |
Remove normalization step from lowerbound computation
| -rw-r--r-- | src/main/scala/uk/ac/ox/cs/rsacomb/approximation/lowerbound.scala | 27 | ||||
| -rw-r--r-- | src/main/scala/uk/ac/ox/cs/rsacomb/ontologies/Ontology.scala | 6 |
2 files changed, 15 insertions, 18 deletions
diff --git a/src/main/scala/uk/ac/ox/cs/rsacomb/approximation/lowerbound.scala b/src/main/scala/uk/ac/ox/cs/rsacomb/approximation/lowerbound.scala index 07f10a4..766ea0e 100644 --- a/src/main/scala/uk/ac/ox/cs/rsacomb/approximation/lowerbound.scala +++ b/src/main/scala/uk/ac/ox/cs/rsacomb/approximation/lowerbound.scala | |||
| @@ -14,7 +14,6 @@ import scalax.collection.GraphTraversal._ | |||
| 14 | 14 | ||
| 15 | import uk.ac.ox.cs.rsacomb.RSAOntology | 15 | import uk.ac.ox.cs.rsacomb.RSAOntology |
| 16 | import uk.ac.ox.cs.rsacomb.RSAUtil | 16 | import uk.ac.ox.cs.rsacomb.RSAUtil |
| 17 | import uk.ac.ox.cs.rsacomb.converter.Normalizer | ||
| 18 | import uk.ac.ox.cs.rsacomb.ontology.Ontology | 17 | import uk.ac.ox.cs.rsacomb.ontology.Ontology |
| 19 | 18 | ||
| 20 | object LowerBound { | 19 | object LowerBound { |
| @@ -47,23 +46,14 @@ class LowerBound extends Approximation[RSAOntology] { | |||
| 47 | /** Simplify conversion between OWLAPI and RDFox concepts */ | 46 | /** Simplify conversion between OWLAPI and RDFox concepts */ |
| 48 | import uk.ac.ox.cs.rsacomb.implicits.RDFox._ | 47 | import uk.ac.ox.cs.rsacomb.implicits.RDFox._ |
| 49 | 48 | ||
| 50 | private val normalizer = new Normalizer() | ||
| 51 | |||
| 52 | /** Main entry point for the approximation algorithm */ | 49 | /** Main entry point for the approximation algorithm */ |
| 53 | def approximate(ontology: Ontology): RSAOntology = { | 50 | def approximate(ontology: Ontology): RSAOntology = |
| 54 | /* Normalize axioms */ | 51 | toRSA( |
| 55 | val axioms1 = ontology.axioms flatMap normalizer.normalize | 52 | new Ontology( |
| 56 | /* Delete any axiom outside of ALCHOIQ */ | 53 | ontology.axioms filterNot inALCHOIQ flatMap shift, |
| 57 | val axioms2 = axioms1 filterNot inALCHOIQ | 54 | ontology.datafiles |
| 58 | /* Shift any axiom with disjunction on the rhs */ | 55 | ) |
| 59 | val axioms3 = for { | 56 | ) |
| 60 | a1 <- axioms1 | ||
| 61 | a2 <- shift(a1) | ||
| 62 | a3 <- normalizer.normalize(a2) | ||
| 63 | } yield a3 | ||
| 64 | /* Approximate to RSA */ | ||
| 65 | toRSA(new Ontology(axioms3, ontology.datafiles)) | ||
| 66 | } | ||
| 67 | 57 | ||
| 68 | /** Discards all axioms outside ALCHOIQ */ | 58 | /** Discards all axioms outside ALCHOIQ */ |
| 69 | private def inALCHOIQ(axiom: OWLLogicalAxiom): Boolean = | 59 | private def inALCHOIQ(axiom: OWLLogicalAxiom): Boolean = |
| @@ -114,6 +104,7 @@ class LowerBound extends Approximation[RSAOntology] { | |||
| 114 | * | 104 | * |
| 115 | * becomes | 105 | * becomes |
| 116 | * | 106 | * |
| 107 | * A n nB1 n nB2 n nB3 -> bot . | ||
| 117 | * A n nB1 n nB2 -> B3 . | 108 | * A n nB1 n nB2 -> B3 . |
| 118 | * A n nB1 n nB3 -> B2 . | 109 | * A n nB1 n nB3 -> B2 . |
| 119 | * A n nB2 n nB3 -> B1 . | 110 | * A n nB2 n nB3 -> B1 . |
| @@ -121,6 +112,8 @@ class LowerBound extends Approximation[RSAOntology] { | |||
| 121 | * | 112 | * |
| 122 | * where nA, nB1, nB2, nB3 are fresh predicates "corresponding" to | 113 | * where nA, nB1, nB2, nB3 are fresh predicates "corresponding" to |
| 123 | * the negation of A, B1, B2, B3 respectively. | 114 | * the negation of A, B1, B2, B3 respectively. |
| 115 | * | ||
| 116 | * @note this method maintains the normal form of the input axiom. | ||
| 124 | */ | 117 | */ |
| 125 | private def shift(axiom: OWLLogicalAxiom): List[OWLLogicalAxiom] = | 118 | private def shift(axiom: OWLLogicalAxiom): List[OWLLogicalAxiom] = |
| 126 | axiom match { | 119 | axiom match { |
diff --git a/src/main/scala/uk/ac/ox/cs/rsacomb/ontologies/Ontology.scala b/src/main/scala/uk/ac/ox/cs/rsacomb/ontologies/Ontology.scala index 723bcaa..d73704f 100644 --- a/src/main/scala/uk/ac/ox/cs/rsacomb/ontologies/Ontology.scala +++ b/src/main/scala/uk/ac/ox/cs/rsacomb/ontologies/Ontology.scala | |||
| @@ -282,7 +282,11 @@ class Ontology(val axioms: List[OWLLogicalAxiom], val datafiles: List[File]) { | |||
| 282 | * @param normalizer the normalization technique to be used. | 282 | * @param normalizer the normalization technique to be used. |
| 283 | * @return a new normalized [[Ontology]]. | 283 | * @return a new normalized [[Ontology]]. |
| 284 | */ | 284 | */ |
| 285 | def normalize(normalizer: Normalizer): Ontology = ??? | 285 | def normalize(normalizer: Normalizer): Ontology = |
| 286 | new Ontology( | ||
| 287 | axioms flatMap normalizer.normalize, | ||
| 288 | datafiles | ||
| 289 | ) | ||
| 286 | 290 | ||
| 287 | /** Approximate the ontology according to the given approximation | 291 | /** Approximate the ontology according to the given approximation |
| 288 | * technique. | 292 | * technique. |
