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

Commit 2abb5c8

Browse files
Added test for ForwardRuleReasonerRDFS rdfs9 rule
1 parent 146b34c commit 2abb5c8

2 files changed

Lines changed: 43 additions & 0 deletions

File tree

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

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,4 +194,28 @@ class ForwardRuleReasonerRDFSTest extends FunSuite with SharedSparkContext with
194194
df.getOWLAnnotationAssertionAxiom(annProp01, indivA.getIRI,
195195
df.getOWLLiteral("wxyz"))))
196196
}
197+
198+
/**
199+
* rdfs9
200+
* Condition:
201+
* xxx rdfs:subClassOf yyy .
202+
* zzz rdf:type xxx .
203+
* Consequence:
204+
* zzz rdf:type yyy .
205+
*/
206+
test("Rule rdfs9 should return correct results") {
207+
val cls01 = df.getOWLClass(defaultPrefix + "Cls01")
208+
val indivB = df.getOWLNamedIndividual(defaultPrefix + "indivB")
209+
210+
val input = getClass.getResource(resourcePath + "test_rdfs9.owl").getPath
211+
212+
val axiomsRDD = spark.owl(Syntax.FUNCTIONAL)(input)
213+
val reasoner = new ForwardRuleReasonerRDFS(sc, sc.defaultMinPartitions)
214+
val inferred: Seq[OWLAxiom] = reasoner.apply(axiomsRDD).collect()
215+
216+
// One axiom should be inferred:
217+
// ClassAssertion(:Cls01 :indivB)
218+
assert(inferred.size == 1)
219+
assert(inferred.contains(df.getOWLClassAssertionAxiom(cls01, indivB)))
220+
}
197221
}

0 commit comments

Comments
 (0)