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

Commit bd60841

Browse files
Omit trivial triples
Triples (c rdfs:subClassOf c) and (p rdfs:subPropertyOf p) that might be generated during TC computation are omitted now.
1 parent a4bdb1e commit bd60841

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

sansa-inference-spark/src/main/scala/net/sansa_stack/inference/spark/forwardchaining/ForwardRuleReasonerOWLHorst.scala

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,25 +42,31 @@ class ForwardRuleReasonerOWLHorst(sc: SparkContext, parallelism: Int = 2) extend
4242
// of rdfs:subClassOf (resp. rdfs:sobPropertyOf)
4343
// rdfp12a: (?C owl:equivalentClass ?D) -> (?C rdfs:subClassOf ?D )
4444
// rdfp12b: (?C owl:equivalentClass ?D) -> (?D rdfs:subClassOf ?C )
45-
subClassOfTriples = sc.union(
46-
subClassOfTriples,
47-
equivClassTriples.map(t => RDFTriple(t.s, RDFS.subClassOf.getURI, t.o)),
48-
equivClassTriples.map(t => RDFTriple(t.o, RDFS.subClassOf.getURI, t.s)))
45+
subClassOfTriples = sc
46+
.union(
47+
subClassOfTriples,
48+
equivClassTriples.map(t => RDFTriple(t.s, RDFS.subClassOf.getURI, t.o)),
49+
equivClassTriples.map(t => RDFTriple(t.o, RDFS.subClassOf.getURI, t.s))
50+
)
4951
.distinct(parallelism)
5052

5153
// rdfp13a: (?C owl:equivalentProperty ?D) -> (?C rdfs:subPropertyOf ?D )
5254
// rdfp13b: (?C owl:equivalentProperty ?D) -> (?D rdfs:subPropertyOf ?C )
53-
subPropertyOfTriples = sc.union(
54-
subPropertyOfTriples,
55-
equivPropertyTriples.map(t => RDFTriple(t.s, RDFS.subPropertyOf.getURI, t.o)),
56-
equivPropertyTriples.map(t => RDFTriple(t.o, RDFS.subPropertyOf.getURI, t.s)))
55+
subPropertyOfTriples = sc
56+
.union(
57+
subPropertyOfTriples,
58+
equivPropertyTriples.map(t => RDFTriple(t.s, RDFS.subPropertyOf.getURI, t.o)),
59+
equivPropertyTriples.map(t => RDFTriple(t.o, RDFS.subPropertyOf.getURI, t.s))
60+
)
5761
.distinct(parallelism)
5862

5963
// 2. we compute the transitive closure of rdfs:subPropertyOf and rdfs:subClassOf
6064
// rdfs11: (xxx rdfs:subClassOf yyy), (yyy rdfs:subClassOf zzz) -> (xxx rdfs:subClassOf zzz)
6165
val subClassOfTriplesTrans = computeTransitiveClosure(subClassOfTriples)
66+
.filter(t => t.s != t.o) // omit (c1 rdfs:subClassOf c1) triples
6267
// rdfs5: (xxx rdfs:subPropertyOf yyy), (yyy rdfs:subPropertyOf zzz) -> (xxx rdfs:subPropertyOf zzz)
6368
val subPropertyOfTriplesTrans = computeTransitiveClosure(subPropertyOfTriples)
69+
.filter(t => t.s != t.o) // omit (p1 rdfs:subPropertyOf p1) triples
6470

6571

6672
// we put all into maps which should be more efficient later on

0 commit comments

Comments
 (0)