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

Commit 6fe5728

Browse files
Merge branch 'experimental' into feature/dependency-updates
2 parents 7be391b + e116237 commit 6fe5728

File tree

9 files changed

+207
-90
lines changed

9 files changed

+207
-90
lines changed

pom.xml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,16 @@
177177
<artifactId>jena-arq</artifactId>
178178
<version>${jena.version}</version>
179179
</dependency>
180+
<dependency>
181+
<groupId>org.apache.jena</groupId>
182+
<artifactId>jena-tdb</artifactId>
183+
<version>${jena.version}</version>
184+
</dependency>
185+
<dependency>
186+
<groupId>org.apache.jena</groupId>
187+
<artifactId>jena-cmds</artifactId>
188+
<version>${jena.version}</version>
189+
</dependency>
180190

181191
<!-- OWL API -->
182192
<dependency>
@@ -202,14 +212,14 @@
202212

203213
<!-- Graph API -->
204214
<dependency>
205-
<groupId>com.assembla.scala-incubator</groupId>
215+
<groupId>org.scala-graph</groupId>
206216
<artifactId>graph-core_${scala.binary.version}</artifactId>
207-
<version>1.10.0</version>
217+
<version>1.12.3</version>
208218
</dependency>
209219
<dependency>
210-
<groupId>com.assembla.scala-incubator</groupId>
220+
<groupId>org.scala-graph</groupId>
211221
<artifactId>graph-dot_${scala.binary.version}</artifactId>
212-
<version>1.9.0</version>
222+
<version>1.11.5</version>
213223
</dependency>
214224
<dependency>
215225
<groupId>org.jgrapht</groupId>

sansa-inference-common/pom.xml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,19 @@
3131
<dependency>
3232
<groupId>org.apache.jena</groupId>
3333
<artifactId>jena-tdb</artifactId>
34-
<version>3.5.0</version>
3534
</dependency>
3635
<dependency>
3736
<groupId>org.apache.jena</groupId>
3837
<artifactId>jena-cmds</artifactId>
39-
<version>3.5.0</version>
4038
</dependency>
4139

4240
<!-- Graph API -->
4341
<dependency>
44-
<groupId>com.assembla.scala-incubator</groupId>
42+
<groupId>org.scala-graph</groupId>
4543
<artifactId>graph-core_${scala.binary.version}</artifactId>
4644
</dependency>
4745
<dependency>
48-
<groupId>com.assembla.scala-incubator</groupId>
46+
<groupId>org.scala-graph</groupId>
4947
<artifactId>graph-dot_${scala.binary.version}</artifactId>
5048
</dependency>
5149
<dependency>
@@ -69,7 +67,7 @@
6967
<artifactId>google-collections</artifactId>
7068
</exclusion>
7169
</exclusions>
72-
<scope>provided</scope>
70+
<scope>compile</scope>
7371
</dependency>
7472

7573
<!-- Guava -->
@@ -89,6 +87,11 @@
8987
<version>3.5.0</version>
9088
</dependency>
9189

90+
<!-- Scopt CLI API-->
91+
<dependency>
92+
<groupId>com.github.scopt</groupId>
93+
<artifactId>scopt_${scala.binary.version}</artifactId>
94+
</dependency>
9295

9396
<!-- Test -->
9497
<dependency>

sansa-inference-common/src/main/resources/log4j.properties

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Root logger option
2-
log4j.rootLogger=INFO, stdout
2+
log4j.rootLogger=DEBUG, stdout
33

44
# Direct log messages to a log file
55
log4j.appender.file=org.apache.log4j.RollingFileAppender
@@ -20,3 +20,5 @@ log4j.logger.akka.remote.Remoting=ERROR
2020

2121
log4j.logger.org.apache.hadoop=ERROR
2222
log4j.logger.org.apache.calcite=ERROR
23+
24+
log4j.logger.scalax.collection.connectivity.GraphComponents=OFF

