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

Commit 85f8104

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

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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(DataProperty(:dataProp01))
10+
Declaration(DataProperty(:dataProp02))
11+
12+
Declaration(Class(:Cls01))
13+
Declaration(Class(:Cls02))
14+
Declaration(Class(:Cls03))
15+
Declaration(Class(:Cls04))
16+
17+
Declaration(NamedIndividual(:indivA))
18+
Declaration(NamedIndividual(:indivB))
19+
Declaration(NamedIndividual(:indivC))
20+
Declaration(NamedIndividual(:indivD))
21+
Declaration(NamedIndividual(:indivE))
22+
23+
EquivalentClasses(:Cls01 ObjectHasValue(:objProp01 :indivB))
24+
EquivalentClasses(:Cls02 DataHasValue(:dataProp01 "ABCD"))
25+
26+
ClassAssertion(:Cls01 :indivA)
27+
ClassAssertion(:Cls02 :indivC)
28+
ClassAssertion(:Cls03 :indivD)
29+
ClassAssertion(:Cls04 :indivE)
30+
)

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,4 +789,40 @@ class ForwardRuleReasonerOWLHorstTest extends FunSuite with SharedSparkContext w
789789
df.getOWLDataHasValue(dataProp01, df.getOWLLiteral("ABCD")),
790790
indivI)))
791791
}
792+
793+
/**
794+
* O14:
795+
* Condition:
796+
* v owl:hasValue w
797+
* v owl:onProperty p
798+
* u rdf:type v
799+
* Consequence:
800+
* u p v
801+
*
802+
* FIXME: Make this test check the exact count of inferred axioms
803+
*/
804+
test("Rule O14 should return correct results") {
805+
val objProp01 = df.getOWLObjectProperty(defaultPrefix + "objProp01")
806+
val dataProp01 = df.getOWLDataProperty(defaultPrefix + "dataProp01")
807+
808+
val indivA = df.getOWLNamedIndividual(defaultPrefix + "indivA")
809+
val indivB = df.getOWLNamedIndividual(defaultPrefix + "indivB")
810+
val indivC = df.getOWLNamedIndividual(defaultPrefix + "indivC")
811+
812+
val input = getClass.getResource(resourcePath + "test_o14.owl").getPath
813+
814+
val axiomsRDD = spark.owl(Syntax.FUNCTIONAL)(input)
815+
val reasoner = new ForwardRuleReasonerOWLHorst(sc, sc.defaultMinPartitions)
816+
val inferred: Seq[OWLAxiom] = reasoner.apply(axiomsRDD).collect()
817+
818+
// Two axioms should be inferred:
819+
// ObjectPropertyAssertion(:objProp01 :indivA :indivB)
820+
// DataPropertyAssertion(:dataProp01 :indivC "ABCD")
821+
assert(inferred.size >= 2)
822+
assert(inferred.contains(
823+
df.getOWLObjectPropertyAssertionAxiom(objProp01, indivA, indivB)))
824+
assert(inferred.contains(
825+
df.getOWLDataPropertyAssertionAxiom(
826+
dataProp01, indivC, df.getOWLLiteral("ABCD"))))
827+
}
792828
}

0 commit comments

Comments
 (0)