From efcc56381d7ebcd12bb0a9836351ae20dc10d334 Mon Sep 17 00:00:00 2001 From: Federico Igne Date: Wed, 3 Nov 2021 14:56:11 +0000 Subject: Add option to specify the approximation algorithm from the CLI --- src/main/scala/uk/ac/ox/cs/rsacomb/Main.scala | 4 ++-- src/main/scala/uk/ac/ox/cs/rsacomb/RSAConfig.scala | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'src') 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 import uk.ac.ox.cs.rsacomb.ontology.Ontology import uk.ac.ox.cs.rsacomb.converter.Normalizer -import uk.ac.ox.cs.rsacomb.approximation.{Upperbound, Lowerbound} +import uk.ac.ox.cs.rsacomb.approximation.Approximation /** Main entry point to the program */ object RSAComb extends App { @@ -53,7 +53,7 @@ object RSAComb extends App { //ontology.axioms foreach println /* Approximate the ontology to RSA */ - val toRSA = new Upperbound + val toRSA = config('approximation).get[Approximation[RSAOntology]] val rsa = ontology approximate toRSA 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 import scala.collection.mutable.Map import util.Logger +import approximation._ case class RSAOption[+T](opt: T) { def get[T]: T = opt.asInstanceOf[T] @@ -116,6 +117,13 @@ object RSAConfig { } case flag @ ("-a" | "--answers") :: answers :: tail => parse(tail, config += ('answers -> getPath(answers))) + case flag @ ("-x" | "--approximation") :: _approx :: tail => { + val approx = _approx match { + case "lowerbound" => new Lowerbound + case "upperbound" => new Upperbound + } + parse(tail, config += ('approximation -> approx)) + } case flag @ ("-q" | "--queries") :: _query :: tail => { val query = getPath(_query) if (!os.isFile(query)) @@ -149,6 +157,8 @@ object RSAConfig { exit("The following flag is mandatory: '-o' or '--ontology'.") if (!config.contains('data)) config += ('data -> List.empty[os.Path]) + if (!config.contains('approximation)) + config += ('approximation -> new Lowerbound) config } } -- cgit v1.2.3