diff options
Diffstat (limited to 'src/main/scala/uk/ac/ox/cs/acqua')
3 files changed, 47 insertions, 24 deletions
diff --git a/src/main/scala/uk/ac/ox/cs/acqua/Main.scala b/src/main/scala/uk/ac/ox/cs/acqua/Main.scala index e8cfeb7..221c0e2 100644 --- a/src/main/scala/uk/ac/ox/cs/acqua/Main.scala +++ b/src/main/scala/uk/ac/ox/cs/acqua/Main.scala | |||
| @@ -57,29 +57,20 @@ object Acqua extends App { | |||
| 57 | reasoner.loadOntology(ontology.origin) | 57 | reasoner.loadOntology(ontology.origin) |
| 58 | reasoner.importData(properties.getDataPath()) | 58 | reasoner.importData(properties.getDataPath()) |
| 59 | if (reasoner.preprocess()) { | 59 | if (reasoner.preprocess()) { |
| 60 | Utility.logInfo("The ontology is consistent!"); | 60 | Utility logInfo "The ontology is consistent!" |
| 61 | } | 61 | } |
| 62 | else { | 62 | else { |
| 63 | Utility.logInfo("The ontology is inconsistent!"); | 63 | Utility logInfo "The ontology is inconsistent!" |
| 64 | reasoner.dispose(); | 64 | reasoner.dispose(); |
| 65 | // Exit somehow | ||
| 65 | } | 66 | } |
| 66 | 67 | ||
| 67 | if (config contains 'queries) { | 68 | if (config contains 'queries) { |
| 68 | val queries = | 69 | val queryManager = reasoner.getQueryManager() |
| 69 | RDFoxUtil.loadQueriesFromFiles( | 70 | config('queries).get[List[os.Path]].map(path => { |
| 70 | config('queries).get[List[os.Path]], | 71 | val queries = queryManager collectQueryRecords path.toString |
| 71 | RSA.Prefixes | 72 | reasoner evaluate queries |
| 72 | ) | 73 | }) |
| 73 | // for(String queryFile : properties.getQueryPath().split(";")) { | ||
| 74 | // Collection<QueryRecord> queryRecords = pagoda.getQueryManager().collectQueryRecords(queryFile); | ||
| 75 | // pagoda.evaluate(queryRecords); | ||
| 76 | } | 74 | } |
| 77 | } | 75 | } |
| 78 | 76 | ||
| 79 | |||
| 80 | // /* Perform query answering */ | ||
| 81 | // val answers = rsa ask queries | ||
| 82 | |||
| 83 | // /* Perform logging */ | ||
| 84 | // Logger write answers | ||
| 85 | // Logger.generateSimulationScripts(datapath, queries) | ||
diff --git a/src/main/scala/uk/ac/ox/cs/acqua/implicits/PagodaConverters.scala b/src/main/scala/uk/ac/ox/cs/acqua/implicits/PagodaConverters.scala index c7c582d..3663813 100644 --- a/src/main/scala/uk/ac/ox/cs/acqua/implicits/PagodaConverters.scala +++ b/src/main/scala/uk/ac/ox/cs/acqua/implicits/PagodaConverters.scala | |||
| @@ -16,14 +16,22 @@ | |||
| 16 | 16 | ||
| 17 | package uk.ac.ox.cs.acqua.implicits | 17 | package uk.ac.ox.cs.acqua.implicits |
| 18 | 18 | ||
| 19 | import java.util.Collection | ||
| 20 | import scala.collection.JavaConverters._ | ||
| 21 | |||
| 19 | import uk.ac.ox.cs.rsacomb.sparql.ConjunctiveQuery | 22 | import uk.ac.ox.cs.rsacomb.sparql.ConjunctiveQuery |
| 23 | import uk.ac.ox.cs.rsacomb.util.RSA | ||
| 20 | import uk.ac.ox.cs.pagoda.query.QueryRecord | 24 | import uk.ac.ox.cs.pagoda.query.QueryRecord |
| 21 | 25 | ||
| 22 | object PagodaConverters { | 26 | object PagodaConverters { |
| 23 | 27 | ||
| 24 | implicit def queryRecord2conjuctiveQuery(q: QueryRecord): ConjunctiveQuery = ??? | 28 | implicit def queryRecord2conjuctiveQuery(q: QueryRecord): ConjunctiveQuery = { |
| 29 | // TODO: check whether `q.id` is correct | ||
| 30 | ConjunctiveQuery.parse(q.id,q.getQueryText(),RSA.Prefixes).get | ||
| 31 | } | ||
| 25 | 32 | ||
| 26 | implicit def conjunctiveQuery2queryRecord(q: ConjunctiveQuery): QueryRecord = ??? | 33 | implicit def queryRecords2conjuctiveQueries(qs: Collection[QueryRecord]): List[ConjunctiveQuery] = |
| 34 | qs.asScala.map(queryRecord2conjuctiveQuery).toList | ||
| 27 | 35 | ||
| 28 | } | 36 | } |
| 29 | 37 | ||
diff --git a/src/main/scala/uk/ac/ox/cs/acqua/reasoner/RSAQueryReasoner.scala b/src/main/scala/uk/ac/ox/cs/acqua/reasoner/RSAQueryReasoner.scala index 6b98d79..ea84ca5 100644 --- a/src/main/scala/uk/ac/ox/cs/acqua/reasoner/RSAQueryReasoner.scala +++ b/src/main/scala/uk/ac/ox/cs/acqua/reasoner/RSAQueryReasoner.scala | |||
| @@ -16,6 +16,9 @@ | |||
| 16 | 16 | ||
| 17 | package uk.ac.ox.cs.acqua.reasoner | 17 | package uk.ac.ox.cs.acqua.reasoner |
| 18 | 18 | ||
| 19 | import java.util.Collection; | ||
| 20 | import scala.collection.JavaConverters._ | ||
| 21 | |||
| 19 | import org.semanticweb.owlapi.model.OWLOntology | 22 | import org.semanticweb.owlapi.model.OWLOntology |
| 20 | import uk.ac.ox.cs.rsacomb.RSAOntology | 23 | import uk.ac.ox.cs.rsacomb.RSAOntology |
| 21 | import uk.ac.ox.cs.rsacomb.approximation.{Approximation,Lowerbound} | 24 | import uk.ac.ox.cs.rsacomb.approximation.{Approximation,Lowerbound} |
| @@ -67,12 +70,33 @@ class RSAQueryReasoner(val origin: Ontology) extends QueryReasoner { | |||
| 67 | origin.isRSA | 70 | origin.isRSA |
| 68 | } | 71 | } |
| 69 | 72 | ||
| 70 | // TODO: probably need to override `evaluate` on multiple queries | 73 | /** Evaluates a collection of queries. |
| 71 | def evaluate(query: QueryRecord): Unit = { | 74 | * |
| 72 | rsa ask query | 75 | * Uses RSAComb internally to reuse part of the computation of |
| 76 | * multiple calls to [[uk.ac.ox.cs.rsacomb.RSAOntology.ask]]. | ||
| 77 | * | ||
| 78 | * TODO: perform logging of answers | ||
| 79 | */ | ||
| 80 | override def evaluate(queries: Collection[QueryRecord]): Unit = { | ||
| 81 | val answers = rsa ask queries | ||
| 82 | /* Perform logging */ | ||
| 83 | // Logger write answers | ||
| 84 | // Logger.generateSimulationScripts(datapath, queries) | ||
| 73 | } | 85 | } |
| 74 | 86 | ||
| 75 | def evaluateUpper(record: QueryRecord): Unit= { | 87 | /** Evaluates a single query. |
| 76 | ??? | 88 | * |
| 89 | * Uses RSAComb internally to reuse part of the computation of | ||
| 90 | * multiple calls to [[uk.ac.ox.cs.rsacomb.RSAOntology.ask]]. | ||
| 91 | * | ||
| 92 | * TODO: perform logging of answers | ||
| 93 | */ | ||
| 94 | def evaluate(query: QueryRecord): Unit = { | ||
| 95 | val answers = rsa ask query | ||
| 96 | /* Perform logging */ | ||
| 97 | // Logger write answers | ||
| 98 | // Logger.generateSimulationScripts(datapath, queries) | ||
| 77 | } | 99 | } |
| 100 | |||
| 101 | def evaluateUpper(record: QueryRecord): Unit= ??? | ||
| 78 | } | 102 | } |
