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

Commit 477ccb1

Browse files
Added test for ForwardRuleReasonerOWLHorst R4 rule
1 parent e76db6e commit 477ccb1

File tree

2 files changed

+69
-0
lines changed

2 files changed

+69
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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(Class(:Cls01))
7+
Declaration(Class(:Cls02))
8+
Declaration(Class(:Cls03))
9+
10+
Declaration(NamedIndividual(:indivA))
11+
Declaration(NamedIndividual(:indivB))
12+
Declaration(NamedIndividual(:indivC))
13+
Declaration(NamedIndividual(:indivD))
14+
Declaration(NamedIndividual(:indivE))
15+
Declaration(NamedIndividual(:indivF))
16+
17+
Declaration(ObjectProperty(:objProp01))
18+
Declaration(ObjectProperty(:objProp02))
19+
ObjectPropertyDomain(:objProp02 :Cls01)
20+
21+
Declaration(DataProperty(:dataProp01))
22+
Declaration(DataProperty(:dataProp02))
23+
DataPropertyDomain(:dataProp02 :Cls02)
24+
25+
Declaration(AnnotationProperty(:annProp01))
26+
Declaration(AnnotationProperty(:annProp02))
27+
AnnotationPropertyDomain(:annProp02 :Cls03)
28+
29+
ObjectPropertyAssertion(:objProp01 :indivA :indivB)
30+
ObjectPropertyAssertion(:objProp02 :indivB :indivC)
31+
32+
DataPropertyAssertion(:dataProp01 :indivC "ABCD")
33+
DataPropertyAssertion(:dataProp02 :indivD "DCBA")
34+
35+
AnnotationAssertion(:annProp01 :indivE "wxyz")
36+
AnnotationAssertion(:annProp02 :indivF "zyxw")
37+
)

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,38 @@ class ForwardRuleReasonerOWLHorstTest extends FunSuite with SharedSparkContext w
175175
assert(inferred.contains(
176176
df.getOWLAnnotationAssertionAxiom(annProp01, indivA.getIRI,
177177
df.getOWLLiteral("wxyz"))))
178+
}
179+
180+
/**
181+
* R4:
182+
* Condition:
183+
* s rdfs:domain x
184+
* u s y
185+
* Consequence:
186+
* u rdf:type x
187+
*/
188+
test("Rule R4 should return correct results") {
189+
val cls01 = df.getOWLClass(defaultPrefix + "Cls01")
190+
val cls02 = df.getOWLClass(defaultPrefix + "Cls02")
191+
val cls03 = df.getOWLClass(defaultPrefix + "Cls03")
192+
val indivB = df.getOWLNamedIndividual(defaultPrefix + "indivB")
193+
val indivD = df.getOWLNamedIndividual(defaultPrefix + "indivD")
194+
val indivF = df.getOWLNamedIndividual(defaultPrefix + "indivF")
195+
196+
val input = getClass.getResource(resourcePath + "test_r4.owl").getPath
197+
198+
val axiomsRDD = spark.owl(Syntax.FUNCTIONAL)(input)
199+
val reasoner = new ForwardRuleReasonerOWLHorst(sc, sc.defaultMinPartitions)
200+
val inferred: Seq[OWLAxiom] = reasoner.apply(axiomsRDD).collect()
201+
202+
// Three axioms should be inferred:
203+
// ClassAssertion(:Cls01 :indivB)
204+
// ClassAssertion(:Cls02 :indivD)
205+
// ClassAssertion(:Cls03 :indivF)
206+
assert(inferred.size == 3)
207+
assert(inferred.contains(df.getOWLClassAssertionAxiom(cls01, indivB)))
208+
assert(inferred.contains(df.getOWLClassAssertionAxiom(cls02, indivD)))
209+
assert(inferred.contains(df.getOWLClassAssertionAxiom(cls03, indivF)))
178210

179211
}
180212
}

0 commit comments

Comments
 (0)