aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/uk/ac/ox/cs/rsacomb/RSAOntology.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/scala/uk/ac/ox/cs/rsacomb/RSAOntology.scala')
-rw-r--r--src/main/scala/uk/ac/ox/cs/rsacomb/RSAOntology.scala27
1 files changed, 13 insertions, 14 deletions
diff --git a/src/main/scala/uk/ac/ox/cs/rsacomb/RSAOntology.scala b/src/main/scala/uk/ac/ox/cs/rsacomb/RSAOntology.scala
index 4dd554a..fef4cfa 100644
--- a/src/main/scala/uk/ac/ox/cs/rsacomb/RSAOntology.scala
+++ b/src/main/scala/uk/ac/ox/cs/rsacomb/RSAOntology.scala
@@ -7,7 +7,7 @@ import java.util.stream.{Collectors, Stream}
7import java.io.File 7import java.io.File
8import org.semanticweb.owlapi.apibinding.OWLManager 8import org.semanticweb.owlapi.apibinding.OWLManager
9import org.semanticweb.owlapi.util.OWLOntologyMerger 9import org.semanticweb.owlapi.util.OWLOntologyMerger
10import org.semanticweb.owlapi.model.{OWLOntology, OWLAxiom} 10import org.semanticweb.owlapi.model.{OWLOntology, OWLAxiom, OWLLogicalAxiom}
11import org.semanticweb.owlapi.model.{ 11import org.semanticweb.owlapi.model.{
12 OWLClass, 12 OWLClass,
13 OWLObjectProperty, 13 OWLObjectProperty,
@@ -82,30 +82,28 @@ object RSAOntology {
82class RSAOntology(val ontology: OWLOntology) { 82class RSAOntology(val ontology: OWLOntology) {
83 83
84 import uk.ac.ox.cs.rsacomb.implicits.RSAAxiom._ 84 import uk.ac.ox.cs.rsacomb.implicits.RSAAxiom._
85 import uk.ac.ox.cs.rsacomb.implicits.JavaCollections._
85 86
86 // Gather TBox/RBox/ABox from original ontology 87 // Gather TBox/RBox/ABox from original ontology
87 val tbox: List[OWLAxiom] = 88 val tbox: List[OWLLogicalAxiom] =
88 ontology 89 ontology
89 .tboxAxioms(Imports.INCLUDED) 90 .tboxAxioms(Imports.INCLUDED)
90 .collect(Collectors.toList()) 91 .collect(Collectors.toList())
91 .asScala 92 .collect { case a: OWLLogicalAxiom => a }
92 .toList
93 93
94 val rbox: List[OWLAxiom] = 94 val rbox: List[OWLLogicalAxiom] =
95 ontology 95 ontology
96 .rboxAxioms(Imports.INCLUDED) 96 .rboxAxioms(Imports.INCLUDED)
97 .collect(Collectors.toList()) 97 .collect(Collectors.toList())
98 .asScala 98 .collect { case a: OWLLogicalAxiom => a }
99 .toList
100 99
101 val abox: List[OWLAxiom] = 100 val abox: List[OWLLogicalAxiom] =
102 ontology 101 ontology
103 .aboxAxioms(Imports.INCLUDED) 102 .aboxAxioms(Imports.INCLUDED)
104 .collect(Collectors.toList()) 103 .collect(Collectors.toList())
105 .asScala 104 .collect { case a: OWLLogicalAxiom => a }
106 .toList
107 105
108 val axioms: List[OWLAxiom] = abox ::: tbox ::: rbox 106 val axioms: List[OWLLogicalAxiom] = abox ::: tbox ::: rbox
109 107
110 /* Retrieve individuals in the original ontology 108 /* Retrieve individuals in the original ontology
111 */ 109 */
@@ -267,8 +265,8 @@ class RSAOntology(val ontology: OWLOntology) {
267 ): Graph[Resource, UnDiEdge] = { 265 ): Graph[Resource, UnDiEdge] = {
268 val query = "SELECT ?X ?Y WHERE { ?X rsa:E ?Y }" 266 val query = "SELECT ?X ?Y WHERE { ?X rsa:E ?Y }"
269 val answers = RDFoxUtil.submitQuery(data, query, RSA.Prefixes).get 267 val answers = RDFoxUtil.submitQuery(data, query, RSA.Prefixes).get
270 var edges: Seq[UnDiEdge[Resource]] = answers.map { 268 var edges: Seq[UnDiEdge[Resource]] = answers.map { case Seq(n1, n2) =>
271 case Seq(n1, n2) => UnDiEdge(n1, n2) 269 UnDiEdge(n1, n2)
272 } 270 }
273 Graph(edges: _*) 271 Graph(edges: _*)
274 } 272 }
@@ -310,7 +308,8 @@ class RSAOntology(val ontology: OWLOntology) {
310 def ask(query: ConjunctiveQuery): ConjunctiveQueryAnswers = { 308 def ask(query: ConjunctiveQuery): ConjunctiveQueryAnswers = {
311 import implicits.JavaCollections._ 309 import implicits.JavaCollections._
312 val (server, data) = RDFoxUtil.openConnection(RSAOntology.DataStore) 310 val (server, data) = RDFoxUtil.openConnection(RSAOntology.DataStore)
313 data.addRules(this.canonicalModel.rules) 311 RDFoxUtil.addRules(data, this.canonicalModel.rules)
312 RDFoxUtil.addFacts(data, this.canonicalModel.facts)
314 data.addRules(this.filteringProgram(query).rules) 313 data.addRules(this.filteringProgram(query).rules)
315 val answers = RDFoxUtil 314 val answers = RDFoxUtil
316 .submitQuery( 315 .submitQuery(