aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFederico Igne <federico.igne@cs.ox.ac.uk>2021-11-03 14:56:11 +0000
committerFederico Igne <federico.igne@cs.ox.ac.uk>2021-11-03 14:56:11 +0000
commitefcc56381d7ebcd12bb0a9836351ae20dc10d334 (patch)
treef7dba28f593d695fd64c7289e526c78bfcac9ee6
parent47a89f67f4acdbd55fd1cbfb704211937962e522 (diff)
downloadRSAComb-efcc56381d7ebcd12bb0a9836351ae20dc10d334.tar.gz
RSAComb-efcc56381d7ebcd12bb0a9836351ae20dc10d334.zip
Add option to specify the approximation algorithm from the CLI
-rw-r--r--src/main/scala/uk/ac/ox/cs/rsacomb/Main.scala4
-rw-r--r--src/main/scala/uk/ac/ox/cs/rsacomb/RSAConfig.scala10
2 files changed, 12 insertions, 2 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 fe88b4f..cbec9ec 100644
--- a/src/main/scala/uk/ac/ox/cs/rsacomb/Main.scala
+++ b/src/main/scala/uk/ac/ox/cs/rsacomb/Main.scala
@@ -29,7 +29,7 @@ import sparql.ConjunctiveQuery
29 29
30import uk.ac.ox.cs.rsacomb.ontology.Ontology 30import uk.ac.ox.cs.rsacomb.ontology.Ontology
31import uk.ac.ox.cs.rsacomb.converter.Normalizer 31import uk.ac.ox.cs.rsacomb.converter.Normalizer
32import uk.ac.ox.cs.rsacomb.approximation.{Upperbound, Lowerbound} 32import uk.ac.ox.cs.rsacomb.approximation.Approximation
33 33
34/** Main entry point to the program */ 34/** Main entry point to the program */
35object RSAComb extends App { 35object RSAComb extends App {
@@ -53,7 +53,7 @@ object RSAComb extends App {
53 //ontology.axioms foreach println 53 //ontology.axioms foreach println
54 54
55 /* Approximate the ontology to RSA */ 55 /* Approximate the ontology to RSA */
56 val toRSA = new Upperbound 56 val toRSA = config('approximation).get[Approximation[RSAOntology]]
57 val rsa = ontology approximate toRSA 57 val rsa = ontology approximate toRSA
58 58
59 if (config contains 'queries) { 59 if (config contains 'queries) {
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 4d96850..3e92d81 100644
--- a/src/main/scala/uk/ac/ox/cs/rsacomb/RSAConfig.scala
+++ b/src/main/scala/uk/ac/ox/cs/rsacomb/RSAConfig.scala
@@ -18,6 +18,7 @@ package uk.ac.ox.cs.rsacomb
18 18
19import scala.collection.mutable.Map 19import scala.collection.mutable.Map
20import util.Logger 20import util.Logger
21import approximation._
21 22
22case class RSAOption[+T](opt: T) { 23case class RSAOption[+T](opt: T) {
23 def get[T]: T = opt.asInstanceOf[T] 24 def get[T]: T = opt.asInstanceOf[T]
@@ -116,6 +117,13 @@ object RSAConfig {
116 } 117 }
117 case flag @ ("-a" | "--answers") :: answers :: tail => 118 case flag @ ("-a" | "--answers") :: answers :: tail =>
118 parse(tail, config += ('answers -> getPath(answers))) 119 parse(tail, config += ('answers -> getPath(answers)))
120 case flag @ ("-x" | "--approximation") :: _approx :: tail => {
121 val approx = _approx match {
122 case "lowerbound" => new Lowerbound
123 case "upperbound" => new Upperbound
124 }
125 parse(tail, config += ('approximation -> approx))
126 }
119 case flag @ ("-q" | "--queries") :: _query :: tail => { 127 case flag @ ("-q" | "--queries") :: _query :: tail => {
120 val query = getPath(_query) 128 val query = getPath(_query)
121 if (!os.isFile(query)) 129 if (!os.isFile(query))
@@ -149,6 +157,8 @@ object RSAConfig {
149 exit("The following flag is mandatory: '-o' or '--ontology'.") 157 exit("The following flag is mandatory: '-o' or '--ontology'.")
150 if (!config.contains('data)) 158 if (!config.contains('data))
151 config += ('data -> List.empty[os.Path]) 159 config += ('data -> List.empty[os.Path])
160 if (!config.contains('approximation))
161 config += ('approximation -> new Lowerbound)
152 config 162 config
153 } 163 }
154} 164}