aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFederico Igne <federico.igne@cs.ox.ac.uk>2022-06-01 17:45:17 +0100
committerFederico Igne <federico.igne@cs.ox.ac.uk>2022-06-01 17:45:17 +0100
commitf480a850161445bb3dd9ead500810db21dfa1451 (patch)
treee9846ae1c00cf6beff7defce306da1eab3a193eb
parentf56365b77f8519d2af3ac9d352086f1568dbf063 (diff)
downloadRSAComb-f480a850161445bb3dd9ead500810db21dfa1451.tar.gz
RSAComb-f480a850161445bb3dd9ead500810db21dfa1451.zip
feat: implicitly propagate configs to approximations
-rw-r--r--src/main/scala/uk/ac/ox/cs/rsacomb/Main.scala2
-rw-r--r--src/main/scala/uk/ac/ox/cs/rsacomb/RSAConfig.scala2
-rw-r--r--src/main/scala/uk/ac/ox/cs/rsacomb/approximation/Lowerbound.scala12
-rw-r--r--src/main/scala/uk/ac/ox/cs/rsacomb/package.scala1
-rw-r--r--src/test/scala/uk/ac/ox/cs/rsacomb/CanonicalModelSpec.scala24
5 files changed, 27 insertions, 14 deletions
diff --git a/src/main/scala/uk/ac/ox/cs/rsacomb/Main.scala b/src/main/scala/uk/ac/ox/cs/rsacomb/Main.scala
index 8784651..233e170 100644
--- a/src/main/scala/uk/ac/ox/cs/rsacomb/Main.scala
+++ b/src/main/scala/uk/ac/ox/cs/rsacomb/Main.scala
@@ -22,7 +22,7 @@ import ontology.{Ontology,RSAOntology}
22import util.{Logger, RDFoxUtil, RSA} 22import util.{Logger, RDFoxUtil, RSA}
23 23
24object RSAComb extends App { 24object RSAComb extends App {
25 val config = RSAConfig.parse(args.toList) 25 implicit val config = RSAConfig parse args.toList
26 RSAConfig describe config 26 RSAConfig describe config
27 27
28 /* Configure logger */ 28 /* Configure logger */
diff --git a/src/main/scala/uk/ac/ox/cs/rsacomb/RSAConfig.scala b/src/main/scala/uk/ac/ox/cs/rsacomb/RSAConfig.scala
index 32460b4..2dcd850 100644
--- a/src/main/scala/uk/ac/ox/cs/rsacomb/RSAConfig.scala
+++ b/src/main/scala/uk/ac/ox/cs/rsacomb/RSAConfig.scala
@@ -74,7 +74,7 @@ object RSAConfig {
74 """ 74 """
75 75
76 /** Default config values */ 76 /** Default config values */
77 private val default: Config = Map( 77 val default: Config = Map(
78 'transitive -> false, 78 'transitive -> false,
79 'data -> List.empty[os.Path], 79 'data -> List.empty[os.Path],
80 'approximation -> 'lowerbound 80 'approximation -> 'lowerbound
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 1b72699..154cbd1 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
@@ -1,7 +1,5 @@
1package uk.ac.ox.cs.rsacomb.approximation 1package uk.ac.ox.cs.rsacomb.approximation
2 2
3import java.io.File
4
5import org.semanticweb.owlapi.apibinding.OWLManager 3import org.semanticweb.owlapi.apibinding.OWLManager
6import org.semanticweb.owlapi.model.{IRI => OWLIRI, _} 4import org.semanticweb.owlapi.model.{IRI => OWLIRI, _}
7 5
@@ -15,6 +13,7 @@ import scalax.collection.GraphTraversal._
15import uk.ac.ox.cs.rsacomb.ontology.RSAOntology 13import uk.ac.ox.cs.rsacomb.ontology.RSAOntology
16import uk.ac.ox.cs.rsacomb.ontology.Ontology 14import uk.ac.ox.cs.rsacomb.ontology.Ontology
17import uk.ac.ox.cs.rsacomb.util.{DataFactory, RDFoxUtil, RSA} 15import uk.ac.ox.cs.rsacomb.util.{DataFactory, RDFoxUtil, RSA}
16import uk.ac.ox.cs.rsacomb.RSAConfig
18 17
19object Lowerbound { 18object Lowerbound {
20 19
@@ -38,8 +37,9 @@ object Lowerbound {
38 * 37 *
39 * @see [[uk.ac.ox.cs.rsacomb.converter.Normalizer]] 38 * @see [[uk.ac.ox.cs.rsacomb.converter.Normalizer]]
40 */ 39 */
41class Lowerbound(implicit fresh: DataFactory) 40class Lowerbound(
42 extends Approximation[RSAOntology] { 41 implicit fresh: DataFactory, config: RSAConfig.Config
42) extends Approximation[RSAOntology] {
43 43
44 /** Simplify conversion between Java and Scala collections */ 44 /** Simplify conversion between Java and Scala collections */
45 import uk.ac.ox.cs.rsacomb.implicits.JavaCollections._ 45 import uk.ac.ox.cs.rsacomb.implicits.JavaCollections._
@@ -84,9 +84,9 @@ class Lowerbound(implicit fresh: DataFactory)
84 case _ => true 84 case _ => true
85 } 85 }
86 } 86 }
87 case a: OWLTransitiveObjectPropertyAxiom => false 87 case a: OWLTransitiveObjectPropertyAxiom => config('transitive).get[Boolean]
88 case a: OWLReflexiveObjectPropertyAxiom => false 88 case a: OWLReflexiveObjectPropertyAxiom => false
89 case a: OWLSubPropertyChainOfAxiom => true /*TODO: should we leave it? */ 89 case a: OWLSubPropertyChainOfAxiom => config('transitive).get[Boolean]
90 case a: OWLAsymmetricObjectPropertyAxiom => false 90 case a: OWLAsymmetricObjectPropertyAxiom => false
91 case a => true 91 case a => true
92 } 92 }
diff --git a/src/main/scala/uk/ac/ox/cs/rsacomb/package.scala b/src/main/scala/uk/ac/ox/cs/rsacomb/package.scala
index 53fa095..b8144c4 100644
--- a/src/main/scala/uk/ac/ox/cs/rsacomb/package.scala
+++ b/src/main/scala/uk/ac/ox/cs/rsacomb/package.scala
@@ -18,4 +18,5 @@ package uk.ac.ox.cs
18package object rsacomb { 18package object rsacomb {
19 19
20 implicit val seed: util.DataFactory = util.DataFactory(0) 20 implicit val seed: util.DataFactory = util.DataFactory(0)
21
21} 22}
diff --git a/src/test/scala/uk/ac/ox/cs/rsacomb/CanonicalModelSpec.scala b/src/test/scala/uk/ac/ox/cs/rsacomb/CanonicalModelSpec.scala
index 32f7d9b..933441b 100644
--- a/src/test/scala/uk/ac/ox/cs/rsacomb/CanonicalModelSpec.scala
+++ b/src/test/scala/uk/ac/ox/cs/rsacomb/CanonicalModelSpec.scala
@@ -31,7 +31,7 @@ import tech.oxfordsemantic.jrdfox.logic.expression.Variable
31import scala.collection.JavaConverters._ 31import scala.collection.JavaConverters._
32 32
33import uk.ac.ox.cs.rsacomb.ontology.RSAOntology 33import uk.ac.ox.cs.rsacomb.ontology.RSAOntology
34import uk.ac.ox.cs.rsacomb.approximation.Lowerbound 34import uk.ac.ox.cs.rsacomb.approximation._
35import uk.ac.ox.cs.rsacomb.ontology.Ontology 35import uk.ac.ox.cs.rsacomb.ontology.Ontology
36import uk.ac.ox.cs.rsacomb.converter.{SkolemStrategy, NoSkolem} 36import uk.ac.ox.cs.rsacomb.converter.{SkolemStrategy, NoSkolem}
37import uk.ac.ox.cs.rsacomb.suffix.Empty 37import uk.ac.ox.cs.rsacomb.suffix.Empty
@@ -39,7 +39,19 @@ import uk.ac.ox.cs.rsacomb.util.{Logger, RDFoxUtil, RSA}
39 39
40object Ontology1_CanonicalModelSpec { 40object Ontology1_CanonicalModelSpec {
41 41
42 Logger.level = Logger.QUIET 42 implicit var config = RSAConfig parse List(
43 "--logger", "quiet",
44 "--approximation", "lowerbound",
45 "--ontology", "examples/example1.ttl",
46 )
47
48 if (config.contains('logger))
49 Logger.level = config('logger).get[Logger.Level]
50
51 val toRSA = config('approximation).get[Symbol] match {
52 case 'lowerbound => new Lowerbound
53 case 'upperbound => new Upperbound
54 }
43 55
44 /* Renderer to display OWL Axioms with DL syntax*/ 56 /* Renderer to display OWL Axioms with DL syntax*/
45 val renderer = new DLSyntaxObjectRenderer() 57 val renderer = new DLSyntaxObjectRenderer()
@@ -47,8 +59,8 @@ object Ontology1_CanonicalModelSpec {
47 def base(str: String): IRI = 59 def base(str: String): IRI =
48 IRI.create("http://example.com/rsa_example.owl#" + str) 60 IRI.create("http://example.com/rsa_example.owl#" + str)
49 61
50 val ontology_path = os.pwd / "examples" / "example1.ttl" 62 val ontopath = config('ontology).get[os.Path]
51 val ontology = Ontology(ontology_path, List()).approximate(new Lowerbound) 63 val ontology = Ontology(ontopath, List.empty) approximate toRSA
52 val program = ontology.canonicalModel 64 val program = ontology.canonicalModel
53 val converter = program.CanonicalModelConverter 65 val converter = program.CanonicalModelConverter
54 66
@@ -257,8 +269,8 @@ class Ontology1_CanonicalModelSpec
257// def base(str: String): IRI = 269// def base(str: String): IRI =
258// IRI.create("http://example.com/rsa_example.owl#" + str) 270// IRI.create("http://example.com/rsa_example.owl#" + str)
259 271
260// val ontology_path: File = new File("examples/example2.owl") 272// val ontopath: File = new File("examples/example2.owl")
261// val ontology = Ontology(ontology_path, List()).approximate(new Lowerbound) 273// val ontology = Ontology(ontopath, List()).approximate(new Lowerbound)
262// val program = ontology.canonicalModel 274// val program = ontology.canonicalModel
263// val converter = program.CanonicalModelConverter 275// val converter = program.CanonicalModelConverter
264 276