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.scala56
1 files changed, 26 insertions, 30 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 a1fd20f..b1fd721 100644
--- a/src/main/scala/uk/ac/ox/cs/rsacomb/Main.scala
+++ b/src/main/scala/uk/ac/ox/cs/rsacomb/Main.scala
@@ -49,7 +49,7 @@ object RSAConfig {
49 -h | -? | --help 49 -h | -? | --help
50 print this help message 50 print this help message
51 51
52 -q <file> | --query <file> 52 -q <file> | --queries <file>
53 path to a file containing a single SPARQL query. If no query 53 path to a file containing a single SPARQL query. If no query
54 is provided, only the approximation to RSA will be performed. 54 is provided, only the approximation to RSA will be performed.
55 55
@@ -97,11 +97,11 @@ object RSAConfig {
97 println(help) 97 println(help)
98 sys.exit(0) 98 sys.exit(0)
99 } 99 }
100 case flag @ ("-q" | "--query") :: _query :: tail => { 100 case flag @ ("-q" | "--queries") :: _query :: tail => {
101 val query = new File(_query) 101 val query = new File(_query)
102 if (!query.isFile) 102 if (!query.isFile)
103 exit(s"'$query' is not a valid filename.") 103 exit(s"'$query' is not a valid filename.")
104 parse(tail, config ++ Map('query -> query)) 104 parse(tail, config ++ Map('queries -> query))
105 } 105 }
106 case _ontology :: _data => { 106 case _ontology :: _data => {
107 val ontology = new File(_ontology) 107 val ontology = new File(_ontology)
@@ -132,36 +132,32 @@ object RSAComb extends App {
132 config('data).get[List[File]] 132 config('data).get[List[File]]
133 ).normalize(new Normalizer) 133 ).normalize(new Normalizer)
134 134
135 //ontology.axioms foreach println
136
135 /* Approximate the ontology to RSA */ 137 /* Approximate the ontology to RSA */
136 val toRSA = new Upperbound 138 val toRSA = new Upperbound
137 val rsa = ontology approximate toRSA 139 val rsa = ontology approximate toRSA
138 140
139 if (config contains 'query) { 141 if (config contains 'queries) {
140 val query = 142 val queries =
141 RDFoxUtil.loadQueryFromFile(config('query).get[File].getAbsoluteFile) 143 RDFoxUtil.loadQueriesFromFile(config('queries).get[File].getAbsoluteFile)
142 144
143 ConjunctiveQuery.parse(query) match { 145 val answers = rsa ask queries
144 case Some(query) => { 146
145 // Retrieve answers 147 // Logger.print(s"$answers", Logger.VERBOSE)
146 val answers = rsa ask query 148 // Logger print s"Number of answers: ${answers.length} (${answers.lengthWithMultiplicity})"
147 Logger.print(s"$answers", Logger.VERBOSE) 149 // Retrieve unfiltered answers
148 Logger print s"Number of answers: ${answers.length} (${answers.lengthWithMultiplicity})" 150 // val unfiltered = rsa.queryDataStore(
149 // Retrieve unfiltered answers 151 // """
150 // val unfiltered = rsa.queryDataStore( 152 // SELECT (count(?K) as ?COUNT)
151 // """ 153 // WHERE {
152 // SELECT (count(?K) as ?COUNT) 154 // ?K a rsa:QM .
153 // WHERE { 155 // }
154 // ?K a rsa:QM . 156 // """,
155 // } 157 // RSA.Prefixes
156 // """, 158 // )
157 // RSA.Prefixes 159 // unfiltered.foreach((u) =>
158 // ) 160 // Logger print s"Number of unfiltered answers: ${u.head._2}"
159 // unfiltered.foreach((u) => 161 // )
160 // Logger print s"Number of unfiltered answers: ${u.head._2}"
161 // )
162 }
163 case None =>
164 throw new RuntimeException("Submitted query is not conjunctive")
165 }
166 } 162 }
167} 163}