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

Commit 8652c70

Browse files
Added test for ForwardRuleReasonerOWLHorst O3 rule
1 parent e6c3e67 commit 8652c70

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
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(ObjectProperty(:objProp01))
7+
Declaration(ObjectProperty(:objProp02))
8+
9+
SymmetricObjectProperty(:objProp01)
10+
11+
Declaration(NamedIndividual(:indivA))
12+
Declaration(NamedIndividual(:indivB))
13+
Declaration(NamedIndividual(:indivC))
14+
15+
ObjectPropertyAssertion(:objProp01 :indivA :indivB)
16+
ObjectPropertyAssertion(:objProp02 :indivB :indivC)
17+
)

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,4 +354,30 @@ class ForwardRuleReasonerOWLHorstTest extends FunSuite with SharedSparkContext w
354354
case _ => assert(false)
355355
}
356356
}
357+
358+
/**
359+
* O3:
360+
* Condition:
361+
* p rdf:type owl:SymmetricProperty
362+
* v p u
363+
* Consequence:
364+
* u p v
365+
*/
366+
test("Rule O3 should return correct results") {
367+
val indivA = df.getOWLNamedIndividual(defaultPrefix + "indivA")
368+
val indivB = df.getOWLNamedIndividual(defaultPrefix + "indivB")
369+
val objProp01 = df.getOWLObjectProperty(defaultPrefix + "objProp01")
370+
371+
val input = getClass.getResource(resourcePath + "test_o3.owl").getPath
372+
373+
val axiomsRDD = spark.owl(Syntax.FUNCTIONAL)(input)
374+
val reasoner = new ForwardRuleReasonerOWLHorst(sc, sc.defaultMinPartitions)
375+
val inferred: Seq[OWLAxiom] = reasoner.apply(axiomsRDD).collect()
376+
377+
// One axiom should be inferred:
378+
// ObjectPropertyAssertion(:objProp01 :indivB :indivA)
379+
assert(inferred.size == 1)
380+
assert(inferred.contains(
381+
df.getOWLObjectPropertyAssertionAxiom(objProp01, indivB, indivA)))
382+
}
357383
}

0 commit comments

Comments
 (0)