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

Commit a8c4e17

Browse files
Added test for ForwardRuleReasonerRDFS rdfs11 rule
1 parent 2abb5c8 commit a8c4e17

2 files changed

Lines changed: 57 additions & 0 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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+
Declaration(Class(:Cls05))
11+
12+
SubClassOf(:Cls02 :Cls01)
13+
SubClassOf(:Cls03 :Cls02)
14+
SubClassOf(:Cls04 :Cls03)
15+
SubClassOf(:Cls05 :Cls01)
16+
)

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

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,4 +218,45 @@ class ForwardRuleReasonerRDFSTest extends FunSuite with SharedSparkContext with
218218
assert(inferred.size == 1)
219219
assert(inferred.contains(df.getOWLClassAssertionAxiom(cls01, indivB)))
220220
}
221+
222+
/**
223+
* rdfs11
224+
* Condition:
225+
* xxx rdfs:subClassOf yyy .
226+
* yyy rdfs:subClassOf zzz .
227+
* Consequence:
228+
* xxx rdfs:subClassOf zzz .
229+
*/
230+
test("Rule rdfs11 should return correct results") {
231+
/*
232+
* Class hierarchy:
233+
*
234+
* :Cls01
235+
* / \
236+
* :Cls02 :Cls05
237+
* |
238+
* :Cls03
239+
* |
240+
* :Cls04
241+
*/
242+
val cls01 = df.getOWLClass(defaultPrefix + "Cls01")
243+
val cls02 = df.getOWLClass(defaultPrefix + "Cls02")
244+
val cls03 = df.getOWLClass(defaultPrefix + "Cls03")
245+
val cls04 = df.getOWLClass(defaultPrefix + "Cls04")
246+
247+
val input = getClass.getResource(resourcePath + "test_rdfs11.owl").getPath
248+
249+
val axiomsRDD = spark.owl(Syntax.FUNCTIONAL)(input)
250+
val reasoner = new ForwardRuleReasonerRDFS(sc, sc.defaultMinPartitions)
251+
val inferred: Seq[OWLAxiom] = reasoner.apply(axiomsRDD).collect()
252+
253+
// Three new axioms should be inferred:
254+
// SubClassOf(<http://ex.com/default#Cls04> <http://ex.com/default#Cls02>)
255+
// SubClassOf(<http://ex.com/default#Cls03> <http://ex.com/default#Cls01>)
256+
// SubClassOf(<http://ex.com/default#Cls04> <http://ex.com/default#Cls01>)
257+
assert(inferred.size == 3)
258+
assert(inferred.contains(df.getOWLSubClassOfAxiom(cls03, cls01)))
259+
assert(inferred.contains(df.getOWLSubClassOfAxiom(cls04, cls01)))
260+
assert(inferred.contains(df.getOWLSubClassOfAxiom(cls04, cls02)))
261+
}
221262
}

0 commit comments

Comments
 (0)