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

Commit cf5ea63

Browse files
Added test for ForwardRuleReasonerOWLHorst O4 rule
1 parent 8652c70 commit cf5ea63

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
TransitiveObjectProperty(: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 :indivB :indivC)
20+
ObjectPropertyAssertion(:objProp01 :indivC :indivD)
21+
22+
ObjectPropertyAssertion(:objProp02 :indivB :indivE)
23+
ObjectPropertyAssertion(:objProp01 :indivE :indivF)
24+
)

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
@@ -380,4 +380,36 @@ class ForwardRuleReasonerOWLHorstTest extends FunSuite with SharedSparkContext w
380380
assert(inferred.contains(
381381
df.getOWLObjectPropertyAssertionAxiom(objProp01, indivB, indivA)))
382382
}
383+
384+
/**
385+
* O4:
386+
* Condition:
387+
* p rdf:type owl:TransitiveProperty
388+
* u p w
389+
* w p v
390+
* Consequence:
391+
* u p v
392+
*/
393+
test("Rule O4 should return correct results") {
394+
val indivA = df.getOWLNamedIndividual(defaultPrefix + "indivA")
395+
val indivB = df.getOWLNamedIndividual(defaultPrefix + "indivB")
396+
val indivC = df.getOWLNamedIndividual(defaultPrefix + "indivC")
397+
val indivD = df.getOWLNamedIndividual(defaultPrefix + "indivD")
398+
val objProp01 = df.getOWLObjectProperty(defaultPrefix + "objProp01")
399+
400+
val input = getClass.getResource(resourcePath + "test_o4.owl").getPath
401+
402+
val axiomsRDD = spark.owl(Syntax.FUNCTIONAL)(input)
403+
val reasoner = new ForwardRuleReasonerOWLHorst(sc, sc.defaultMinPartitions)
404+
val inferred: Seq[OWLAxiom] = reasoner.apply(axiomsRDD).collect()
405+
406+
// Three axioms should be inferred:
407+
// ObjectPropertyAssertion(:objProp01 :indivA :indivC)
408+
// ObjectPropertyAssertion(:objProp01 :indivA :indivD)
409+
// ObjectPropertyAssertion(:objProp01 :indivB :indivD)
410+
assert(inferred.size == 3)
411+
assert(inferred.contains(df.getOWLObjectPropertyAssertionAxiom(objProp01, indivA, indivC)))
412+
assert(inferred.contains(df.getOWLObjectPropertyAssertionAxiom(objProp01, indivA, indivD)))
413+
assert(inferred.contains(df.getOWLObjectPropertyAssertionAxiom(objProp01, indivB, indivD)))
414+
}
383415
}

0 commit comments

Comments
 (0)