diff options
author | Federico Igne <git@federicoigne.com> | 2021-09-29 16:43:01 +0100 |
---|---|---|
committer | Federico Igne <git@federicoigne.com> | 2021-09-29 16:43:01 +0100 |
commit | a5a4f5eba46c51c2a14e9915bfa34e78bff59030 (patch) | |
tree | 2bb20ae0d2ada44d3cc0cec7fc25d719bfe06f26 /src/main/scala/uk/ac/ox/cs/rsacomb/Main.scala | |
parent | b1799a0af7bd243fb24bff66682f6f848557c27d (diff) | |
download | RSAComb-a5a4f5eba46c51c2a14e9915bfa34e78bff59030.tar.gz RSAComb-a5a4f5eba46c51c2a14e9915bfa34e78bff59030.zip |
Add import of multiple queries
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.scala | 56 |
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 | } |