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

Commit da8c023

Browse files
Added test for Forw.RuleReasonerOWLHorst O7b rule
1 parent f52cf3b commit da8c023

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
InverseObjectProperties(:objProp01 :objProp02)
11+
12+
Declaration(NamedIndividual(:indivA))
13+
Declaration(NamedIndividual(:indivB))
14+
Declaration(NamedIndividual(:indivC))
15+
16+
ObjectPropertyAssertion(:objProp02 :indivB :indivA)
17+
ObjectPropertyAssertion(:objProp03 :indivB :indivC)
18+
)

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
@@ -438,4 +438,30 @@ class ForwardRuleReasonerOWLHorstTest extends FunSuite with SharedSparkContext w
438438
assert(inferred.contains(
439439
df.getOWLObjectPropertyAssertionAxiom(objProp02, indivB, indivA)))
440440
}
441+
442+
/**
443+
* O7b:
444+
* Condition:
445+
* p owl:inverseOf q
446+
* v q w
447+
* Consequence:
448+
* w p v
449+
*/
450+
test("Rule O7b should return correct results") {
451+
val indivA = df.getOWLNamedIndividual(defaultPrefix + "indivA")
452+
val indivB = df.getOWLNamedIndividual(defaultPrefix + "indivB")
453+
val objProp01 = df.getOWLObjectProperty(defaultPrefix + "objProp01")
454+
455+
val input = getClass.getResource(resourcePath + "test_o7b.owl").getPath
456+
457+
val axiomsRDD = spark.owl(Syntax.FUNCTIONAL)(input)
458+
val reasoner = new ForwardRuleReasonerOWLHorst(sc, sc.defaultMinPartitions)
459+
val inferred: Seq[OWLAxiom] = reasoner.apply(axiomsRDD).collect()
460+
461+
// One axiom should be inferred:
462+
// ObjectPropertyAssertion(:objProp01 :indivA :indivB)
463+
assert(inferred.size == 1)
464+
assert(inferred.contains(
465+
df.getOWLObjectPropertyAssertionAxiom(objProp01, indivA, indivB)))
466+
}
441467
}

0 commit comments

Comments
 (0)