diff options
author | Federico Igne <federico.igne@cs.ox.ac.uk> | 2020-10-21 19:05:27 +0200 |
---|---|---|
committer | Federico Igne <federico.igne@cs.ox.ac.uk> | 2020-10-21 19:05:27 +0200 |
commit | 87471bc45d1824cbef40dc1cfcc4e5e26e83dcea (patch) | |
tree | 942d4f19475891848d39fcdd9b066cf6e6ad7ee9 | |
parent | c4bef39700410c6a86b8d8cb225a0ac9d3692bc1 (diff) | |
download | RSAComb-87471bc45d1824cbef40dc1cfcc4e5e26e83dcea.tar.gz RSAComb-87471bc45d1824cbef40dc1cfcc4e5e26e83dcea.zip |
Fix bug in conflict set computation
-rw-r--r-- | src/main/scala/rsacomb/CanonicalModel.scala | 4 | ||||
-rw-r--r-- | src/main/scala/rsacomb/RSAOntology.scala | 9 | ||||
-rw-r--r-- | src/test/scala/rsacomb/CanonicalModelSpec.scala | 15 |
3 files changed, 23 insertions, 5 deletions
diff --git a/src/main/scala/rsacomb/CanonicalModel.scala b/src/main/scala/rsacomb/CanonicalModel.scala index a248d61..c07fc06 100644 --- a/src/main/scala/rsacomb/CanonicalModel.scala +++ b/src/main/scala/rsacomb/CanonicalModel.scala | |||
@@ -86,10 +86,10 @@ class ProgramGenerator( | |||
86 | import RDFoxUtil._ | 86 | import RDFoxUtil._ |
87 | 87 | ||
88 | def rules1(axiom: OWLSubClassOfAxiom): List[Rule] = { | 88 | def rules1(axiom: OWLSubClassOfAxiom): List[Rule] = { |
89 | val unfold = ontology.cycle(axiom).toList | 89 | val unfold = ontology.unfold(axiom).toList |
90 | // Fresh Variables | 90 | // Fresh Variables |
91 | val v0 = IRI.create("v0_" ++ axiom.hashCode.toString) | 91 | val v0 = IRI.create("v0_" ++ axiom.hashCode.toString) |
92 | val varX = Variable.create("x") | 92 | val varX = Variable.create("X") |
93 | // Predicates | 93 | // Predicates |
94 | val atomA: Atom = { | 94 | val atomA: Atom = { |
95 | val cls = axiom.getSubClass.asInstanceOf[OWLClass].getIRI | 95 | val cls = axiom.getSubClass.asInstanceOf[OWLClass].getIRI |
diff --git a/src/main/scala/rsacomb/RSAOntology.scala b/src/main/scala/rsacomb/RSAOntology.scala index 2941440..9e45c28 100644 --- a/src/main/scala/rsacomb/RSAOntology.scala +++ b/src/main/scala/rsacomb/RSAOntology.scala | |||
@@ -264,10 +264,15 @@ trait RSAOntology { | |||
264 | .map(_.getInverseProperty) | 264 | .map(_.getInverseProperty) |
265 | 265 | ||
266 | invSuperRoles | 266 | invSuperRoles |
267 | .flatMap( | 267 | .flatMap(x => |
268 | reasoner.subObjectProperties(_).collect(Collectors.toSet()).asScala | 268 | reasoner |
269 | .subObjectProperties(x) | ||
270 | .collect(Collectors.toSet()) | ||
271 | .asScala | ||
272 | .addOne(x) | ||
269 | ) | 273 | ) |
270 | .filterNot(_.isOWLBottomObjectProperty()) | 274 | .filterNot(_.isOWLBottomObjectProperty()) |
275 | .filterNot(_.getInverseProperty.isOWLTopObjectProperty()) | ||
271 | } | 276 | } |
272 | 277 | ||
273 | def self(axiom: OWLSubClassOfAxiom): Set[Term] = { | 278 | def self(axiom: OWLSubClassOfAxiom): Set[Term] = { |
diff --git a/src/test/scala/rsacomb/CanonicalModelSpec.scala b/src/test/scala/rsacomb/CanonicalModelSpec.scala index c528328..c5f040d 100644 --- a/src/test/scala/rsacomb/CanonicalModelSpec.scala +++ b/src/test/scala/rsacomb/CanonicalModelSpec.scala | |||
@@ -5,7 +5,6 @@ import org.scalatest.LoneElement | |||
5 | import org.scalatest.flatspec.AnyFlatSpec | 5 | import org.scalatest.flatspec.AnyFlatSpec |
6 | import org.scalatest.matchers.should.Matchers | 6 | import org.scalatest.matchers.should.Matchers |
7 | 7 | ||
8 | |||
9 | import org.semanticweb.owlapi.model._ | 8 | import org.semanticweb.owlapi.model._ |
10 | import uk.ac.manchester.cs.owl.owlapi._ | 9 | import uk.ac.manchester.cs.owl.owlapi._ |
11 | import org.semanticweb.owlapi.dlsyntax.renderer.DLSyntaxObjectRenderer | 10 | import org.semanticweb.owlapi.dlsyntax.renderer.DLSyntaxObjectRenderer |
@@ -72,10 +71,24 @@ class Ontology1_CanonicalModelSpec | |||
72 | ontology.unsafeRoles should not contain roleR | 71 | ontology.unsafeRoles should not contain roleR |
73 | } | 72 | } |
74 | 73 | ||
74 | it should "have 3 elements in its conflict set" in { | ||
75 | ontology.confl(roleR) should have size 3 | ||
76 | } | ||
77 | |||
75 | it should "contain S in its conflict set" in { | 78 | it should "contain S in its conflict set" in { |
76 | ontology.confl(roleR) should contain(roleS) | 79 | ontology.confl(roleR) should contain(roleS) |
77 | } | 80 | } |
78 | 81 | ||
82 | it should "contain T in its conflict set" in { | ||
83 | ontology.confl(roleR) should contain(roleT) | ||
84 | } | ||
85 | |||
86 | it should ("contain " + renderer.render( | ||
87 | roleR_inv | ||
88 | ) + " in its conflict set") in { | ||
89 | ontology.confl(roleR) should contain(roleR_inv) | ||
90 | } | ||
91 | |||
79 | renderer.render(roleS) should "be safe" in { | 92 | renderer.render(roleS) should "be safe" in { |
80 | ontology.unsafeRoles should not contain roleS | 93 | ontology.unsafeRoles should not contain roleS |
81 | } | 94 | } |