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

Commit c1e22c4

Browse files
Added test for ForwardRuleReasonerOWLHorst R6 rule
1 parent 4751d10 commit c1e22c4

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
Declaration(Class(:Cls04))
10+
11+
SubClassOf(:Cls02 :Cls01)
12+
SubClassOf(:Cls03 :Cls01)
13+
14+
Declaration(NamedIndividual(:indivA))
15+
Declaration(NamedIndividual(:indivB))
16+
Declaration(NamedIndividual(:indivC))
17+
18+
ClassAssertion(:Cls03 :indivA)
19+
ClassAssertion(:Cls02 :indivB)
20+
ClassAssertion(:Cls04 :indivC)
21+
)

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,4 +238,31 @@ class ForwardRuleReasonerOWLHorstTest extends FunSuite with SharedSparkContext w
238238
assert(inferred.size == 1)
239239
assert(inferred.contains(df.getOWLClassAssertionAxiom(cls01, indivC)))
240240
}
241+
242+
/**
243+
* R6:
244+
* Condition:
245+
* c rdfs:subClassOf c1
246+
* v rdf:type c
247+
* Consequence:
248+
* v rdf:type c1
249+
*/
250+
test("Rule R6 should return correct results") {
251+
val cls01 = df.getOWLClass(defaultPrefix + "Cls01")
252+
val indivA = df.getOWLNamedIndividual(defaultPrefix + "indivA")
253+
val indivB = df.getOWLNamedIndividual(defaultPrefix + "indivB")
254+
255+
val input = getClass.getResource(resourcePath + "test_r6.owl").getPath
256+
257+
val axiomsRDD = spark.owl(Syntax.FUNCTIONAL)(input)
258+
val reasoner = new ForwardRuleReasonerOWLHorst(sc, sc.defaultMinPartitions)
259+
val inferred: Seq[OWLAxiom] = reasoner.apply(axiomsRDD).collect()
260+
261+
// Two axioms should be inferred:
262+
// ClassAssertion(bar:Cls1 :indivA)
263+
// ClassAssertion(bar:Cls1 :indivB)
264+
assert(inferred.size == 2)
265+
assert(inferred.contains(df.getOWLClassAssertionAxiom(cls01, indivA)))
266+
assert(inferred.contains(df.getOWLClassAssertionAxiom(cls01, indivB)))
267+
}
241268
}

0 commit comments

Comments
 (0)