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

Commit dea42c3

Browse files
Added test for Forw.RuleReasonerOWLHorst rule O14
1 parent 85f8104 commit dea42c3

File tree

2 files changed

+72
-1
lines changed

2 files changed

+72
-1
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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+
Declaration(Class(:Cls01))
10+
Declaration(Class(:Cls02))
11+
Declaration(Class(:Cls03))
12+
Declaration(Class(:Cls04))
13+
Declaration(Class(:Cls05))
14+
Declaration(Class(:Cls06))
15+
Declaration(Class(:Cls07))
16+
Declaration(Class(:Cls08))
17+
18+
Declaration(NamedIndividual(:indivA))
19+
Declaration(NamedIndividual(:indivB))
20+
Declaration(NamedIndividual(:indivC))
21+
Declaration(NamedIndividual(:indivD))
22+
Declaration(NamedIndividual(:indivE))
23+
Declaration(NamedIndividual(:indivF))
24+
Declaration(NamedIndividual(:indivG))
25+
26+
27+
EquivalentClasses(:Cls01 ObjectSomeValuesFrom(:objProp01 :Cls02))
28+
EquivalentClasses(:Cls03 ObjectSomeValuesFrom(:objProp02 :Cls04))
29+
30+
ClassAssertion(:Cls02 :indivB)
31+
ClassAssertion(:Cls05 :indivD)
32+
ClassAssertion(:Cls06 :indivE)
33+
ClassAssertion(:Cls07 :indivF)
34+
ClassAssertion(:Cls08 :indivG)
35+
36+
# indivA should be detected as instance of :Cls01
37+
ObjectPropertyAssertion(:objProp01 :indivA :indivB)
38+
39+
# These should not result in any class assertion inferences
40+
ObjectPropertyAssertion(:objProp01 :indivC :indivD)
41+
ObjectPropertyAssertion(:objProp02 :indivE :indivB)
42+
ObjectPropertyAssertion(:objProp02 :indivF :indivG)
43+
)

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

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,7 @@ class ForwardRuleReasonerOWLHorstTest extends FunSuite with SharedSparkContext w
799799
* Consequence:
800800
* u p v
801801
*
802-
* FIXME: Make this test check the exact count of inferred axioms
802+
* FIXME: Make this test check the exact count of inferred axioms
803803
*/
804804
test("Rule O14 should return correct results") {
805805
val objProp01 = df.getOWLObjectProperty(defaultPrefix + "objProp01")
@@ -825,4 +825,32 @@ class ForwardRuleReasonerOWLHorstTest extends FunSuite with SharedSparkContext w
825825
df.getOWLDataPropertyAssertionAxiom(
826826
dataProp01, indivC, df.getOWLLiteral("ABCD"))))
827827
}
828+
829+
/**
830+
* O15:
831+
* Condition:
832+
* v owl:someValuesFrom w
833+
* v owl:onProperty p
834+
* u p x
835+
* x rdf:type w
836+
* Consequence:
837+
* u rdf:type v
838+
*
839+
* FIXME: Make this test check the exact count of inferred axioms
840+
*/
841+
test("Rule O15 should return correct results") {
842+
val cls01 = df.getOWLClass(defaultPrefix + "Cls01")
843+
val indivA = df.getOWLNamedIndividual(defaultPrefix + "indivA")
844+
845+
val input = getClass.getResource(resourcePath + "test_o15.owl").getPath
846+
847+
val axiomsRDD = spark.owl(Syntax.FUNCTIONAL)(input)
848+
val reasoner = new ForwardRuleReasonerOWLHorst(sc, sc.defaultMinPartitions)
849+
val inferred: Seq[OWLAxiom] = reasoner.apply(axiomsRDD).collect()
850+
851+
// One axiom should be inferred:
852+
// ClassAssertion(:Cls01 :indivA)
853+
assert(inferred.size >= 1)
854+
assert(inferred.contains(df.getOWLClassAssertionAxiom(cls01, indivA)))
855+
}
828856
}

0 commit comments

Comments
 (0)