Skip to content
This repository was archived by the owner on Oct 8, 2020. It is now read-only.

Commit ed77232

Browse files
Added test for FwRuleReasonerOWLHorst rules O12a+b
1 parent 26e9ed7 commit ed77232

File tree

3 files changed

+146
-1
lines changed

3 files changed

+146
-1
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Prefix(:=<http://ex.com/default#>)
2+
3+
Ontology(<http://ex.com/ont/sample1.owl>
4+
<http://ex.com/ont/release/123/sample1.owl>
5+
6+
Declaration(DataProperty(:dataProp01))
7+
Declaration(DataProperty(:dataProp02))
8+
Declaration(DataProperty(:dataProp03))
9+
10+
Declaration(DataProperty(:dataProp04))
11+
Declaration(DataProperty(:dataProp05))
12+
13+
Declaration(DataProperty(:dataProp06))
14+
15+
EquivalentDataProperties(:dataProp01 :dataProp02 :dataProp03)
16+
EquivalentDataProperties(:dataProp04 :dataProp05)
17+
)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Prefix(:=<http://ex.com/default#>)
2+
3+
Ontology(<http://ex.com/ont/sample1.owl>
4+
<http://ex.com/ont/release/123/sample1.owl>
5+
6+
Declaration(ObjectProperty(:objProp01))
7+
Declaration(ObjectProperty(:objProp02))
8+
Declaration(ObjectProperty(:objProp03))
9+
10+
Declaration(ObjectProperty(:objProp04))
11+
Declaration(ObjectProperty(:objProp05))
12+
13+
Declaration(ObjectProperty(:objProp06))
14+
15+
EquivalentObjectProperties(:objProp01 :objProp02 :objProp03)
16+
EquivalentObjectProperties(:objProp04 :objProp05)
17+
)

sansa-inference-spark/src/test/scala/net/sansa_stack/inference/spark/forwardchaining/axioms/ForwardRuleReasonerOWLHorstTest.scala

Lines changed: 112 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ class ForwardRuleReasonerOWLHorstTest extends FunSuite with SharedSparkContext w
534534
* Consequence:
535535
* w rdfs:subClassOf v
536536
*/
537-
test("Rule O11a and 11b should return correct results") {
537+
test("Rules O11a and 11b should return correct results") {
538538
val cls01 = df.getOWLClass(defaultPrefix + "Cls01")
539539
val cls02 = df.getOWLClass(defaultPrefix + "Cls02")
540540
val cls03 = df.getOWLClass(defaultPrefix + "Cls03")
@@ -594,4 +594,115 @@ class ForwardRuleReasonerOWLHorstTest extends FunSuite with SharedSparkContext w
594594
assert(inferred.size == 1)
595595
assert(inferred.contains(df.getOWLEquivalentClassesAxiom(cls01, cls02)))
596596
}
597+
598+
/**
599+
* O12a:
600+
* Condition:
601+
* v owl:equivalentProperty w
602+
* Consequence:
603+
* v rdfs:subPropertyOf w
604+
*
605+
* O12b:
606+
* Condition:
607+
* v owl:equivalentProperty w
608+
* Consequence:
609+
* w rdfs:subPropertyOf v
610+
*/
611+
test("Rules O12a and 12b should return correct results") {
612+
val objProp01 = df.getOWLObjectProperty(defaultPrefix + "objProp01")
613+
val objProp02 = df.getOWLObjectProperty(defaultPrefix + "objProp02")
614+
val objProp03 = df.getOWLObjectProperty(defaultPrefix + "objProp03")
615+
val objProp04 = df.getOWLObjectProperty(defaultPrefix + "objProp04")
616+
val objProp05 = df.getOWLObjectProperty(defaultPrefix + "objProp05")
617+
618+
var input = getClass.getResource(resourcePath + "test_o12ab_obj_props.owl").getPath
619+
620+
var axiomsRDD = spark.owl(Syntax.FUNCTIONAL)(input)
621+
var reasoner = new ForwardRuleReasonerOWLHorst(sc, sc.defaultMinPartitions)
622+
var inferred: Seq[OWLAxiom] = reasoner.apply(axiomsRDD).collect()
623+
624+
// Eight axioms should be inferred
625+
// SubObjectPropertyOf(:objProp01 :objProp02)
626+
// SubObjectPropertyOf(:objProp01 :objProp03)
627+
// SubObjectPropertyOf(:objProp02 :objProp01)
628+
// SubObjectPropertyOf(:objProp02 :objProp03)
629+
// SubObjectPropertyOf(:objProp03 :objProp01)
630+
// SubObjectPropertyOf(:objProp03 :objProp02)
631+
//
632+
// SubObjectPropertyOf(:objProp04 :objProp05)
633+
// SubObjectPropertyOf(:objProp05 :objProp04)
634+
//
635+
// Could be more than 8 since axioms like
636+
// EquivalentObjectProperties(:objProp01 :objProp02),
637+
// EquivalentObjectProperties(:objProp01 :objProp03) etc. seem to be
638+
// inferred as well
639+
assert(inferred.size >= 8)
640+
assert(inferred.contains(
641+
df.getOWLSubObjectPropertyOfAxiom(objProp01, objProp02)))
642+
assert(inferred.contains(
643+
df.getOWLSubObjectPropertyOfAxiom(objProp01, objProp03)))
644+
assert(inferred.contains(
645+
df.getOWLSubObjectPropertyOfAxiom(objProp02, objProp01)))
646+
assert(inferred.contains(
647+
df.getOWLSubObjectPropertyOfAxiom(objProp02, objProp03)))
648+
assert(inferred.contains(
649+
df.getOWLSubObjectPropertyOfAxiom(objProp03, objProp01)))
650+
assert(inferred.contains(
651+
df.getOWLSubObjectPropertyOfAxiom(objProp03, objProp02)))
652+
653+
assert(inferred.contains(
654+
df.getOWLSubObjectPropertyOfAxiom(objProp04, objProp05)))
655+
assert(inferred.contains(
656+
df.getOWLSubObjectPropertyOfAxiom(objProp05, objProp04)))
657+
658+
// ---
659+
val dataProp01 = df.getOWLDataProperty(defaultPrefix + "dataProp01")
660+
val dataProp02 = df.getOWLDataProperty(defaultPrefix + "dataProp02")
661+
val dataProp03 = df.getOWLDataProperty(defaultPrefix + "dataProp03")
662+
val dataProp04 = df.getOWLDataProperty(defaultPrefix + "dataProp04")
663+
val dataProp05 = df.getOWLDataProperty(defaultPrefix + "dataProp05")
664+
665+
input = getClass.getResource(resourcePath + "test_o12ab_data_props.owl").getPath
666+
667+
axiomsRDD = spark.owl(Syntax.FUNCTIONAL)(input)
668+
reasoner = new ForwardRuleReasonerOWLHorst(sc, sc.defaultMinPartitions)
669+
inferred = reasoner.apply(axiomsRDD).collect()
670+
// Eight axioms should be inferred
671+
// SubDataPropertyOf(:dataProp01 :dataProp02)
672+
// SubDataPropertyOf(:dataProp01 :dataProp03)
673+
// SubDataPropertyOf(:dataProp02 :dataProp01)
674+
// SubDataPropertyOf(:dataProp02 :dataProp03)
675+
// SubDataPropertyOf(:dataProp03 :dataProp01)
676+
// SubDataPropertyOf(:dataProp03 :dataProp02)
677+
//
678+
// SubDataPropertyOf(:dataProp04 :dataProp05)
679+
// SubDataPropertyOf(:dataProp05 :dataProp04)
680+
//
681+
// Could be more than 8 since axioms like
682+
// EquivalentDataProperties(:dataProp01 :dataProp02),
683+
// EquivalentDataProperties(:dataProp01 :dataProp03) etc. seem to be
684+
// inferred as well
685+
assert(inferred.size >= 8)
686+
assert(inferred.contains(
687+
df.getOWLSubDataPropertyOfAxiom(dataProp01, dataProp02)))
688+
assert(inferred.contains(
689+
df.getOWLSubDataPropertyOfAxiom(dataProp01, dataProp03)))
690+
assert(inferred.contains(
691+
df.getOWLSubDataPropertyOfAxiom(dataProp02, dataProp01)))
692+
assert(inferred.contains(
693+
df.getOWLSubDataPropertyOfAxiom(dataProp02, dataProp03)))
694+
assert(inferred.contains(
695+
df.getOWLSubDataPropertyOfAxiom(dataProp03, dataProp01)))
696+
assert(inferred.contains(
697+
df.getOWLSubDataPropertyOfAxiom(dataProp03, dataProp02)))
698+
699+
assert(inferred.contains(
700+
df.getOWLSubDataPropertyOfAxiom(dataProp04, dataProp05)))
701+
assert(inferred.contains(
702+
df.getOWLSubDataPropertyOfAxiom(dataProp05, dataProp04)))
703+
704+
// --
705+
// There is no EquivalentAnnotationProperties( ) construct --> annotation
706+
// property equivalence skipped
707+
}
597708
}

0 commit comments

Comments
 (0)