sansa-inference-common/src/main/scala/net/sansa_stack/inference/rules/RuleDependencyGraphAnalyzer.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ object RuleDependencyGraphAnalyzer extends Logging{
137137
def main(args: Array[String]) {
138138
// we re-use the JENA API for parsing rules
139139
val filenames = List(
140-
// "rules/rdfs-simple.rules"
141-
"rules/owl_horst.rules"
140+
"rules/rdfs-simple.rules"
141+
// "rules/owl_horst.rules"
142142
// "rules/owl_rl.rules"
143143
)
144144

@@ -154,7 +154,7 @@ object RuleDependencyGraphAnalyzer extends Logging{
154154

155155
// print each rule as graph
156156
rules.foreach { r =>
157-
val g = RuleUtils.asGraph(r).export(new File(graphDir, r.getName + ".graphml").toString)
157+
RuleUtils.asGraph(r).export(new File(graphDir, r.getName + ".graphml").toString)
158158
}
159159

160160
// generate graph

sansa-inference-common/src/main/scala/net/sansa_stack/inference/rules/RuleDependencyGraphGenerator.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import java.util.stream.Collectors
55
import scala.collection
66
import scala.collection.JavaConverters._
77
import scala.language.{existentials, implicitConversions}
8+
89
import scalax.collection.GraphPredef._
910
import scalax.collection.GraphTraversal.Parameters
1011
import scalax.collection._
@@ -13,7 +14,6 @@ import scalax.collection.edge._
1314
import scalax.collection.mutable.DefaultGraphImpl
1415
import scalax.collection.GraphPredef._
1516
import scalax.collection.GraphEdge._
16-
1717
import org.apache.jena.graph.{Node, NodeFactory}
1818
import org.apache.jena.reasoner.TriplePattern
1919
import org.apache.jena.reasoner.rulesys.Rule
@@ -259,12 +259,12 @@ object RuleDependencyGraphGenerator extends Logging {
259259
pairsOfRules :+= (cycle.last, cycle(0))
260260

261261
// map to list of edges
262-
val edges: Buffer[graph.EdgeT] = pairsOfRules.map(e => {
262+
val edges: Buffer[graph.EdgeT] = pairsOfRules.flatMap(e => {
263263
val node1 = graph get e._1
264264
val node2 = graph get e._2
265265

266266
node1.outgoing.filter(_.target == node2)
267-
}).flatten
267+
})
268268
debug("Edges: " + edges.mkString(", "))
269269

270270
// map to edge labels, i.e. the predicates

sansa-inference-common/src/main/scala/net/sansa_stack/inference/rules/minimizer/RuleDependencyGraphMinimizer.scala

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package net.sansa_stack.inference.rules.minimizer
22
import scala.collection.mutable.{ArrayBuffer, Buffer}
3+
34
import scalax.collection.Graph
45
import scalax.collection.edge.LDiEdge
56
import scala.collection.JavaConverters._
6-
import scalax.collection.GraphTraversal.Parameters
7+
import scala.collection.mutable
78

9+
import scalax.collection.GraphTraversal.Parameters
810
import org.apache.jena.graph.{Node, NodeFactory}
911
import org.apache.jena.reasoner.TriplePattern
1012
import org.apache.jena.reasoner.rulesys.Rule
@@ -16,7 +18,6 @@ import net.sansa_stack.inference.rules.RuleDependencyGraphGenerator.{asString, d
1618
import net.sansa_stack.inference.utils.{GraphUtils, RuleUtils}
1719
import net.sansa_stack.inference.utils.graph.LabeledEdge
1820
import net.sansa_stack.inference.utils.RuleUtils._
19-
2021
import scalax.collection.GraphTraversal.Parameters
2122
import scalax.collection._
2223
import scalax.collection.edge.Implicits._
@@ -294,11 +295,13 @@ abstract class RuleDependencyGraphMinimizer extends MinimizationRuleExecutor {
294295
// debug(cycles.asScala.mkString(","))
295296

296297
// cycles that contain the current node
297-
val cyclesWithNode: Buffer[Buffer[Rule]] = allCycles.asScala.filter(cycle => cycle.contains(node.value)).map(cycle => cycle.asScala)
298+
val cyclesWithNode: mutable.Buffer[mutable.Buffer[Rule]] = allCycles.asScala
299+
.filter(cycle => cycle.contains(node.value))
300+
.map(cycle => cycle.asScala)
298301
debug("Cycles: " + cyclesWithNode.map(c => c.map(r => r.getName)).mkString(","))
299302

300303
// cycles that use the same property
301-
val cyclesWithNodeSameProp: Map[Node, scala.List[Buffer[graph.EdgeT]]] = cyclesWithNode.map(cycle => {
304+
val cyclesWithNodeSameProp: Map[Node, scala.List[mutable.Buffer[graph.EdgeT]]] = cyclesWithNode.map(cycle => {
302305

303306
debug("Cycle: " + cycle.map(r => r.getName).mkString(", "))
304307

@@ -307,12 +310,12 @@ abstract class RuleDependencyGraphMinimizer extends MinimizationRuleExecutor {
307310
pairsOfRules :+= (cycle.last, cycle(0))
308311

309312
// map to list of edges
310-
val edges: Buffer[graph.EdgeT] = pairsOfRules.map(e => {
313+
val edges: mutable.Buffer[graph.EdgeT] = pairsOfRules.flatMap(e => {
311314
val node1 = graph get e._1
312315
val node2 = graph get e._2
313316

314317
node1.outgoing.filter(_.target == node2)
315-
}).flatten
318+
})
316319
debug("Edges: " + edges.mkString(", "))
317320

318321
// map to edge labels, i.e. the predicates
@@ -325,9 +328,14 @@ abstract class RuleDependencyGraphMinimizer extends MinimizationRuleExecutor {
325328
if (samePred) Some(predicates(0), edges) else None
326329
}).filter(_.isDefined).map(_.get).groupBy(e => e._1).mapValues(e => e.map(x => x._2).toList)
327330

328-
var removedCycles: collection.mutable.Set[Buffer[graph.EdgeT]] = collection.mutable.Set()
331+
var removedCycles: collection.mutable.Set[mutable.Buffer[graph.EdgeT]] = collection.mutable.Set()
329332

330-
val tmp: Map[Node, Map[Int, List[Buffer[graph.EdgeT]]]] = cyclesWithNodeSameProp.mapValues(value => value.map(cycle => (cycle.size, cycle)).groupBy(_._1).mapValues(e => e.map(x => x._2).toList))
333+
val tmp: Map[Node, Map[Int, List[mutable.Buffer[graph.EdgeT]]]] =
334+
cyclesWithNodeSameProp
335+
.mapValues(value =>
336+
value.map(cycle => (cycle.size, cycle))
337+
.groupBy(_._1)
338+
.mapValues(e => e.map(x => x._2)))
331339

332340
tmp.foreach(predicate2Cycles => {
333341
debug("predicate: " + predicate2Cycles._1)

0 commit comments

Comments
 (0)