@@ -64,7 +64,7 @@ class ForwardRuleReasonerOWLHorst (sc: SparkContext, parallelism: Int = 2) exten
6464 // 1. we have to process owl:equivalentClass (resp. owl:equivalentProperty) before computing the transitive closure
6565 // of rdfs:subClassOf (resp. rdfs:sobPropertyOf)
6666 // O11a: (C owl:equivalentClass D) -> (C rdfs:subClassOf D )
67- // O12b : (C owl:equivalentClass D) -> (D rdfs:subClassOf C )
67+ // O11b : (C owl:equivalentClass D) -> (D rdfs:subClassOf C )
6868
6969 val equClass_Pairs = equClass.asInstanceOf [RDD [OWLEquivalentClassesAxiom ]]
7070 .flatMap(equivClassesAxiom => equivClassesAxiom.asPairwiseAxioms().asScala)
@@ -108,7 +108,7 @@ class ForwardRuleReasonerOWLHorst (sc: SparkContext, parallelism: Int = 2) exten
108108 val equClassMap = equClass_Pairs
109109 .map(a => (a.getOperandsAsList.get(0 ), a.getOperandsAsList.get(1 ))).collect.toMap
110110
111- val equClassSwapMap = equClass_Pairs
111+ val equClassSwapMap = equClass_Pairs
112112 .map(a => (a.getOperandsAsList.get(1 ), a.getOperandsAsList.get(0 ))).collect.toMap
113113
114114 // distribute the schema data structures by means of shared variables
@@ -286,8 +286,8 @@ class ForwardRuleReasonerOWLHorst (sc: SparkContext, parallelism: Int = 2) exten
286286 val objHasVal = eq.filter(a => a.getClassExpressionType.equals(ClassExpressionType .OBJECT_HAS_VALUE ))
287287 val objAllValues = eq.filter(a => a.getClassExpressionType.equals(ClassExpressionType .OBJECT_ALL_VALUES_FROM ))
288288 val objSomeValues = eq.filter(a => a.getClassExpressionType.equals(ClassExpressionType .OBJECT_SOME_VALUES_FROM ))
289- // val dataAllValues = eq.filter(a => a.getClassExpressionType.equals(ClassExpressionType.DATA_ALL_VALUES_FROM))
290- // val dataSomeValues = eq.filter(a => a.getClassExpressionType.equals(ClassExpressionType.DATA_SOME_VALUES_FROM))
289+ val dataAllValues = eq.filter(a => a.getClassExpressionType.equals(ClassExpressionType .DATA_ALL_VALUES_FROM ))
290+ val dataSomeValues = eq.filter(a => a.getClassExpressionType.equals(ClassExpressionType .DATA_SOME_VALUES_FROM ))
291291
292292 val dataHasValBC = sc.broadcast(dataHasVal.asInstanceOf [RDD [OWLDataHasValue ]]
293293 .map(a => (a.getProperty, a.getFiller)).collect().toMap)
@@ -307,14 +307,14 @@ class ForwardRuleReasonerOWLHorst (sc: SparkContext, parallelism: Int = 2) exten
307307 val objSomeValuesSwapBC = sc.broadcast(objSomeValues.asInstanceOf [RDD [OWLObjectSomeValuesFrom ]]
308308 .map(a => (a.getFiller, a.getProperty)).collect().toMap)
309309
310- // val dataAllValuesBC = sc.broadcast(dataAllValues.asInstanceOf[RDD[OWLDataAllValuesFrom]]
311- // .map(a => (a.getProperty, a.getFiller)).collect().toMap)
310+ val dataAllValuesBC = sc.broadcast(dataAllValues.asInstanceOf [RDD [OWLDataAllValuesFrom ]]
311+ .map(a => (a.getProperty, a.getFiller)).collect().toMap)
312312
313- // val dataSomeValuesBC = sc.broadcast(dataSomeValues.asInstanceOf[RDD[OWLDataSomeValuesFrom]]
314- // .map(a => (a.getProperty, a.getFiller)).collect().toMap)
313+ val dataSomeValuesBC = sc.broadcast(dataSomeValues.asInstanceOf [RDD [OWLDataSomeValuesFrom ]]
314+ .map(a => (a.getProperty, a.getFiller)).collect().toMap)
315315
316- // val dataSomeValuesSwapBC = sc.broadcast(dataSomeValues.asInstanceOf[RDD[OWLDataSomeValuesFrom]]
317- // .map(a => (a.getFiller, a.getProperty)).collect().toMap)
316+ val dataSomeValuesSwapBC = sc.broadcast(dataSomeValues.asInstanceOf [RDD [OWLDataSomeValuesFrom ]]
317+ .map(a => (a.getFiller, a.getProperty)).collect().toMap)
318318
319319 // val ca = CollectionUtils
320320 // .toMultiMap(typeAxioms.map(a => (a.getClassExpression, a.getIndividual)).collect())
@@ -323,8 +323,6 @@ class ForwardRuleReasonerOWLHorst (sc: SparkContext, parallelism: Int = 2) exten
323323 // val e = equClass.asInstanceOf[RDD[OWLEquivalentClassesAxiom]]
324324 // .filter(a => caBC.value.exists(n => a.contains(n._1)) && a.getOperandsAsList.get(1).isInstanceOf[OWLDataHasValue])
325325
326-
327-
328326 // Perform fix-point iteration i.e. we process a set of rules until no new data has been generated
329327
330328 var newData = true
@@ -524,25 +522,7 @@ class ForwardRuleReasonerOWLHorst (sc: SparkContext, parallelism: Int = 2) exten
524522// typeAxioms = new UnionRDD(sc, Seq(typeAxioms, O13_data_a, O13_data_b, O13_obj_a, O13_obj_b))
525523// .distinct(parallelism)
526524
527- // val eos: RDD[(OWLClassExpression, OWLObjectSomeValuesFrom)] = eqOperands.filter(eq => eq._2.isInstanceOf[OWLObjectSomeValuesFrom])
528- // .map(eq => (eq._1, eq._2.asInstanceOf[OWLObjectSomeValuesFrom]))
529- // val eosMapBC: Broadcast[Map[OWLClassExpression, OWLObjectSomeValuesFrom]] = sc.broadcast(eos.collect().toMap)
530-
531- // val O15_1 = typeAxioms.filter(a => equClassMapBC.value.contains(a.getClassExpression))
532- // .map(a => (a.getClassExpression, a.getIndividual))
533- // .join(eos)
534- // .map(a => ((a._1, a._2._1), Nil))
535-
536- // val O15_data_1: RDD[(OWLLiteral, OWLIndividual)] = dataPropAssertion.filter(a => dataSomeValuesBC.value.contains(a.getProperty))
537- // .map(a => (a.getObject, a.getSubject))
538-
539- // val O15_data_2: RDD[(OWLIndividual, OWLClassExpression)] = typeAxioms.filter(a => dataSomeValuesBC.value.contains(a.getClassExpression)
540- // && equClassMapBC.value.contains(a.getClassExpression))
541- // .map(a => (a.getIndividual, a.getClassExpression))
542- //
543- // val O15_1 = O15_data_1.join(O15_data_2)
544- // // .map(a => dataFactory.getOWLClassAssertionAxiom(a.))
545-
525+ // Apply O15, O16 only on ObjectAssertions because we compare individuals
546526
547527 // O15: (R owl:someValuesFrom D), (R owl:onProperty P), (X P A), (A rdf:type D ) -> (X rdf:type R )
548528 val O15_obj_1 = objPropAssertion.filter(a => objSomeValuesBC.value.contains(a.getProperty))
@@ -551,13 +531,10 @@ class ForwardRuleReasonerOWLHorst (sc: SparkContext, parallelism: Int = 2) exten
551531 val O15_obj_2 = typeAxioms.filter(a => objSomeValuesSwapBC.value.contains(a.getClassExpression)
552532 && equClassMapBC.value.contains(a.getClassExpression))
553533 .map(a => (a.getIndividual, a.getClassExpression)) // (A, D)
554- // .join(eos)
555- // .map(a => (a._2._1, a._1))
556534
557535 val O15 = O15_obj_1 .join(O15_obj_2 ) // Join on A to get (A, (X, D))
558536 .map(a => dataFactory.getOWLClassAssertionAxiom(a._2._2, a._2._1))
559537
560-
561538 // O16: (R owl:allValuesFrom D), (R owl:onProperty P), (X P Y), (X rdf:type R ) -> (Y rdf:type D)
562539 val O16_1 = objPropAssertion.filter(a => objAllValuesBC.value.contains(a.getProperty))
563540 .map(a => (a.getSubject, a.getObject)) // (X, Y)
@@ -574,11 +551,11 @@ class ForwardRuleReasonerOWLHorst (sc: SparkContext, parallelism: Int = 2) exten
574551 newTypeCount = newTypeAxioms.count()
575552
576553 if (newTypeCount > 0 ) {
577- // add type axioms
578- typeAxioms = typeAxioms.union(newTypeAxioms)
554+
555+ typeAxioms = typeAxioms.union(newTypeAxioms) // add type axioms
579556 }
580- newData = newTypeCount > 0 || newAxiomsCount > 0
581557
558+ newData = newTypeCount > 0 || newAxiomsCount > 0
582559
583560 newAxioms = sc.union(newAxioms, O14_data .asInstanceOf [RDD [OWLAxiom ]], O14_obj .asInstanceOf [RDD [OWLAxiom ]])
584561 .distinct(parallelism)
@@ -590,7 +567,8 @@ class ForwardRuleReasonerOWLHorst (sc: SparkContext, parallelism: Int = 2) exten
590567
591568 val infered : Long = allAxioms.count - newTypeCount - newAxiomsCount
592569
593- println(" \n Finish with " + infered + " Inferred Axioms from Schema, SPO and Type rules" )
570+ // println("\n Finish with " + infered + " Inferred Axioms from Schema, SPO and Type rules")
571+
594572 // --------------------- SameAs Rules --------------------------
595573
596574 // O1: (P rdf:type owl:FunctionalProperty), (A P B), notLiteral(B), (A P C), notLiteral(C), notEqual(B C) -> (B owl:sameAs C)
@@ -614,9 +592,6 @@ class ForwardRuleReasonerOWLHorst (sc: SparkContext, parallelism: Int = 2) exten
614592 .map(a => dataFactory.getOWLSameIndividualAxiom(a._2._1, a._2._2)) // A owl:sameAs C
615593 .distinct(parallelism)
616594
617- // println("\n O2: \n----------------\n")
618- // O2.collect().foreach(println)
619-
620595 var newSameAsAxioms = sc.union(O1 , O2 )
621596 sameAsAxioms = sc.union(sameAsAxioms, newSameAsAxioms).distinct(parallelism)
622597
@@ -625,7 +600,7 @@ class ForwardRuleReasonerOWLHorst (sc: SparkContext, parallelism: Int = 2) exten
625600 var inferedAxioms = sc.union(typeAxioms.asInstanceOf [RDD [OWLAxiom ]], sameAsAxioms.asInstanceOf [RDD [OWLAxiom ]], SPOAxioms )
626601 .subtract(axioms)
627602
628- println(" \n Finish with " + inferedAxioms.count + " Inferred Axioms after adding SameAs rules" )
603+ // println("\n Finish with " + inferedAxioms.count + " Inferred Axioms after adding SameAs rules")
629604 println(" \n ...finished materialization in " + (Time / 1000 ) + " sec." )
630605
631606 inferedAxioms
0 commit comments