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

Commit e6c3e67

Browse files
Added test for ForwardRuleReasonerOWLHorst O2 rule
1 parent c5a5104 commit e6c3e67

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
InverseFunctionalObjectProperty(:objProp01)
10+
11+
Declaration(NamedIndividual(:indivA))
12+
Declaration(NamedIndividual(:indivB))
13+
Declaration(NamedIndividual(:indivC))
14+
Declaration(NamedIndividual(:indivD))
15+
Declaration(NamedIndividual(:indivE))
16+
Declaration(NamedIndividual(:indivF))
17+
18+
ObjectPropertyAssertion(:objProp01 :indivA :indivB)
19+
ObjectPropertyAssertion(:objProp01 :indivC :indivB)
20+
ObjectPropertyAssertion(:objProp01 :indivD :indivB)
21+
ObjectPropertyAssertion(:objProp02 :indivE :indivF)
22+
)

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

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,4 +310,48 @@ class ForwardRuleReasonerOWLHorstTest extends FunSuite with SharedSparkContext w
310310
case _ => assert(false)
311311
}
312312
}
313+
314+
/**
315+
* O2:
316+
* Condition:
317+
* p rdf:type owl:InverseFunctionalProperty
318+
* v p u
319+
* w p u
320+
* Consequence:
321+
* v owl:sameAs w
322+
*/
323+
test("Rule O2 should return correct results") {
324+
val indivA = df.getOWLNamedIndividual(defaultPrefix + "indivA")
325+
val indivC = df.getOWLNamedIndividual(defaultPrefix + "indivC")
326+
val indivD = df.getOWLNamedIndividual(defaultPrefix + "indivD")
327+
328+
val input = getClass.getResource(resourcePath + "test_o2.owl").getPath
329+
330+
val axiomsRDD = spark.owl(Syntax.FUNCTIONAL)(input)
331+
val reasoner = new ForwardRuleReasonerOWLHorst(sc, sc.defaultMinPartitions)
332+
val inferred: Seq[OWLAxiom] = reasoner.apply(axiomsRDD).collect()
333+
334+
// It should be either one axiom inferred:
335+
// SameIndividual(:indivA :indivC :indivD)
336+
// or three pairwise axioms:
337+
// SameIndividual(:indivA :indivC)
338+
// SameIndividual(:indivA :indivD)
339+
// SameIndividual(:indivC :indivD)
340+
// (where the individual operand pairs may be in arbitrary order)
341+
// Permutations are assumed to be handled by the axiom's equals method.
342+
inferred.size match {
343+
case 1 => assert(
344+
inferred.contains(
345+
df.getOWLSameIndividualAxiom(Seq(indivA, indivC, indivD).asJava)))
346+
case 3 =>
347+
assert( // B == C
348+
inferred.contains(df.getOWLSameIndividualAxiom(indivA, indivC)))
349+
assert( // B == D
350+
inferred.contains(df.getOWLSameIndividualAxiom(indivA, indivD)))
351+
assert( // C == D
352+
inferred.contains(df.getOWLSameIndividualAxiom(indivC, indivD))
353+
)
354+
case _ => assert(false)
355+
}
356+
}
313357
}

0 commit comments

Comments
 (0)