diff options
author | Federico Igne <federico.igne@cs.ox.ac.uk> | 2020-12-08 14:29:35 +0000 |
---|---|---|
committer | Federico Igne <federico.igne@cs.ox.ac.uk> | 2020-12-08 14:29:35 +0000 |
commit | 2b0f0d0079484b00a1b788414ff1499282a86aeb (patch) | |
tree | 3e31df8a6fea594b704d2a5013659c9a59483996 /src | |
parent | 17285895dec47f4ca05590c861a7e8ef6f595c0c (diff) | |
parent | f8e612288f3a604ee1bd60016b7320f00b763e6b (diff) | |
download | RSAComb-2b0f0d0079484b00a1b788414ff1499282a86aeb.tar.gz RSAComb-2b0f0d0079484b00a1b788414ff1499282a86aeb.zip |
Merge branch 'master' into logger
Diffstat (limited to 'src')
-rw-r--r-- | src/main/scala/uk/ac/ox/cs/rsacomb/CanonicalModel.scala | 9 | ||||
-rw-r--r-- | src/main/scala/uk/ac/ox/cs/rsacomb/RSAOntology.scala | 12 | ||||
-rw-r--r-- | src/main/scala/uk/ac/ox/cs/rsacomb/converter/RDFoxConverter.scala | 2 | ||||
-rw-r--r-- | src/main/scala/uk/ac/ox/cs/rsacomb/sparql/ConjunctiveQueryAnswers.scala | 12 | ||||
-rw-r--r-- | src/test/scala/uk/ac/ox/cs/rsacomb/CanonicalModelSpec.scala | 6 | ||||
-rw-r--r-- | src/test/scala/uk/ac/ox/cs/rsacomb/FilteringProgramSpecs.scala | 2 | ||||
-rw-r--r-- | src/test/scala/uk/ac/ox/cs/rsacomb/converter/OWLAxiomSpec.scala (renamed from src/test/scala/uk/ac/ox/cs/rsacomb/OWLAxiomSpec.scala) | 2 | ||||
-rw-r--r-- | src/test/scala/uk/ac/ox/cs/rsacomb/converter/OWLClassSpec.scala (renamed from src/test/scala/uk/ac/ox/cs/rsacomb/OWLClassSpec.scala) | 2 | ||||
-rw-r--r-- | src/test/scala/uk/ac/ox/cs/rsacomb/converter/RDFoxConverterSpec.scala (renamed from src/test/scala/uk/ac/ox/cs/rsacomb/RDFoxConverterSpec.scala) | 2 |
9 files changed, 31 insertions, 18 deletions
diff --git a/src/main/scala/uk/ac/ox/cs/rsacomb/CanonicalModel.scala b/src/main/scala/uk/ac/ox/cs/rsacomb/CanonicalModel.scala index c605e51..5001c8a 100644 --- a/src/main/scala/uk/ac/ox/cs/rsacomb/CanonicalModel.scala +++ b/src/main/scala/uk/ac/ox/cs/rsacomb/CanonicalModel.scala | |||
@@ -247,11 +247,10 @@ class CanonicalModel(val ontology: RSAOntology) { | |||
247 | } | 247 | } |
248 | 248 | ||
249 | case a: OWLSubObjectPropertyOfAxiom => { | 249 | case a: OWLSubObjectPropertyOfAxiom => { |
250 | val (factsF, rulesF) = | 250 | val (facts, rules) = List(Empty, Forward, Backward) |
251 | super.convert(a, term, unsafe, NoSkolem, Forward) | 251 | .map(super.convert(a, term, unsafe, NoSkolem, _)) |
252 | val (factsB, rulesB) = | 252 | .unzip |
253 | super.convert(a, term, unsafe, NoSkolem, Backward) | 253 | (facts.flatten, rules.flatten) |
254 | (factsF ::: factsB, rulesF ::: rulesB) | ||
255 | } | 254 | } |
256 | 255 | ||
257 | case a => super.convert(a, term, unsafe, skolem, suffix) | 256 | case a => super.convert(a, term, unsafe, skolem, suffix) |
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 79f2ef3..dc64c79 100644 --- a/src/main/scala/uk/ac/ox/cs/rsacomb/RSAOntology.scala +++ b/src/main/scala/uk/ac/ox/cs/rsacomb/RSAOntology.scala | |||
@@ -11,6 +11,7 @@ import org.semanticweb.owlapi.model.{OWLOntology, OWLAxiom, OWLLogicalAxiom} | |||
11 | import org.semanticweb.owlapi.model.{ | 11 | import org.semanticweb.owlapi.model.{ |
12 | OWLClass, | 12 | OWLClass, |
13 | OWLClassExpression, | 13 | OWLClassExpression, |
14 | OWLDataPropertyAssertionAxiom, | ||
14 | OWLObjectProperty, | 15 | OWLObjectProperty, |
15 | OWLSubObjectPropertyOfAxiom, | 16 | OWLSubObjectPropertyOfAxiom, |
16 | OWLObjectPropertyExpression, | 17 | OWLObjectPropertyExpression, |
@@ -35,7 +36,8 @@ import tech.oxfordsemantic.jrdfox.logic.expression.{ | |||
35 | Term, | 36 | Term, |
36 | Variable, | 37 | Variable, |
37 | IRI, | 38 | IRI, |
38 | Resource | 39 | Resource, |
40 | Literal | ||
39 | } | 41 | } |
40 | import tech.oxfordsemantic.jrdfox.logic.sparql.statement.SelectQuery | 42 | import tech.oxfordsemantic.jrdfox.logic.sparql.statement.SelectQuery |
41 | 43 | ||
@@ -122,6 +124,12 @@ class RSAOntology(val ontology: OWLOntology) { | |||
122 | .map(implicits.RDFox.owlapiToRdfoxIri) | 124 | .map(implicits.RDFox.owlapiToRdfoxIri) |
123 | .toList | 125 | .toList |
124 | 126 | ||
127 | val literals: List[Literal] = | ||
128 | abox | ||
129 | .collect { case a: OWLDataPropertyAssertionAxiom => a } | ||
130 | .map(_.getObject) | ||
131 | .map(implicits.RDFox.owlapiToRdfoxLiteral) | ||
132 | |||
125 | val concepts: List[OWLClass] = | 133 | val concepts: List[OWLClass] = |
126 | ontology.getClassesInSignature().asScala.toList | 134 | ontology.getClassesInSignature().asScala.toList |
127 | 135 | ||
@@ -298,7 +306,7 @@ class RSAOntology(val ontology: OWLOntology) { | |||
298 | 306 | ||
299 | def filteringProgram(query: ConjunctiveQuery): FilteringProgram = | 307 | def filteringProgram(query: ConjunctiveQuery): FilteringProgram = |
300 | Logger.timed( | 308 | Logger.timed( |
301 | new FilteringProgram(query, individuals), | 309 | new FilteringProgram(query, individuals ++ literals), |
302 | "Generating filtering program", | 310 | "Generating filtering program", |
303 | Logger.DEBUG | 311 | Logger.DEBUG |
304 | ) | 312 | ) |
diff --git a/src/main/scala/uk/ac/ox/cs/rsacomb/converter/RDFoxConverter.scala b/src/main/scala/uk/ac/ox/cs/rsacomb/converter/RDFoxConverter.scala index 6c83caf..6193296 100644 --- a/src/main/scala/uk/ac/ox/cs/rsacomb/converter/RDFoxConverter.scala +++ b/src/main/scala/uk/ac/ox/cs/rsacomb/converter/RDFoxConverter.scala | |||
@@ -225,7 +225,7 @@ trait RDFoxConverter { | |||
225 | * @see [[org.semanticweb.owlapi.model.OWLDataPropertyAssertionAxiom OWLDataPropertyAssertionAxiom]] | 225 | * @see [[org.semanticweb.owlapi.model.OWLDataPropertyAssertionAxiom OWLDataPropertyAssertionAxiom]] |
226 | */ | 226 | */ |
227 | case a: OWLDataPropertyAssertionAxiom => | 227 | case a: OWLDataPropertyAssertionAxiom => |
228 | if (!a.getSubject.isNamed || !a.getObject.isNamed) | 228 | if (!a.getSubject.isNamed) |
229 | Result() | 229 | Result() |
230 | else { | 230 | else { |
231 | val subj = a.getSubject.asOWLNamedIndividual.getIRI | 231 | val subj = a.getSubject.asOWLNamedIndividual.getIRI |
diff --git a/src/main/scala/uk/ac/ox/cs/rsacomb/sparql/ConjunctiveQueryAnswers.scala b/src/main/scala/uk/ac/ox/cs/rsacomb/sparql/ConjunctiveQueryAnswers.scala index 50cbb86..667defc 100644 --- a/src/main/scala/uk/ac/ox/cs/rsacomb/sparql/ConjunctiveQueryAnswers.scala +++ b/src/main/scala/uk/ac/ox/cs/rsacomb/sparql/ConjunctiveQueryAnswers.scala | |||
@@ -1,6 +1,11 @@ | |||
1 | package uk.ac.ox.cs.rsacomb.sparql | 1 | package uk.ac.ox.cs.rsacomb.sparql |
2 | 2 | ||
3 | import tech.oxfordsemantic.jrdfox.logic.expression.{IRI, Resource, Variable} | 3 | import tech.oxfordsemantic.jrdfox.logic.expression.{ |
4 | IRI, | ||
5 | Literal, | ||
6 | Resource, | ||
7 | Variable | ||
8 | } | ||
4 | 9 | ||
5 | /** A collections of answers to a query. | 10 | /** A collections of answers to a query. |
6 | * | 11 | * |
@@ -30,8 +35,9 @@ class ConjunctiveQueryAnswers( | |||
30 | val header = variables map (_.getName) mkString "\t" | 35 | val header = variables map (_.getName) mkString "\t" |
31 | val body = answers | 36 | val body = answers |
32 | .map(_.map { | 37 | .map(_.map { |
33 | case x: IRI => x.getIRI | 38 | case x: IRI => x.getIRI |
34 | case x => x.toString | 39 | case x: Literal => x.getLexicalForm |
40 | case x => x.toString | ||
35 | }.mkString("\t")) | 41 | }.mkString("\t")) |
36 | .mkString("\n") | 42 | .mkString("\n") |
37 | s"$header\n$body" | 43 | s"$header\n$body" |
diff --git a/src/test/scala/uk/ac/ox/cs/rsacomb/CanonicalModelSpec.scala b/src/test/scala/uk/ac/ox/cs/rsacomb/CanonicalModelSpec.scala index a7d7f27..0d18e66 100644 --- a/src/test/scala/uk/ac/ox/cs/rsacomb/CanonicalModelSpec.scala +++ b/src/test/scala/uk/ac/ox/cs/rsacomb/CanonicalModelSpec.scala | |||
@@ -1,4 +1,4 @@ | |||
1 | package rsacomb | 1 | package uk.ac.ox.cs.rsacomb |
2 | 2 | ||
3 | import java.io.File | 3 | import java.io.File |
4 | import org.scalatest.LoneElement | 4 | import org.scalatest.LoneElement |
@@ -218,13 +218,13 @@ class Ontology1_CanonicalModelSpec | |||
218 | 218 | ||
219 | renderer.render( | 219 | renderer.render( |
220 | SsubPropertyOfT | 220 | SsubPropertyOfT |
221 | ) should "produce 2 rules" in { | 221 | ) should "produce 3 rules" in { |
222 | val term = Variable.create("X") | 222 | val term = Variable.create("X") |
223 | val unsafe = ontology.unsafeRoles | 223 | val unsafe = ontology.unsafeRoles |
224 | val (facts, rules) = | 224 | val (facts, rules) = |
225 | converter.convert(SsubPropertyOfT, term, unsafe, NoSkolem, Empty) | 225 | converter.convert(SsubPropertyOfT, term, unsafe, NoSkolem, Empty) |
226 | facts shouldBe empty | 226 | facts shouldBe empty |
227 | rules should have length 2 | 227 | rules should have length 3 |
228 | } | 228 | } |
229 | 229 | ||
230 | } | 230 | } |
diff --git a/src/test/scala/uk/ac/ox/cs/rsacomb/FilteringProgramSpecs.scala b/src/test/scala/uk/ac/ox/cs/rsacomb/FilteringProgramSpecs.scala index 93e312c..e627bf7 100644 --- a/src/test/scala/uk/ac/ox/cs/rsacomb/FilteringProgramSpecs.scala +++ b/src/test/scala/uk/ac/ox/cs/rsacomb/FilteringProgramSpecs.scala | |||
@@ -1,4 +1,4 @@ | |||
1 | package rsacomb | 1 | package uk.ac.ox.cs.rsacomb |
2 | 2 | ||
3 | import org.scalatest.flatspec.AnyFlatSpec | 3 | import org.scalatest.flatspec.AnyFlatSpec |
4 | import org.scalatest.matchers.should.Matchers | 4 | import org.scalatest.matchers.should.Matchers |
diff --git a/src/test/scala/uk/ac/ox/cs/rsacomb/OWLAxiomSpec.scala b/src/test/scala/uk/ac/ox/cs/rsacomb/converter/OWLAxiomSpec.scala index e1ece62..eb49c7d 100644 --- a/src/test/scala/uk/ac/ox/cs/rsacomb/OWLAxiomSpec.scala +++ b/src/test/scala/uk/ac/ox/cs/rsacomb/converter/OWLAxiomSpec.scala | |||
@@ -1,4 +1,4 @@ | |||
1 | package rsacomb | 1 | package uk.ac.ox.cs.rsacomb.converter |
2 | 2 | ||
3 | import java.util.{ArrayList => JList} | 3 | import java.util.{ArrayList => JList} |
4 | import org.scalatest.LoneElement | 4 | import org.scalatest.LoneElement |
diff --git a/src/test/scala/uk/ac/ox/cs/rsacomb/OWLClassSpec.scala b/src/test/scala/uk/ac/ox/cs/rsacomb/converter/OWLClassSpec.scala index def864b..09ab6eb 100644 --- a/src/test/scala/uk/ac/ox/cs/rsacomb/OWLClassSpec.scala +++ b/src/test/scala/uk/ac/ox/cs/rsacomb/converter/OWLClassSpec.scala | |||
@@ -1,4 +1,4 @@ | |||
1 | package rsacomb | 1 | package uk.ox.ac.cs.rsacomb.converter |
2 | 2 | ||
3 | import java.util.{ArrayList => JList} | 3 | import java.util.{ArrayList => JList} |
4 | 4 | ||
diff --git a/src/test/scala/uk/ac/ox/cs/rsacomb/RDFoxConverterSpec.scala b/src/test/scala/uk/ac/ox/cs/rsacomb/converter/RDFoxConverterSpec.scala index 5c9fa96..a401abf 100644 --- a/src/test/scala/uk/ac/ox/cs/rsacomb/RDFoxConverterSpec.scala +++ b/src/test/scala/uk/ac/ox/cs/rsacomb/converter/RDFoxConverterSpec.scala | |||
@@ -1,4 +1,4 @@ | |||
1 | package rsacomb | 1 | package uk.ac.ox.cs.rsacomb.converter |
2 | 2 | ||
3 | import org.scalatest.LoneElement | 3 | import org.scalatest.LoneElement |
4 | import org.scalatest.flatspec.AnyFlatSpec | 4 | import org.scalatest.flatspec.AnyFlatSpec |