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

Commit aed373e

Browse files
Added test for ForwardRuleReasonerOWLHorst R1 rule
1 parent d0045e0 commit aed373e

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/ForwardRuleReasonerOWLHorstTest.scala

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,47 @@ class ForwardRuleReasonerOWLHorstTest extends FunSuite with SharedSparkContext w
3333
val res: RDD[OWLAxiom] = reasoner(owlAxiomsRDD)
3434

3535
assert(res.count() == 211)
36+
}
37+
38+
/**
39+
* R1:
40+
* Condition:
41+
* c rdfs:subClassOf c1
42+
* c1 rdfs:subClassOf c2
43+
* Consequence:
44+
* c rdfs:subClassOf c2
45+
*/
46+
test("Rule R1 should return correct results") {
47+
/*
48+
* Class hierarchy:
49+
*
50+
* :Cls01
51+
* / \
52+
* :Cls02 :Cls05
53+
* |
54+
* :Cls03
55+
* |
56+
* :Cls04
57+
*/
58+
val cls01 = df.getOWLClass(defaultPrefix + "Cls01")
59+
val cls02 = df.getOWLClass(defaultPrefix + "Cls02")
60+
val cls03 = df.getOWLClass(defaultPrefix + "Cls03")
61+
val cls04 = df.getOWLClass(defaultPrefix + "Cls04")
62+
63+
val input = getClass.getResource(resourcePath + "test_r1.owl").getPath
64+
65+
val axiomsRDD = spark.owl(Syntax.FUNCTIONAL)(input)
66+
val reasoner = new ForwardRuleReasonerOWLHorst(sc, sc.defaultMinPartitions)
67+
val inferred: Seq[OWLAxiom] = reasoner.apply(axiomsRDD).collect()
68+
69+
// Three new axioms should be inferred:
70+
// SubClassOf(<http://ex.com/default#Cls04> <http://ex.com/default#Cls02>)
71+
// SubClassOf(<http://ex.com/default#Cls03> <http://ex.com/default#Cls01>)
72+
// SubClassOf(<http://ex.com/default#Cls04> <http://ex.com/default#Cls01>)
73+
assert(inferred.size == 3)
74+
assert(inferred.contains(df.getOWLSubClassOfAxiom(cls03, cls01)))
75+
assert(inferred.contains(df.getOWLSubClassOfAxiom(cls04, cls01)))
76+
assert(inferred.contains(df.getOWLSubClassOfAxiom(cls04, cls02)))
3677

3778
}
3879
}

0 commit comments

Comments
 (0)