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

Commit 660f832

Browse files
Merge branch 'develop' into feature/dependency-updates
2 parents 88f88e8 + 3114ad8 commit 660f832

39 files changed

+285
-301
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@ project/plugins/project/
1717
.worksheet
1818
*.iml
1919
.idea
20+
21+
scalastyle-output.xml

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@
1717
- [Setup](#setup)
1818
- [Prerequisites](#prerequisites)
1919
- [From source](#from-source)
20-
- [Using Maven pre-build artifacts](#)
20+
- [Using Maven pre-build artifacts](#using-maven-pre-build-artifacts)
2121
- [Using SBT](#using-SBT)
2222
- [Usage](#usage)
2323
- [Example](#example)
24-
- [Supported Reasoning Profiles](#)
24+
- [Supported Reasoning Profiles](#supported-reasoning-profiles)
2525
- [RDFS](#rdfs)
2626
- [RDFS Simple](#rdfs-simple)
2727
- [OWL Horst](#owl-horst)
28+
- [How to Contribute](#how-to-contribute)
2829

2930

3031
## Structure
@@ -216,3 +217,7 @@ OWL Horst is a fragment of OWL and was proposed by Herman ter Horst [1] defining
216217

217218
[1] Herman J. ter Horst:
218219
*Completeness, decidability and complexity of entailment for RDF Schema and a semantic extension involving the OWL vocabulary.* J. Web Sem. 3(2-3): 79-115 (2005)
220+
221+
## How to Contribute
222+
We always welcome new contributors to the project! Please see [our contribution guide](http://sansa-stack.net/contributing-to-sansa/) for more details on how to get started contributing to SANSA.
223+

pom.xml

Lines changed: 42 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
<CodeCacheSize>512m</CodeCacheSize>
8383
<gpg.keyname>AKSW</gpg.keyname>
8484
<owlapi.version>5.1.5</owlapi.version>
85+
<scalastyle.config.path>${project.basedir}/scalastyle-config.xml</scalastyle.config.path>
8586
</properties>
8687

8788
<prerequisites>
@@ -554,30 +555,33 @@
554555
<groupId>com.versioneye</groupId>
555556
<artifactId>versioneye-maven-plugin</artifactId>
556557
</plugin>
557-
<!--<plugin>-->
558-
<!--<groupId>org.scalastyle</groupId>-->
559-
<!--<artifactId>scalastyle-maven-plugin</artifactId>-->
560-
<!--<version>0.8.0</version>-->
561-
<!--<configuration>-->
562-
<!--<verbose>false</verbose>-->
563-
<!--<failOnViolation>false</failOnViolation>-->
564-
<!--<includeTestSourceDirectory>false</includeTestSourceDirectory>-->
565-
<!--<failOnWarning>false</failOnWarning>-->
566-
<!--<sourceDirectory>${basedir}/src/main/scala</sourceDirectory>-->
567-
<!--<testSourceDirectory>${basedir}/src/test/scala</testSourceDirectory>-->
568-
<!--<configLocation>scalastyle-config.xml</configLocation>-->
569-
<!--<outputFile>${basedir}/target/scalastyle-output.xml</outputFile>-->
570-
<!--<inputEncoding>${project.build.sourceEncoding}</inputEncoding>-->
571-
<!--<outputEncoding>${project.reporting.outputEncoding}</outputEncoding>-->
572-
<!--</configuration>-->
573-
<!--<executions>-->
574-
<!--<execution>-->
575-
<!--<goals>-->
576-
<!--<goal>check</goal>-->
577-
<!--</goals>-->
578-
<!--</execution>-->
579-
<!--</executions>-->
580-
<!--</plugin>-->
558+
559+
<!-- Scalastyle -->
560+
<plugin>
561+
<groupId>org.scalastyle</groupId>
562+
<artifactId>scalastyle-maven-plugin</artifactId>
563+
<version>1.0.0</version>
564+
<configuration>
565+
<verbose>false</verbose>
566+
<failOnViolation>false</failOnViolation>
567+
<includeTestSourceDirectory>true</includeTestSourceDirectory>
568+
<failOnWarning>false</failOnWarning>
569+
<sourceDirectory>${project.basedir}/src/main/scala</sourceDirectory>
570+
<testSourceDirectory>${project.basedir}/src/test/scala</testSourceDirectory>
571+
<!-- we use a central config located in the root directory -->
572+
<configLocation>${scalastyle.config.path}</configLocation>
573+
<outputFile>${project.basedir}/scalastyle-output.xml</outputFile>
574+
<outputEncoding>UTF-8</outputEncoding>
575+
</configuration>
576+
<executions>
577+
<execution>
578+
<goals>
579+
<goal>check</goal>
580+
</goals>
581+
</execution>
582+
</executions>
583+
</plugin>
584+
581585
</plugins>
582586
</build>
583587

@@ -702,6 +706,7 @@
702706

703707
<!-- the profile used for deployment to Sonatype Maven repository -->
704708
<profile>
709+
<!-- for Maven Central deployment -->
705710
<id>ossrh</id>
706711
<distributionManagement>
707712
<repository>
@@ -820,5 +825,18 @@
820825
</plugins>
821826
</build>
822827
</profile>
828+
829+
<!-- for Scalastyle plugin -->
830+
<profile>
831+
<id>root-dir</id>
832+
<activation>
833+
<file>
834+
<exists>${project.basedir}/../../scalastyle-config.xml</exists>
835+
</file>
836+
</activation>
837+
<properties>
838+
<scalastyle.config.path>${project.basedir}/../scalastyle-config.xml</scalastyle.config.path>
839+
</properties>
840+
</profile>
823841
</profiles>
824842
</project>

sansa-inference-common/src/main/scala/net/sansa_stack/inference/data/JenaOps.scala

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package net.sansa_stack.inference.data
22

3+
import scala.collection.JavaConverters._
4+
35
import org.apache.jena.datatypes.{BaseDatatype, RDFDatatype, TypeMapper}
46
import org.apache.jena.graph.{Graph => JenaGraph, Node => JenaNode, Triple => JenaTriple, _}
5-
import org.apache.jena.rdf.model.{Literal => JenaLiteral, Seq => _}
6-
7-
import scala.collection.JavaConverters._
7+
import org.apache.jena.rdf.model.{Seq => _}
88

99
class JenaOps extends RDFOps[Jena] {
1010

@@ -33,10 +33,12 @@ class JenaOps extends RDFOps[Jena] {
3333
val s = t.getSubject
3434
val p = t.getPredicate
3535
val o = t.getObject
36-
if (p.isInstanceOf[Jena#URI])
37-
(s, p.asInstanceOf[Jena#URI], o)
38-
else
39-
throw new RuntimeException("fromTriple: predicate " + p.toString + " must be a URI")
36+
p match {
37+
case uri: Node_URI =>
38+
(s, uri, o)
39+
case _ =>
40+
throw new RuntimeException("fromTriple: predicate " + p.toString + " must be a URI")
41+
}
4042
}
4143

4244
// node
@@ -52,10 +54,11 @@ class JenaOps extends RDFOps[Jena] {
5254
def makeUri(iriStr: String): Jena#URI = { NodeFactory.createURI(iriStr).asInstanceOf[Node_URI] }
5355

5456
def fromUri(node: Jena#URI): String =
55-
if (node.isURI)
57+
if (node.isURI) {
5658
node.getURI
57-
else
59+
} else {
5860
throw new RuntimeException("fromUri: " + node.toString() + " must be a URI")
61+
}
5962

6063
// bnode
6164

@@ -67,17 +70,18 @@ class JenaOps extends RDFOps[Jena] {
6770
}
6871

6972
def fromBNode(bn: Jena#BNode): String =
70-
if (bn.isBlank)
73+
if (bn.isBlank) {
7174
bn.getBlankNodeId.getLabelString
72-
else
75+
} else {
7376
throw new RuntimeException("fromBNode: " + bn.toString + " must be a BNode")
77+
}
7478

7579
// literal
7680

7781
// TODO the javadoc doesn't say if this is thread safe
7882
lazy val mapper = TypeMapper.getInstance
7983

80-
def jenaDatatype(datatype: Jena#URI) = {
84+
private def jenaDatatype(datatype: Jena#URI) = {
8185
val iriString = fromUri(datatype)
8286
val typ = mapper.getTypeByName(iriString)
8387
if (typ == null) {
@@ -94,20 +98,21 @@ class JenaOps extends RDFOps[Jena] {
9498
val __rdfLangStringURI: Jena#URI = makeUri("http://www.w3.org/1999/02/22-rdf-syntax-ns#langString")
9599

96100
def makeLiteral(lexicalForm: String, datatype: Jena#URI): Jena#Literal =
97-
if (datatype == __xsdStringURI)
101+
if (datatype == __xsdStringURI) {
98102
NodeFactory.createLiteral(lexicalForm, null, null).asInstanceOf[Node_Literal]
99-
else
103+
} else {
100104
NodeFactory.createLiteral(lexicalForm, null, jenaDatatype(datatype)).asInstanceOf[Node_Literal]
105+
}
101106

102107
def makeLangTaggedLiteral(lexicalForm: String, lang: Jena#Lang): Jena#Literal =
103108
NodeFactory.createLiteral(lexicalForm, fromLang(lang), null).asInstanceOf[Node_Literal]
104109

105110

106111
// lang
107112

108-
def makeLang(langString: String) = langString
113+
def makeLang(langString: String): String = langString
109114

110-
def fromLang(lang: Jena#Lang) = lang
115+
def fromLang(lang: Jena#Lang): String = lang
111116

112117

113118

sansa-inference-common/src/main/scala/net/sansa_stack/inference/data/RDF.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ trait RDF {
3939
// types for the graph traversal API
4040
type NodeMatch
4141
type NodeAny <: NodeMatch
42-
}
42+
}

sansa-inference-common/src/main/scala/net/sansa_stack/inference/data/RDFTuple.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ package net.sansa_stack.inference.data
88
* @author Lorenz Buehmann
99
*/
1010
case class RDFTuple(s: String, o: String) extends Product2[String, String] {
11-
override def _1: String = s
12-
override def _2: String = o
13-
}
11+
override def _1: String = s
12+
13+
override def _2: String = o
14+
}

sansa-inference-common/src/main/scala/net/sansa_stack/inference/data/SimpleRDFOps.scala

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@ class SimpleRDFOps extends RDFOps[SimpleRDF] {
1717
val s = t.s
1818
val p = t.p
1919
val o = t.o
20-
if (p.isInstanceOf[SimpleRDF#URI])
21-
(s, p.asInstanceOf[SimpleRDF#URI], o)
22-
else
23-
throw new RuntimeException("fromTriple: predicate " + p.toString + " must be a URI")
20+
p match {
21+
case uri: String =>
22+
(s, uri, o)
23+
case _ =>
24+
throw new RuntimeException("fromTriple: predicate " + p.toString + " must be a URI")
25+
}
2426
}
2527

2628
// node

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ abstract class MinimizationRule extends Logging {
1818

1919
def apply(graph: RuleDependencyGraph): RuleDependencyGraph
2020

21-
}
21+
}

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

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,20 @@
11
package net.sansa_stack.inference.rules.plan
22

3-
import java.io.PrintWriter
4-
import java.util.Collections
3+
import scala.collection.JavaConverters._
4+
import scala.util.Try
55

6-
import com.google.common.collect.ImmutableList
76
import org.apache.calcite.config.Lex
7+
import org.apache.calcite.interpreter.{BindableConvention, Bindables}
88
import org.apache.calcite.plan.{RelOptUtil, _}
9+
import org.apache.calcite.rel.`type`.RelDataTypeSystem
10+
import org.apache.calcite.rel.rules._
911
import org.apache.calcite.rel.{RelCollationTraitDef, RelNode}
1012
import org.apache.calcite.schema.SchemaPlus
1113
import org.apache.calcite.sql.parser.SqlParser
1214
import org.apache.calcite.tools._
13-
import collection.JavaConverters._
14-
import scala.util.Try
15-
16-
import org.apache.calcite.rel.`type`.RelDataTypeSystem
17-
import org.apache.calcite.rel.externalize.RelWriterImpl
18-
import org.apache.calcite.rel.rules._
1915
import org.apache.jena.reasoner.rulesys.Rule
2016

2117
import net.sansa_stack.inference.utils.{Logging, RuleUtils}
22-
import org.apache.calcite.adapter.enumerable.{EnumerableConvention, EnumerableRules}
23-
import org.apache.calcite.interpreter.{BindableConvention, Bindables}
24-
import org.apache.calcite.plan.RelOptPlanner.CannotPlanException
25-
import org.apache.calcite.plan.hep.{HepMatchOrder, HepPlanner, HepProgramBuilder}
26-
import org.apache.calcite.plan.volcano.VolcanoPlanner
27-
import org.apache.calcite.sql2rel.{RelDecorrelator, SqlToRelConverter}
2818

2919
/**
3020
* @author Lorenz Buehmann
@@ -37,7 +27,7 @@ class SimplePlanGenerator(schema: SchemaPlus) extends Logging {
3727
BindableConvention.INSTANCE.getTraitDef
3828
)
3929

40-
val optRuleSet = RuleSets.ofList(
30+
val optRuleSet: RuleSet = RuleSets.ofList(
4131
FilterJoinRule.FILTER_ON_JOIN,// push a filter into a join
4232
FilterJoinRule.JOIN,// push filter into the children of a join
4333
ProjectJoinTransposeRule.INSTANCE// push a projection to the children of a join
@@ -68,13 +58,13 @@ class SimplePlanGenerator(schema: SchemaPlus) extends Logging {
6858
// // Context provides a way to store data within the planner session that can be accessed in planner rules.
6959
// .context(Contexts.EMPTY_CONTEXT)
7060
// // Rule sets to use in transformation phases. Each transformation phase can use a different set of rules.
71-
//// .ruleSets(optRuleSet)
61+
// // .ruleSets(optRuleSet)
7262
// .ruleSets(RuleSets.ofList(Bindables.BINDABLE_TABLE_SCAN_RULE, Bindables.BINDABLE_PROJECT_RULE, Bindables.BINDABLE_JOIN_RULE, Bindables.BINDABLE_FILTER_RULE, FilterJoinRule.FILTER_ON_JOIN))
7363
// .programs(Programs.ofRules(Bindables.BINDABLE_TABLE_SCAN_RULE, Bindables.BINDABLE_PROJECT_RULE, Bindables.BINDABLE_JOIN_RULE, Bindables.BINDABLE_FILTER_RULE, FilterJoinRule.FILTER_ON_JOIN))
7464
//
7565
// // Custom cost factory to use during optimization
7666
// .costFactory(null)
77-
//// .programs(program)
67+
// // .programs(program)
7868
// .typeSystem(RelDataTypeSystem.DEFAULT)
7969
// .build()
8070

sansa-inference-common/src/main/scala/net/sansa_stack/inference/utils/JenaTripleToNTripleString.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import org.apache.jena.graph.Triple
99
* @author Lorenz Buehmann
1010
*/
1111
class JenaTripleToNTripleString
12-
extends ((Triple) => String)
12+
extends Function[Triple, String]
1313
with java.io.Serializable {
1414
override def apply(t: Triple): String = {
1515
val subStr =
@@ -27,7 +27,7 @@ class JenaTripleToNTripleString
2727
} else {
2828
s"<${t.getObject}>"
2929
}
30-
s"${subStr} <${t.getPredicate}> ${objStr} ."
30+
s"$subStr <${t.getPredicate}> $objStr ."
3131
}
3232
}
3333

0 commit comments

Comments
 (0)