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

Commit c8e2c54

Browse files
Added test for Forw.RuleReasonerOWLHorst rule O16
1 parent f1d2e8f commit c8e2c54

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
9+
Declaration(Class(:Cls01))
10+
Declaration(Class(:Cls02))
11+
12+
Declaration(NamedIndividual(:indivA))
13+
Declaration(NamedIndividual(:indivB))
14+
Declaration(NamedIndividual(:indivC))
15+
Declaration(NamedIndividual(:indivD))
16+
Declaration(NamedIndividual(:indivE))
17+
Declaration(NamedIndividual(:indivF))
18+
19+
EquivalentClasses(:Cls01 ObjectAllValuesFrom(:objProp01 :Cls02))
20+
21+
ClassAssertion(:Cls01 :indivA)
22+
23+
# :indivB, :indivC and :indivD should be detected as instance of :Cls02
24+
ObjectPropertyAssertion(:objProp01 :indivA :indivB)
25+
ObjectPropertyAssertion(:objProp01 :indivA :indivC)
26+
ObjectPropertyAssertion(:objProp01 :indivA :indivD)
27+
28+
# These should not result in any class assertion inferences
29+
ObjectPropertyAssertion(:objProp02 :indivA :indivD)
30+
ObjectPropertyAssertion(:objProp02 :indivE :indivF)
31+
)

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

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -853,4 +853,38 @@ class ForwardRuleReasonerOWLHorstTest extends FunSuite with SharedSparkContext w
853853
assert(inferred.size >= 1)
854854
assert(inferred.contains(df.getOWLClassAssertionAxiom(cls01, indivA)))
855855
}
856+
857+
/**
858+
* O16:
859+
* Condition:
860+
* v owl:allValuesFrom w
861+
* v owl:onProperty p
862+
* u rdf:type v
863+
* u p x
864+
* Consequence:
865+
* x rdf:type w
866+
*
867+
* FIXME: Make this test check the exact count of inferred axioms
868+
*/
869+
test("Rule O16 should return correct results") {
870+
val cls02 = df.getOWLClass(defaultPrefix + "Cls01")
871+
val indivB = df.getOWLNamedIndividual(defaultPrefix + "indivB")
872+
val indivC = df.getOWLNamedIndividual(defaultPrefix + "indivC")
873+
val indivD = df.getOWLNamedIndividual(defaultPrefix + "indivD")
874+
875+
val input = getClass.getResource(resourcePath + "test_o16.owl").getPath
876+
877+
val axiomsRDD = spark.owl(Syntax.FUNCTIONAL)(input)
878+
val reasoner = new ForwardRuleReasonerOWLHorst(sc, sc.defaultMinPartitions)
879+
val inferred: Seq[OWLAxiom] = reasoner.apply(axiomsRDD).collect()
880+
881+
// Three axioms should be inferred:
882+
// ClassAssertion(:Cls02 :indivB)
883+
// ClassAssertion(:Cls02 :indivC)
884+
// ClassAssertion(:Cls02 :indivD)
885+
assert(inferred.size >= 3)
886+
assert(inferred.contains(df.getOWLClassAssertionAxiom(cls02, indivB)))
887+
assert(inferred.contains(df.getOWLClassAssertionAxiom(cls02, indivC)))
888+
assert(inferred.contains(df.getOWLClassAssertionAxiom(cls02, indivD)))
889+
}
856890
}

0 commit comments

Comments
 (0)