diff options
| author | Federico Igne <git@federicoigne.com> | 2021-08-06 13:31:54 +0100 |
|---|---|---|
| committer | Federico Igne <git@federicoigne.com> | 2021-08-06 13:31:54 +0100 |
| commit | 75eb39dd0fd31c295b9ed9a6d3b0fd3b25611b2a (patch) | |
| tree | 885cb3a76a5bdcbb685ac697e297ea8d91eb2ed8 /src/test/scala/uk/ac/ox/cs | |
| parent | 19c22a38ccaf1685e345a18883ffbac891f97df3 (diff) | |
| download | RSAComb-75eb39dd0fd31c295b9ed9a6d3b0fd3b25611b2a.tar.gz RSAComb-75eb39dd0fd31c295b9ed9a6d3b0fd3b25611b2a.zip | |
Add new fresh data factory
This will help write more significant test.
Diffstat (limited to 'src/test/scala/uk/ac/ox/cs')
3 files changed, 228 insertions, 194 deletions
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 abfe1ee..8d363e9 100644 --- a/src/test/scala/uk/ac/ox/cs/rsacomb/CanonicalModelSpec.scala +++ b/src/test/scala/uk/ac/ox/cs/rsacomb/CanonicalModelSpec.scala | |||
| @@ -31,6 +31,8 @@ import tech.oxfordsemantic.jrdfox.logic.expression.Variable | |||
| 31 | import scala.collection.JavaConverters._ | 31 | import scala.collection.JavaConverters._ |
| 32 | 32 | ||
| 33 | import uk.ac.ox.cs.rsacomb.RSAOntology | 33 | import uk.ac.ox.cs.rsacomb.RSAOntology |
| 34 | import uk.ac.ox.cs.rsacomb.approximation.Lowerbound | ||
| 35 | import uk.ac.ox.cs.rsacomb.ontology.Ontology | ||
| 34 | import uk.ac.ox.cs.rsacomb.converter.{SkolemStrategy, NoSkolem} | 36 | import uk.ac.ox.cs.rsacomb.converter.{SkolemStrategy, NoSkolem} |
| 35 | import uk.ac.ox.cs.rsacomb.suffix.Empty | 37 | import uk.ac.ox.cs.rsacomb.suffix.Empty |
| 36 | import uk.ac.ox.cs.rsacomb.util.{RDFoxUtil, RSA} | 38 | import uk.ac.ox.cs.rsacomb.util.{RDFoxUtil, RSA} |
| @@ -44,7 +46,7 @@ object Ontology1_CanonicalModelSpec { | |||
| 44 | IRI.create("http://example.com/rsa_example.owl#" + str) | 46 | IRI.create("http://example.com/rsa_example.owl#" + str) |
| 45 | 47 | ||
| 46 | val ontology_path: File = new File("examples/example1.ttl") | 48 | val ontology_path: File = new File("examples/example1.ttl") |
| 47 | val ontology = RSAOntology(ontology_path) | 49 | val ontology = Ontology(ontology_path, List()).approximate(new Lowerbound) |
| 48 | val program = ontology.canonicalModel | 50 | val program = ontology.canonicalModel |
| 49 | val converter = program.CanonicalModelConverter | 51 | val converter = program.CanonicalModelConverter |
| 50 | 52 | ||
| @@ -109,7 +111,7 @@ class Ontology1_CanonicalModelSpec | |||
| 109 | 111 | ||
| 110 | renderer.render(AsubClassOfD) should "be converted into a single Rule" in { | 112 | renderer.render(AsubClassOfD) should "be converted into a single Rule" in { |
| 111 | val term = Variable.create("X") | 113 | val term = Variable.create("X") |
| 112 | val unsafe = ontology.unsafeRoles | 114 | val unsafe = ontology.unsafe |
| 113 | val (facts, rules) = | 115 | val (facts, rules) = |
| 114 | converter.convert(AsubClassOfD, term, unsafe, NoSkolem, Empty) | 116 | converter.convert(AsubClassOfD, term, unsafe, NoSkolem, Empty) |
| 115 | facts shouldBe empty | 117 | facts shouldBe empty |
| @@ -119,7 +121,7 @@ class Ontology1_CanonicalModelSpec | |||
| 119 | // Role R // | 121 | // Role R // |
| 120 | 122 | ||
| 121 | renderer.render(roleR) should "be safe" in { | 123 | renderer.render(roleR) should "be safe" in { |
| 122 | ontology.unsafeRoles should not contain roleR | 124 | ontology.unsafe should not contain roleR |
| 123 | } | 125 | } |
| 124 | 126 | ||
| 125 | it should "have 3 elements in its conflict set" in { | 127 | it should "have 3 elements in its conflict set" in { |
| @@ -143,7 +145,7 @@ class Ontology1_CanonicalModelSpec | |||
| 143 | // Role S // | 145 | // Role S // |
| 144 | 146 | ||
| 145 | renderer.render(roleS) should "be safe" in { | 147 | renderer.render(roleS) should "be safe" in { |
| 146 | ontology.unsafeRoles should not contain roleS | 148 | ontology.unsafe should not contain roleS |
| 147 | } | 149 | } |
| 148 | 150 | ||
| 149 | it should "have 3 elements in its conflict set" in { | 151 | it should "have 3 elements in its conflict set" in { |
| @@ -169,14 +171,14 @@ class Ontology1_CanonicalModelSpec | |||
| 169 | // S⁻ | 171 | // S⁻ |
| 170 | 172 | ||
| 171 | renderer.render(roleS_inv) should "be unsafe" in { | 173 | renderer.render(roleS_inv) should "be unsafe" in { |
| 172 | ontology.unsafeRoles should contain(roleS_inv) | 174 | ontology.unsafe should contain(roleS_inv) |
| 173 | } | 175 | } |
| 174 | 176 | ||
| 175 | renderer.render( | 177 | renderer.render( |
| 176 | AsomeValuesFromSiC | 178 | AsomeValuesFromSiC |
| 177 | ) should "produce 1 rule" ignore { | 179 | ) should "produce 1 rule" ignore { |
| 178 | val term = Variable.create("X") | 180 | val term = Variable.create("X") |
| 179 | val unsafe = ontology.unsafeRoles | 181 | val unsafe = ontology.unsafe |
| 180 | val (facts, rules) = | 182 | val (facts, rules) = |
| 181 | converter.convert(AsomeValuesFromSiC, term, unsafe, NoSkolem, Empty) | 183 | converter.convert(AsomeValuesFromSiC, term, unsafe, NoSkolem, Empty) |
| 182 | facts shouldBe empty | 184 | facts shouldBe empty |
| @@ -200,7 +202,7 @@ class Ontology1_CanonicalModelSpec | |||
| 200 | // Rule 2 provides 0 rules | 202 | // Rule 2 provides 0 rules |
| 201 | // Rule 3 provides 48 rule (split in 2) | 203 | // Rule 3 provides 48 rule (split in 2) |
| 202 | val term = Variable.create("X") | 204 | val term = Variable.create("X") |
| 203 | val unsafe = ontology.unsafeRoles | 205 | val unsafe = ontology.unsafe |
| 204 | val (facts, rules) = | 206 | val (facts, rules) = |
| 205 | converter.convert(DsomeValuesFromRB, term, unsafe, NoSkolem, Empty) | 207 | converter.convert(DsomeValuesFromRB, term, unsafe, NoSkolem, Empty) |
| 206 | facts should have length 48 | 208 | facts should have length 48 |
| @@ -225,7 +227,7 @@ class Ontology1_CanonicalModelSpec | |||
| 225 | // Rule 3 provides 32 rule (split in 2) | 227 | // Rule 3 provides 32 rule (split in 2) |
| 226 | // Then (1*2 + 32) + (0) + (32*2) = 98 | 228 | // Then (1*2 + 32) + (0) + (32*2) = 98 |
| 227 | val term = Variable.create("X") | 229 | val term = Variable.create("X") |
| 228 | val unsafe = ontology.unsafeRoles | 230 | val unsafe = ontology.unsafe |
| 229 | val (facts, rules) = | 231 | val (facts, rules) = |
| 230 | converter.convert(BsomeValuesFromSD, term, unsafe, NoSkolem, Empty) | 232 | converter.convert(BsomeValuesFromSD, term, unsafe, NoSkolem, Empty) |
| 231 | facts should have length 32 | 233 | facts should have length 32 |
| @@ -236,7 +238,7 @@ class Ontology1_CanonicalModelSpec | |||
| 236 | SsubPropertyOfT | 238 | SsubPropertyOfT |
| 237 | ) should "produce 3 rules" in { | 239 | ) should "produce 3 rules" in { |
| 238 | val term = Variable.create("X") | 240 | val term = Variable.create("X") |
| 239 | val unsafe = ontology.unsafeRoles | 241 | val unsafe = ontology.unsafe |
| 240 | val (facts, rules) = | 242 | val (facts, rules) = |
| 241 | converter.convert(SsubPropertyOfT, term, unsafe, NoSkolem, Empty) | 243 | converter.convert(SsubPropertyOfT, term, unsafe, NoSkolem, Empty) |
| 242 | facts shouldBe empty | 244 | facts shouldBe empty |
| @@ -245,167 +247,167 @@ class Ontology1_CanonicalModelSpec | |||
| 245 | 247 | ||
| 246 | } | 248 | } |
| 247 | 249 | ||
| 248 | object Ontology2_CanonicalModelSpec { | 250 | // object Ontology2_CanonicalModelSpec { |
| 249 | 251 | ||
| 250 | /* Renderer to display OWL Axioms with DL syntax*/ | 252 | // /* Renderer to display OWL Axioms with DL syntax*/ |
| 251 | val renderer = new DLSyntaxObjectRenderer() | 253 | // val renderer = new DLSyntaxObjectRenderer() |
| 252 | 254 | ||
| 253 | def base(str: String): IRI = | 255 | // def base(str: String): IRI = |
| 254 | IRI.create("http://example.com/rsa_example.owl#" + str) | 256 | // IRI.create("http://example.com/rsa_example.owl#" + str) |
| 255 | 257 | ||
| 256 | val ontology_path: File = new File("examples/example2.owl") | 258 | // val ontology_path: File = new File("examples/example2.owl") |
| 257 | val ontology = RSAOntology(ontology_path) | 259 | // val ontology = Ontology(ontology_path, List()).approximate(new Lowerbound) |
| 258 | val program = ontology.canonicalModel | 260 | // val program = ontology.canonicalModel |
| 259 | val converter = program.CanonicalModelConverter | 261 | // val converter = program.CanonicalModelConverter |
| 260 | 262 | ||
| 261 | val roleR = new OWLObjectPropertyImpl(base("R")) | 263 | // val roleR = new OWLObjectPropertyImpl(base("R")) |
| 262 | val roleS = new OWLObjectPropertyImpl(base("S")) | 264 | // val roleS = new OWLObjectPropertyImpl(base("S")) |
| 263 | val roleT = new OWLObjectPropertyImpl(base("T")) | 265 | // val roleT = new OWLObjectPropertyImpl(base("T")) |
| 264 | val roleP = new OWLObjectPropertyImpl(base("P")) | 266 | // val roleP = new OWLObjectPropertyImpl(base("P")) |
| 265 | val roleR_inv = roleR.getInverseProperty() | 267 | // val roleR_inv = roleR.getInverseProperty() |
| 266 | val roleS_inv = roleS.getInverseProperty() | 268 | // val roleS_inv = roleS.getInverseProperty() |
| 267 | val roleT_inv = roleT.getInverseProperty() | 269 | // val roleT_inv = roleT.getInverseProperty() |
| 268 | val roleP_inv = roleP.getInverseProperty() | 270 | // val roleP_inv = roleP.getInverseProperty() |
| 269 | 271 | ||
| 270 | val AsomeValuesFromRB = new OWLSubClassOfAxiomImpl( | 272 | // val AsomeValuesFromRB = new OWLSubClassOfAxiomImpl( |
| 271 | new OWLClassImpl(base("A")), | 273 | // new OWLClassImpl(base("A")), |
| 272 | new OWLObjectSomeValuesFromImpl( | 274 | // new OWLObjectSomeValuesFromImpl( |
| 273 | roleR, | 275 | // roleR, |
| 274 | new OWLClassImpl(base("B")) | 276 | // new OWLClassImpl(base("B")) |
| 275 | ), | 277 | // ), |
| 276 | Seq().asJava | 278 | // Seq().asJava |
| 277 | ) | 279 | // ) |
| 278 | 280 | ||
| 279 | val BsomeValuesFromSC = new OWLSubClassOfAxiomImpl( | 281 | // val BsomeValuesFromSC = new OWLSubClassOfAxiomImpl( |
| 280 | new OWLClassImpl(base("B")), | 282 | // new OWLClassImpl(base("B")), |
| 281 | new OWLObjectSomeValuesFromImpl( | 283 | // new OWLObjectSomeValuesFromImpl( |
| 282 | roleS, | 284 | // roleS, |
| 283 | new OWLClassImpl(base("C")) | 285 | // new OWLClassImpl(base("C")) |
| 284 | ), | 286 | // ), |
| 285 | Seq().asJava | 287 | // Seq().asJava |
| 286 | ) | 288 | // ) |
| 287 | 289 | ||
| 288 | val CsomeValuesFromTD = new OWLSubClassOfAxiomImpl( | 290 | // val CsomeValuesFromTD = new OWLSubClassOfAxiomImpl( |
| 289 | new OWLClassImpl(base("C")), | 291 | // new OWLClassImpl(base("C")), |
| 290 | new OWLObjectSomeValuesFromImpl( | 292 | // new OWLObjectSomeValuesFromImpl( |
| 291 | roleT, | 293 | // roleT, |
| 292 | new OWLClassImpl(base("D")) | 294 | // new OWLClassImpl(base("D")) |
| 293 | ), | 295 | // ), |
| 294 | Seq().asJava | 296 | // Seq().asJava |
| 295 | ) | 297 | // ) |
| 296 | 298 | ||
| 297 | val DsomeValuesFromPA = new OWLSubClassOfAxiomImpl( | 299 | // val DsomeValuesFromPA = new OWLSubClassOfAxiomImpl( |
| 298 | new OWLClassImpl(base("D")), | 300 | // new OWLClassImpl(base("D")), |
| 299 | new OWLObjectSomeValuesFromImpl( | 301 | // new OWLObjectSomeValuesFromImpl( |
| 300 | roleP, | 302 | // roleP, |
| 301 | new OWLClassImpl(base("A")) | 303 | // new OWLClassImpl(base("A")) |
| 302 | ), | 304 | // ), |
| 303 | Seq().asJava | 305 | // Seq().asJava |
| 304 | ) | 306 | // ) |
| 305 | 307 | ||
| 306 | } | 308 | // } |
| 307 | 309 | ||
| 308 | class Ontology2_CanonicalModelSpec | 310 | // class Ontology2_CanonicalModelSpec |
| 309 | extends AnyFlatSpec | 311 | // extends AnyFlatSpec |
| 310 | with Matchers | 312 | // with Matchers |
| 311 | with LoneElement { | 313 | // with LoneElement { |
| 312 | 314 | ||
| 313 | import Ontology2_CanonicalModelSpec._ | 315 | // import Ontology2_CanonicalModelSpec._ |
| 314 | 316 | ||
| 315 | "The program generated from Example #1" should "not be empty" in { | 317 | // "The program generated from Example #1" should "not be empty" in { |
| 316 | program.rules should not be empty | 318 | // program.rules should not be empty |
| 317 | } | 319 | // } |
| 318 | 320 | ||
| 319 | // Role R // | 321 | // // Role R // |
| 320 | 322 | ||
| 321 | renderer.render(roleR) should "be unsafe" in { | 323 | // renderer.render(roleR) should "be unsafe" in { |
| 322 | ontology.unsafeRoles should contain(roleR) | 324 | // ontology.unsafe should contain(roleR) |
| 323 | } | 325 | // } |
| 324 | 326 | ||
| 325 | it should "have only its inverse in its conflict set" in { | 327 | // it should "have only its inverse in its conflict set" in { |
| 326 | ontology.confl(roleR).loneElement shouldBe roleR_inv | 328 | // ontology.confl(roleR).loneElement shouldBe roleR_inv |
| 327 | } | 329 | // } |
| 328 | 330 | ||
| 329 | // Role S // | 331 | // // Role S // |
| 330 | 332 | ||
| 331 | renderer.render(roleS) should "be unsafe" in { | 333 | // renderer.render(roleS) should "be unsafe" in { |
| 332 | ontology.unsafeRoles should contain(roleS) | 334 | // ontology.unsafe should contain(roleS) |
| 333 | } | 335 | // } |
| 334 | 336 | ||
| 335 | it should "have only its inverse in its conflict set" in { | 337 | // it should "have only its inverse in its conflict set" in { |
| 336 | ontology.confl(roleS).loneElement shouldBe roleS_inv | 338 | // ontology.confl(roleS).loneElement shouldBe roleS_inv |
| 337 | } | 339 | // } |
| 338 | 340 | ||
| 339 | // Role T // | 341 | // // Role T // |
| 340 | 342 | ||
| 341 | renderer.render(roleT) should "be unsafe" in { | 343 | // renderer.render(roleT) should "be unsafe" in { |
| 342 | ontology.unsafeRoles should contain(roleT) | 344 | // ontology.unsafe should contain(roleT) |
| 343 | } | 345 | // } |
| 344 | 346 | ||
| 345 | it should "have only its inverse in its conflict set" in { | 347 | // it should "have only its inverse in its conflict set" in { |
| 346 | ontology.confl(roleT).loneElement shouldBe roleT_inv | 348 | // ontology.confl(roleT).loneElement shouldBe roleT_inv |
| 347 | } | 349 | // } |
| 348 | 350 | ||
| 349 | // Role P // | 351 | // // Role P // |
| 350 | 352 | ||
| 351 | renderer.render(roleP) should "be unsafe" in { | 353 | // renderer.render(roleP) should "be unsafe" in { |
| 352 | ontology.unsafeRoles should contain(roleP) | 354 | // ontology.unsafe should contain(roleP) |
| 353 | } | 355 | // } |
| 354 | 356 | ||
| 355 | it should "have only its inverse in its conflict set" in { | 357 | // it should "have only its inverse in its conflict set" in { |
| 356 | ontology.confl(roleP).loneElement shouldBe roleP_inv | 358 | // ontology.confl(roleP).loneElement shouldBe roleP_inv |
| 357 | } | 359 | // } |
| 358 | 360 | ||
| 359 | // A ⊑ ∃ R.B | 361 | // // A ⊑ ∃ R.B |
| 360 | 362 | ||
| 361 | renderer.render( | 363 | // renderer.render( |
| 362 | AsomeValuesFromRB | 364 | // AsomeValuesFromRB |
| 363 | ) should "produce 1 rule" in { | 365 | // ) should "produce 1 rule" in { |
| 364 | val term = Variable.create("X") | 366 | // val term = Variable.create("X") |
| 365 | val unsafe = ontology.unsafeRoles | 367 | // val unsafe = ontology.unsafe |
| 366 | val (facts, rules) = | 368 | // val (facts, rules) = |
| 367 | converter.convert(AsomeValuesFromRB, term, unsafe, NoSkolem, Empty) | 369 | // converter.convert(AsomeValuesFromRB, term, unsafe, NoSkolem, Empty) |
| 368 | facts shouldBe empty | 370 | // facts shouldBe empty |
| 369 | rules should have length 1 | 371 | // rules should have length 1 |
| 370 | } | 372 | // } |
| 371 | 373 | ||
| 372 | // B ⊑ ∃ S.C | 374 | // // B ⊑ ∃ S.C |
| 373 | 375 | ||
| 374 | renderer.render( | 376 | // renderer.render( |
| 375 | BsomeValuesFromSC | 377 | // BsomeValuesFromSC |
| 376 | ) should "produce 1 rule" in { | 378 | // ) should "produce 1 rule" in { |
| 377 | val term = Variable.create("X") | 379 | // val term = Variable.create("X") |
| 378 | val unsafe = ontology.unsafeRoles | 380 | // val unsafe = ontology.unsafe |
| 379 | val (facts, rules) = | 381 | // val (facts, rules) = |
| 380 | converter.convert(BsomeValuesFromSC, term, unsafe, NoSkolem, Empty) | 382 | // converter.convert(BsomeValuesFromSC, term, unsafe, NoSkolem, Empty) |
| 381 | facts shouldBe empty | 383 | // facts shouldBe empty |
| 382 | rules should have length 1 | 384 | // rules should have length 1 |
| 383 | } | 385 | // } |
| 384 | 386 | ||
| 385 | // C ⊑ ∃ T.D | 387 | // // C ⊑ ∃ T.D |
| 386 | 388 | ||
| 387 | renderer.render( | 389 | // renderer.render( |
| 388 | CsomeValuesFromTD | 390 | // CsomeValuesFromTD |
| 389 | ) should "produce 1 rule" in { | 391 | // ) should "produce 1 rule" in { |
| 390 | val term = Variable.create("X") | 392 | // val term = Variable.create("X") |
| 391 | val unsafe = ontology.unsafeRoles | 393 | // val unsafe = ontology.unsafe |
| 392 | val (facts, rules) = | 394 | // val (facts, rules) = |
| 393 | converter.convert(CsomeValuesFromTD, term, unsafe, NoSkolem, Empty) | 395 | // converter.convert(CsomeValuesFromTD, term, unsafe, NoSkolem, Empty) |
| 394 | facts shouldBe empty | 396 | // facts shouldBe empty |
| 395 | rules should have length 1 | 397 | // rules should have length 1 |
| 396 | } | 398 | // } |
| 397 | 399 | ||
| 398 | // D ⊑ ∃ P.A | 400 | // // D ⊑ ∃ P.A |
| 399 | 401 | ||
| 400 | renderer.render( | 402 | // renderer.render( |
| 401 | DsomeValuesFromPA | 403 | // DsomeValuesFromPA |
| 402 | ) should "produce 1 rule" in { | 404 | // ) should "produce 1 rule" in { |
| 403 | val term = Variable.create("X") | 405 | // val term = Variable.create("X") |
| 404 | val unsafe = ontology.unsafeRoles | 406 | // val unsafe = ontology.unsafe |
| 405 | val (facts, rules) = | 407 | // val (facts, rules) = |
| 406 | converter.convert(DsomeValuesFromPA, term, unsafe, NoSkolem, Empty) | 408 | // converter.convert(DsomeValuesFromPA, term, unsafe, NoSkolem, Empty) |
| 407 | facts shouldBe empty | 409 | // facts shouldBe empty |
| 408 | rules should have length 1 | 410 | // rules should have length 1 |
| 409 | } | 411 | // } |
| 410 | 412 | ||
| 411 | } | 413 | // } |
diff --git a/src/test/scala/uk/ac/ox/cs/rsacomb/SuiteAll.scala b/src/test/scala/uk/ac/ox/cs/rsacomb/SuiteAll.scala index 1df0757..9653546 100644 --- a/src/test/scala/uk/ac/ox/cs/rsacomb/SuiteAll.scala +++ b/src/test/scala/uk/ac/ox/cs/rsacomb/SuiteAll.scala | |||
| @@ -32,7 +32,7 @@ import uk.ac.ox.cs.rsacomb.sparql.{ | |||
| 32 | class SuiteAll | 32 | class SuiteAll |
| 33 | extends Suites( | 33 | extends Suites( |
| 34 | new Ontology1_CanonicalModelSpec, | 34 | new Ontology1_CanonicalModelSpec, |
| 35 | new Ontology2_CanonicalModelSpec, | 35 | //new Ontology2_CanonicalModelSpec, |
| 36 | new NaiveFilteringProgramSpec, | 36 | new NaiveFilteringProgramSpec, |
| 37 | new OWLAxiomSpec, | 37 | new OWLAxiomSpec, |
| 38 | new OWLClassSpec, | 38 | new OWLClassSpec, |
diff --git a/src/test/scala/uk/ac/ox/cs/rsacomb/converter/NormalizerSpec.scala b/src/test/scala/uk/ac/ox/cs/rsacomb/converter/NormalizerSpec.scala index 7285df2..5047e12 100644 --- a/src/test/scala/uk/ac/ox/cs/rsacomb/converter/NormalizerSpec.scala +++ b/src/test/scala/uk/ac/ox/cs/rsacomb/converter/NormalizerSpec.scala | |||
| @@ -27,6 +27,7 @@ import tech.oxfordsemantic.jrdfox.logic.expression.{Variable, IRI} | |||
| 27 | import uk.ac.ox.cs.rsacomb.converter.RDFoxConverter | 27 | import uk.ac.ox.cs.rsacomb.converter.RDFoxConverter |
| 28 | import uk.ac.ox.cs.rsacomb.suffix.{Empty, Forward, Backward, Inverse} | 28 | import uk.ac.ox.cs.rsacomb.suffix.{Empty, Forward, Backward, Inverse} |
| 29 | import uk.ac.ox.cs.rsacomb.converter.{Normalizer, SkolemStrategy, NoSkolem} | 29 | import uk.ac.ox.cs.rsacomb.converter.{Normalizer, SkolemStrategy, NoSkolem} |
| 30 | import uk.ac.ox.cs.rsacomb.util.DataFactory | ||
| 30 | 31 | ||
| 31 | object NormalizerSpec { | 32 | object NormalizerSpec { |
| 32 | val manager = OWLManager.createOWLOntologyManager() | 33 | val manager = OWLManager.createOWLOntologyManager() |
| @@ -89,27 +90,58 @@ class NormalizerSpec extends AnyFlatSpec with Matchers with LoneElement { | |||
| 89 | ).flatMap(normalizer.normalize) | 90 | ).flatMap(normalizer.normalize) |
| 90 | } | 91 | } |
| 91 | 92 | ||
| 92 | "Disjunction on the rhs" should "be shifted" in { | 93 | "A c \\exists R . D" should "be normalised to { A c \\exists R . C, C c D } if D is not a concept name" in { |
| 93 | def cls(n: Int) = factory.getOWLClass(s"_:class$n") | 94 | val seed = 42 |
| 94 | val axiom1 = | 95 | val test = normalizer.normalize( |
| 95 | factory.getOWLSubClassOfAxiom( | 96 | factory |
| 96 | factory.getOWLObjectIntersectionOf(cls(1), cls(2), cls(3)), | 97 | .getOWLSubClassOfAxiom( |
| 97 | factory.getOWLObjectUnionOf(cls(4), cls(5)) | 98 | factory.getOWLClass("A"), |
| 98 | ) | 99 | factory.getOWLObjectSomeValuesFrom( |
| 99 | val axiom2 = | 100 | factory.getOWLObjectProperty("R"), |
| 100 | factory.getOWLSubClassOfAxiom( | 101 | factory.getOWLObjectIntersectionOf( |
| 101 | cls(1), | 102 | factory.getOWLClass("D1"), |
| 102 | factory.getOWLObjectUnionOf(cls(2), cls(3), cls(4)) | 103 | factory.getOWLClass("D2") |
| 103 | ) | 104 | ) |
| 104 | val axiom3 = | 105 | ) |
| 105 | factory.getOWLSubClassOfAxiom( | 106 | ) |
| 106 | factory.getOWLObjectIntersectionOf(cls(1), cls(2), cls(3)), | 107 | )(DataFactory(seed)) |
| 107 | factory.getOWLObjectUnionOf(cls(4)) | 108 | val cls = DataFactory(seed).getOWLClass |
| 108 | ) | 109 | val result = List( |
| 109 | normalizer.normalize(axiom1) should have length 5 | 110 | factory |
| 110 | normalizer.normalize(axiom2) should have length 5 | 111 | .getOWLSubClassOfAxiom( |
| 111 | normalizer.normalize(axiom3) should have length 4 | 112 | factory.getOWLClass("A"), |
| 113 | factory.getOWLObjectSomeValuesFrom( | ||
| 114 | factory.getOWLObjectProperty("R"), | ||
| 115 | cls | ||
| 116 | ) | ||
| 117 | ), | ||
| 118 | factory.getOWLSubClassOfAxiom(cls, factory.getOWLClass("D1")), | ||
| 119 | factory.getOWLSubClassOfAxiom(cls, factory.getOWLClass("D2")) | ||
| 120 | ) | ||
| 121 | test should contain theSameElementsAs result | ||
| 112 | } | 122 | } |
| 123 | |||
| 124 | // "Disjunction on the rhs" should "be shifted" in { | ||
| 125 | // def cls(n: Int) = factory.getOWLClass(s"_:class$n") | ||
| 126 | // val axiom1 = | ||
| 127 | // factory.getOWLSubClassOfAxiom( | ||
| 128 | // factory.getOWLObjectIntersectionOf(cls(1), cls(2), cls(3)), | ||
| 129 | // factory.getOWLObjectUnionOf(cls(4), cls(5)) | ||
| 130 | // ) | ||
| 131 | // val axiom2 = | ||
| 132 | // factory.getOWLSubClassOfAxiom( | ||
| 133 | // cls(1), | ||
| 134 | // factory.getOWLObjectUnionOf(cls(2), cls(3), cls(4)) | ||
| 135 | // ) | ||
| 136 | // val axiom3 = | ||
| 137 | // factory.getOWLSubClassOfAxiom( | ||
| 138 | // factory.getOWLObjectIntersectionOf(cls(1), cls(2), cls(3)), | ||
| 139 | // factory.getOWLObjectUnionOf(cls(4)) | ||
| 140 | // ) | ||
| 141 | // normalizer.normalize(axiom1) should have length 5 | ||
| 142 | // normalizer.normalize(axiom2) should have length 5 | ||
| 143 | // normalizer.normalize(axiom3) should have length 4 | ||
| 144 | // } | ||
| 113 | //"A class name" should "be converted into a single atom" in { | 145 | //"A class name" should "be converted into a single atom" in { |
| 114 | // val cls = factory.getOWLClass(iriString0) | 146 | // val cls = factory.getOWLClass(iriString0) |
| 115 | // val atom = TupleTableAtom.rdf(term0, IRI.RDF_TYPE, IRI.create(iriString0)) | 147 | // val atom = TupleTableAtom.rdf(term0, IRI.RDF_TYPE, IRI.create(iriString0)) |
