aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/uk/ac/ox/cs/rsacomb/Main.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/scala/uk/ac/ox/cs/rsacomb/Main.scala')
-rw-r--r--src/main/scala/uk/ac/ox/cs/rsacomb/Main.scala27
1 files changed, 23 insertions, 4 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 c030301..22b1f76 100644
--- a/src/main/scala/uk/ac/ox/cs/rsacomb/Main.scala
+++ b/src/main/scala/uk/ac/ox/cs/rsacomb/Main.scala
@@ -19,6 +19,7 @@ package uk.ac.ox.cs.rsacomb
19import java.io.{File, PrintWriter} 19import java.io.{File, PrintWriter}
20import java.nio.file.{Path, Paths, InvalidPathException} 20import java.nio.file.{Path, Paths, InvalidPathException}
21import java.util.HashMap 21import java.util.HashMap
22import scala.collection.mutable.Map
22import scala.collection.JavaConverters._ 23import scala.collection.JavaConverters._
23import tech.oxfordsemantic.jrdfox.client.UpdateType 24import tech.oxfordsemantic.jrdfox.client.UpdateType
24import tech.oxfordsemantic.jrdfox.logic.expression.{IRI, Term} 25import tech.oxfordsemantic.jrdfox.logic.expression.{IRI, Term}
@@ -50,7 +51,15 @@ object RSAConfig {
50 -h | -? | --help 51 -h | -? | --help
51 print this help message 52 print this help message
52 53
53 -q <file> | --queries <file> 54 -l | --logger <level>
55 specify the logger verbosity. Values are: quiet, normal (default),
56 debug, verbose.
57
58 -o | --output <file>
59 path to the output file for the answers to the query (in JSON
60 format)
61
62 -q | --queries <file>
54 path to a file containing a single SPARQL query. If no query 63 path to a file containing a single SPARQL query. If no query
55 is provided, only the approximation to RSA will be performed. 64 is provided, only the approximation to RSA will be performed.
56 65
@@ -98,10 +107,19 @@ object RSAConfig {
98 println(help) 107 println(help)
99 sys.exit(0) 108 sys.exit(0)
100 } 109 }
110 case flag @ ("-l" | "--logger") :: _level :: tail => {
111 val level = _level match {
112 case "quiet" => Logger.QUIET
113 case "debug" => Logger.DEBUG
114 case "verbose" => Logger.VERBOSE
115 case _ => Logger.NORMAL
116 }
117 parse(tail, config += ('logger -> level))
118 }
101 case flag @ ("-o" | "--output") :: _output :: tail => 119 case flag @ ("-o" | "--output") :: _output :: tail =>
102 try { 120 try {
103 val output = Paths.get(_output) 121 val output = Paths.get(_output)
104 parse(tail, config ++ Map('output -> output)) 122 parse(tail, config += ('output -> output))
105 } catch { 123 } catch {
106 case e: InvalidPathException => 124 case e: InvalidPathException =>
107 exit(s"'${_output}' is not a valid filename.") 125 exit(s"'${_output}' is not a valid filename.")
@@ -110,7 +128,7 @@ object RSAConfig {
110 val query = new File(_query) 128 val query = new File(_query)
111 if (!query.isFile) 129 if (!query.isFile)
112 exit(s"'$query' is not a valid filename.") 130 exit(s"'$query' is not a valid filename.")
113 parse(tail, config ++ Map('queries -> query)) 131 parse(tail, config += ('queries -> query))
114 } 132 }
115 case _ontology :: _data => { 133 case _ontology :: _data => {
116 val ontology = new File(_ontology) 134 val ontology = new File(_ontology)
@@ -119,7 +137,7 @@ object RSAConfig {
119 if (!file.isFile) 137 if (!file.isFile)
120 exit(s"'$file' is not a valid filename.") 138 exit(s"'$file' is not a valid filename.")
121 } 139 }
122 finalise(config ++ Map('ontology -> ontology, 'data -> data)) 140 finalise(config += ('ontology -> ontology) += ('data -> data))
123 } 141 }
124 case a => exit(s"Invalid sequence of arguments '${a.mkString(" ")}'.") 142 case a => exit(s"Invalid sequence of arguments '${a.mkString(" ")}'.")
125 } 143 }
@@ -134,6 +152,7 @@ object RSAComb extends App {
134 152
135 /* Command-line options */ 153 /* Command-line options */
136 val config = RSAConfig.parse(args.toList) 154 val config = RSAConfig.parse(args.toList)
155 Logger.level = config('logger).get[Logger.Level]
137 156
138 /* Load original ontology and normalize it */ 157 /* Load original ontology and normalize it */
139 val ontology = Ontology( 158 val ontology = Ontology(