Skip to content

Commit

Permalink
Merge branch 'approximation'
Browse files Browse the repository at this point in the history
  • Loading branch information
dyamon committed Jul 27, 2021
2 parents c597b5e + 7d61970 commit d017662
Show file tree
Hide file tree
Showing 9 changed files with 886 additions and 415 deletions.
4 changes: 2 additions & 2 deletions src/main/scala/uk/ac/ox/cs/rsacomb/CanonicalModel.scala
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ class CanonicalModel(val ontology: RSAOntology) {
val (facts, rules): (List[TupleTableAtom], List[Rule]) = {
// Compute rules from ontology axioms
val (facts, rules) = {
val term = RSAOntology.genFreshVariable()
val unsafe = ontology.unsafeRoles
val term = RSAUtil.genFreshVariable()
val unsafe = ontology.unsafe
ontology.axioms
.map(a =>
CanonicalModelConverter.convert(a, term, unsafe, Constant(a), Empty)
Expand Down
41 changes: 24 additions & 17 deletions src/main/scala/uk/ac/ox/cs/rsacomb/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ import tech.oxfordsemantic.jrdfox.logic.sparql.statement.SelectQuery
import util.{Logger, RDFoxUtil, RSA}
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.LowerBound

case class RSAOption[+T](opt: T) {
def get[T]: T = opt.asInstanceOf[T]
}
Expand Down Expand Up @@ -122,12 +126,15 @@ object RSAComb extends App {
/* Command-line options */
val config = RSAConfig.parse(args.toList)

val ontology = RSAOntology(
/* Load original ontology and normalize it */
val ontology = Ontology(
config('ontology).get[File],
config('data).get[List[File]]: _*
)
val rsa = ontology.toRSA()
ontology.statistics()
config('data).get[List[File]]
).normalize(new Normalizer)

/* Approximate the ontology to RSA */
val toRSA = new LowerBound
val rsa = ontology approximate toRSA

if (config contains 'query) {
val query =
Expand All @@ -140,18 +147,18 @@ object RSAComb extends App {
Logger.print(s"$answers", Logger.VERBOSE)
Logger print s"Number of answers: ${answers.length} (${answers.lengthWithMultiplicity})"
// Retrieve unfiltered answers
val unfiltered = rsa.queryDataStore(
"""
SELECT (count(?K) as ?COUNT)
WHERE {
?K a rsa:QM .
}
""",
RSA.Prefixes
)
unfiltered.foreach((u) =>
Logger print s"Number of unfiltered answers: ${u.head._2}"
)
// val unfiltered = rsa.queryDataStore(
// """
// SELECT (count(?K) as ?COUNT)
// WHERE {
// ?K a rsa:QM .
// }
// """,
// RSA.Prefixes
// )
// unfiltered.foreach((u) =>
// Logger print s"Number of unfiltered answers: ${u.head._2}"
// )
}
case None =>
throw new RuntimeException("Submitted query is not conjunctive")
Expand Down
Loading

0 comments on commit d017662

Please sign in to comment.