Commit 6e623fba authored by Christian Willms's avatar Christian Willms
Browse files

merge

parents 59188028 87e54250
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
<properties> <properties>
<maven.compiler.source>8</maven.compiler.source> <maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target> <maven.compiler.target>8</maven.compiler.target>
<junit.version>5.0.1</junit.version>
<encoding>UTF-8</encoding> <encoding>UTF-8</encoding>
</properties> </properties>
...@@ -45,6 +44,35 @@ ...@@ -45,6 +44,35 @@
</configuration> </configuration>
</plugin> </plugin>
<!-- THIS WORKED BUT IS NO LONGER NEEDED
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>types-library</id>
<goals><goal>jar</goal></goals>
<phase>package</phase>
<configuration>
<classifier>types-lib</classifier>
<includes>
<include>**/de/dfki/lt/hfc/types/*</include>
<include>**/de/dfki/lt/hfc/Namespace*</include>
<include>**/de/dfki/lt/hfc/WrongFormatException*</include>
</includes>
</configuration>
</execution>
<execution>
<id>everything</id>
<goals><goal>jar</goal></goals>
<phase>package</phase>
<configuration>
<includes>
<include>**/*</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>-->
<plugin> <plugin>
<artifactId>maven-assembly-plugin</artifactId> <artifactId>maven-assembly-plugin</artifactId>
...@@ -54,15 +82,6 @@ ...@@ -54,15 +82,6 @@
<descriptorRef>jar-with-dependencies</descriptorRef> <descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs> </descriptorRefs>
</configuration> </configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin> </plugin>
<plugin> <plugin>
...@@ -80,32 +99,6 @@ ...@@ -80,32 +99,6 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<reuseForks>false</reuseForks>
<forkCount>4</forkCount>
</configuration>
<dependencies>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>1.1.0-M1</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.1.0-M1</version>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>5.1.0-M1</version>
</dependency>
</dependencies>
</plugin>
</plugins> </plugins>
</build> </build>
...@@ -135,28 +128,23 @@ ...@@ -135,28 +128,23 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.sf.trove4j</groupId> <groupId>org.apache.commons</groupId>
<artifactId>trove4j</artifactId> <artifactId>commons-lang3</artifactId>
<version>3.0.3</version> <version>3.5</version>
</dependency> </dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency> <dependency>
<groupId>org.apache.commons</groupId> <groupId>net.sf.trove4j</groupId>
<artifactId>commons-lang3</artifactId> <artifactId>trove4j</artifactId>
<version>3.1</version> <version>3.0.3</version>
</dependency> </dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.1.0-M1</version>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
......
...@@ -363,7 +363,7 @@ public class BindingTable { ...@@ -363,7 +363,7 @@ public class BindingTable {
* on or not; in case it is turned off, calling this method does not have an * on or not; in case it is turned off, calling this method does not have an
* effect * effect
*/ */
public void expandBindingTable() { protected void expandBindingTable() {
// if already expanded, no need to call method again, esp., since SELECT // if already expanded, no need to call method again, esp., since SELECT
// statements without the DISTINCT keyword use java.util.Hashset objects to // statements without the DISTINCT keyword use java.util.Hashset objects to
// represent duplicate elements (int arrays); otherwise (w/ DISTINCT), a // represent duplicate elements (int arrays); otherwise (w/ DISTINCT), a
......
...@@ -2,9 +2,6 @@ package de.dfki.lt.hfc; ...@@ -2,9 +2,6 @@ package de.dfki.lt.hfc;
import java.util.*; import java.util.*;
import gnu.trove.set.hash.*; import gnu.trove.set.hash.*;
import org.apache.log4j.Level;
import org.apache.log4j.LogMF;
import org.apache.log4j.Logger;
/** /**
* a collection of static methods that deal with sets and binding tables, used by the * a collection of static methods that deal with sets and binding tables, used by the
...@@ -21,15 +18,6 @@ import org.apache.log4j.Logger; ...@@ -21,15 +18,6 @@ import org.apache.log4j.Logger;
*/ */
public final class Calc { public final class Calc {
/**
* A basic LOGGER.
*/
private final static Logger LOGGER = Logger.getLogger(Calc.class.getName());
static {
LOGGER.setLevel(Level.ERROR);
}
/** /**
* the default hashing and equals strategy for tuples from the output set of the current * the default hashing and equals strategy for tuples from the output set of the current
* iteration: take ALL positions of a tuple into account * iteration: take ALL positions of a tuple into account
...@@ -245,11 +233,10 @@ public final class Calc { ...@@ -245,11 +233,10 @@ public final class Calc {
public static BindingTable restrict(BindingTable bt, public static BindingTable restrict(BindingTable bt,
ArrayList<Integer> varvarIneqs, ArrayList<Integer> varvarIneqs,
ArrayList<Integer> varconstIneqs) { ArrayList<Integer> varconstIneqs) {
LogMF.trace(LOGGER, "restrict ineqs", null);
// check whether both ineq lists are empty in order to avoid iterator // check whether both ineq lists are empty in order to avoid iterator
if (varvarIneqs.isEmpty() && varconstIneqs.isEmpty()){ if (varvarIneqs.isEmpty() && varconstIneqs.isEmpty())
return bt;} return bt;
// instead of using the indexToVariable, we use their positions (faster!); // instead of using the vars, we use their positions (faster!);
// use int[] instead of ArrayList<Integer> // use int[] instead of ArrayList<Integer>
int[] vv = new int[varvarIneqs.size()]; int[] vv = new int[varvarIneqs.size()];
for (int i = 0; i < varvarIneqs.size(); i++) { for (int i = 0; i < varvarIneqs.size(); i++) {
...@@ -286,7 +273,6 @@ public final class Calc { ...@@ -286,7 +273,6 @@ public final class Calc {
} }
} // outerloop block } // outerloop block
} }
bt.size();
return bt; return bt;
} }
...@@ -295,10 +281,9 @@ public final class Calc { ...@@ -295,10 +281,9 @@ public final class Calc {
*/ */
public static BindingTable restrict(BindingTable bt, public static BindingTable restrict(BindingTable bt,
ArrayList<Predicate> predicates) { ArrayList<Predicate> predicates) {
LogMF.trace(LOGGER, "restrict predicates", null);
// no predicate: binding table does not change // no predicate: binding table does not change
if (predicates.isEmpty()){ if (predicates.isEmpty())
return bt;} return bt;
// fundamental distinction: functional-only vs. relational-only variables; // fundamental distinction: functional-only vs. relational-only variables;
// address the RELATIONAL case first: involved predicates will NOT undergo the double loop below // address the RELATIONAL case first: involved predicates will NOT undergo the double loop below
ArrayList<Predicate> allPredicates = new ArrayList<Predicate>(predicates); // do NOT modify predicates ArrayList<Predicate> allPredicates = new ArrayList<Predicate>(predicates); // do NOT modify predicates
......
...@@ -123,6 +123,7 @@ public class Configuration { ...@@ -123,6 +123,7 @@ public class Configuration {
st = new StringTokenizer(line, " =:\t"); st = new StringTokenizer(line, " =:\t");
processSpecification(st); processSpecification(st);
} }
br.close();
} }
catch (Exception e) { catch (Exception e) {
System.err.println("\nerror while reading configuration file " + configFile); System.err.println("\nerror while reading configuration file " + configFile);
......
...@@ -3,7 +3,6 @@ package de.dfki.lt.hfc; ...@@ -3,7 +3,6 @@ package de.dfki.lt.hfc;
import java.io.*; import java.io.*;
import java.util.*; import java.util.*;
import java.util.concurrent.*; import java.util.concurrent.*;
import de.dfki.lt.hfc.indices.IndexingException; import de.dfki.lt.hfc.indices.IndexingException;
import gnu.trove.set.hash.*; import gnu.trove.set.hash.*;
import gnu.trove.map.hash.*; import gnu.trove.map.hash.*;
...@@ -196,23 +195,6 @@ public final class ForwardChainer { ...@@ -196,23 +195,6 @@ public final class ForwardChainer {
this.noOfTasks = this.ruleStore.allRules.size(); this.noOfTasks = this.ruleStore.allRules.size();
} }
/**
* generates a new forward chainer with the default namespace for XSD, RDF, RDFS, and OWL
* @throws IOException
* @throws FileNotFoundException
* @throws WrongFormatException
*/
public ForwardChainer(boolean verbose, String tupleFile, String ruleFile)
throws FileNotFoundException, IOException, WrongFormatException {
this();
this.verbose = verbose;
Namespace namespace = new Namespace();
this.tupleStore = new TupleStore(verbose, this.noOfAtoms, this.noOfTuples, namespace, tupleFile);
this.ruleStore = new RuleStore(this.tupleStore, ruleFile);
this.threadPool = Executors.newFixedThreadPool(this.noOfCores);
this.noOfTasks = this.ruleStore.allRules.size();
}
/** /**
* this version allows to explicitly define the namespace * this version allows to explicitly define the namespace
* @throws IOException * @throws IOException
...@@ -229,40 +211,6 @@ public final class ForwardChainer { ...@@ -229,40 +211,6 @@ public final class ForwardChainer {
this.noOfTasks = this.ruleStore.allRules.size(); this.noOfTasks = this.ruleStore.allRules.size();
} }
/**
* this version allows to explicitly define the namespace
* @throws IOException
* @throws WrongFormatException
* @throws FileNotFoundException
*/
public ForwardChainer(boolean verbose, String tupleFile, String ruleFile, String namespaceFile)
throws FileNotFoundException, WrongFormatException, IOException {
this();
this.verbose = verbose;
Namespace namespace = new Namespace(namespaceFile);
this.tupleStore = new TupleStore(false, this.noOfAtoms, this.noOfTuples, namespace, tupleFile);
this.ruleStore = new RuleStore(this.tupleStore, ruleFile);
this.threadPool = Executors.newFixedThreadPool(this.noOfCores);
this.noOfTasks = this.ruleStore.allRules.size();
}
/**
* this version allows to explicitly define the namespace
* @throws IOException
* @throws WrongFormatException
* @throws FileNotFoundException
*/
public ForwardChainer(String tupleFile, String ruleFile, String namespaceFile, String indexFile)
throws FileNotFoundException, WrongFormatException, IOException, IndexingException {
this();
Namespace namespace = new Namespace(namespaceFile);
IndexStore indexStore = new IndexStore(indexFile, this.verbose);
this.tupleStore = new TupleStore(this.noOfAtoms, this.noOfTuples, namespace, tupleFile, indexStore);
this.ruleStore = new RuleStore(this.tupleStore, ruleFile);
this.threadPool = Executors.newFixedThreadPool(this.noOfCores);
this.noOfTasks = this.ruleStore.allRules.size();
}
/** /**
* generates a new forward chainer with the default namespace for XSD, RDF, RDFS, and OWL; * generates a new forward chainer with the default namespace for XSD, RDF, RDFS, and OWL;
* noOfAtoms and noOfTuples are important parameters that affects the performance of the * noOfAtoms and noOfTuples are important parameters that affects the performance of the
...@@ -284,28 +232,6 @@ public final class ForwardChainer { ...@@ -284,28 +232,6 @@ public final class ForwardChainer {
this.noOfTasks = this.ruleStore.allRules.size(); this.noOfTasks = this.ruleStore.allRules.size();
} }
/**
* generates a new forward chainer with the default namespace for XSD, RDF, RDFS, and OWL;
* noOfAtoms and noOfTuples are important parameters that affects the performance of the
* tuple store used by the forward chainer
* @throws IOException
* @throws FileNotFoundException
* @throws WrongFormatException
*/
public ForwardChainer(boolean verbose, int noOfAtoms, int noOfTuples, String tupleFile, String ruleFile)
throws FileNotFoundException, IOException, WrongFormatException {
this();
this.verbose = verbose;
this.noOfAtoms = noOfAtoms;
this.noOfTuples = noOfTuples;
//this.namespace = new Namespace();
this.tupleStore = new TupleStore(verbose, this.noOfAtoms, this.noOfTuples);
this.tupleStore.readTuples(tupleFile);
this.ruleStore = new RuleStore(this.tupleStore, ruleFile);
this.threadPool = Executors.newFixedThreadPool(this.noOfCores);
this.noOfTasks = this.ruleStore.allRules.size();
}
/** /**
* this version allows to explicitly define the namespace * this version allows to explicitly define the namespace
* @throws IOException * @throws IOException
...@@ -324,25 +250,6 @@ public final class ForwardChainer { ...@@ -324,25 +250,6 @@ public final class ForwardChainer {
this.noOfTasks = this.ruleStore.allRules.size(); this.noOfTasks = this.ruleStore.allRules.size();
} }
/**
* this version allows to explicitly define the namespace
* @throws IOException
* @throws WrongFormatException
* @throws FileNotFoundException
*/
public ForwardChainer(boolean verbose, int noOfAtoms, int noOfTuples, String tupleFile, String ruleFile, String namespaceFile)
throws FileNotFoundException, WrongFormatException, IOException {
this();
this.verbose = verbose;
this.noOfAtoms = noOfAtoms;
this.noOfTuples = noOfTuples;
Namespace namespace = new Namespace(namespaceFile);
this.tupleStore = new TupleStore(verbose, this.noOfAtoms, this.noOfTuples, namespace, tupleFile);
this.ruleStore = new RuleStore(this.tupleStore, ruleFile);
this.threadPool = Executors.newFixedThreadPool(this.noOfCores);
this.noOfTasks = this.ruleStore.allRules.size();
}
/** /**
* assumes a default of 100,000 atoms and 500,000 tuples * assumes a default of 100,000 atoms and 500,000 tuples
...@@ -355,18 +262,6 @@ public final class ForwardChainer { ...@@ -355,18 +262,6 @@ public final class ForwardChainer {
this.noOfTasks = this.ruleStore.allRules.size(); this.noOfTasks = this.ruleStore.allRules.size();
} }
/**
* assumes a default of 100,000 atoms and 500,000 tuples
*/
public ForwardChainer(boolean verbose, TupleStore tupleStore, RuleStore ruleStore) {
this();
this.verbose = verbose;
this.tupleStore = tupleStore;
this.ruleStore = ruleStore;
this.threadPool = Executors.newFixedThreadPool(this.noOfCores);
this.noOfTasks = this.ruleStore.allRules.size();
}
/** /**
* more options that will also affect namespace, tuple store, and rule store * more options that will also affect namespace, tuple store, and rule store
* @throws IOException * @throws IOException
...@@ -397,32 +292,6 @@ public final class ForwardChainer { ...@@ -397,32 +292,6 @@ public final class ForwardChainer {
this.noOfTasks = this.ruleStore.allRules.size(); this.noOfTasks = this.ruleStore.allRules.size();
} }
public ForwardChainer(int noOfCores,
boolean verbose,
boolean rdfCheck,
boolean eqReduction,
int minNoOfArgs,
int maxNoOfArgs,
int noOfAtoms,
int noOfTuples,
String tupleFile,
String ruleFile,
String namespaceFile,
String indexFile)
throws FileNotFoundException, WrongFormatException, IOException, IndexingException {
this(noOfCores, verbose);
this.noOfAtoms = noOfAtoms;
this.noOfTuples = noOfTuples;
Namespace namespace = new Namespace(namespaceFile, verbose);
IndexStore indexStore = new IndexStore(indexFile,this.verbose);
this.tupleStore = new TupleStore(verbose, rdfCheck, eqReduction, minNoOfArgs, maxNoOfArgs,
this.noOfAtoms, this.noOfTuples, namespace, tupleFile, indexStore);
this.ruleStore = new RuleStore(verbose, rdfCheck, minNoOfArgs, maxNoOfArgs,
this.tupleStore, ruleFile);
this.threadPool = Executors.newFixedThreadPool(this.noOfCores);
this.noOfTasks = this.ruleStore.allRules.size();
}
/** /**
* more options that will also affect namespace, tuple store, and rule store * more options that will also affect namespace, tuple store, and rule store
* @throws IOException * @throws IOException
...@@ -476,6 +345,49 @@ public final class ForwardChainer { ...@@ -476,6 +345,49 @@ public final class ForwardChainer {
this.noOfTasks = this.ruleStore.allRules.size(); this.noOfTasks = this.ruleStore.allRules.size();
} }
/**
* this version allows to explicitly define the namespace
* @throws IOException
* @throws WrongFormatException
* @throws FileNotFoundException
*/
public ForwardChainer(String tupleFile, String ruleFile, String namespaceFile, String indexFile)
throws FileNotFoundException, WrongFormatException, IOException, IndexingException {
this();
Namespace namespace = new Namespace(namespaceFile);
IndexStore indexStore = new IndexStore(indexFile, this.verbose);
this.tupleStore = new TupleStore(this.noOfAtoms, this.noOfTuples, namespace, tupleFile, indexStore);
this.ruleStore = new RuleStore(this.tupleStore, ruleFile);
this.threadPool = Executors.newFixedThreadPool(this.noOfCores);
this.noOfTasks = this.ruleStore.allRules.size();
}
public ForwardChainer(int noOfCores,
boolean verbose,
boolean rdfCheck,
boolean eqReduction,
int minNoOfArgs,
int maxNoOfArgs,
int noOfAtoms,
int noOfTuples,
String tupleFile,
String ruleFile,
String namespaceFile,
String indexFile)
throws FileNotFoundException, WrongFormatException, IOException, IndexingException {
this(noOfCores, verbose);
this.noOfAtoms = noOfAtoms;
this.noOfTuples = noOfTuples;
Namespace namespace = new Namespace(namespaceFile, verbose);
IndexStore indexStore = new IndexStore(indexFile,this.verbose);
this.tupleStore = new TupleStore(verbose, rdfCheck, eqReduction, minNoOfArgs, maxNoOfArgs,
this.noOfAtoms, this.noOfTuples, namespace, tupleFile, indexStore);
this.ruleStore = new RuleStore(verbose, rdfCheck, minNoOfArgs, maxNoOfArgs,
this.tupleStore, ruleFile);
this.threadPool = Executors.newFixedThreadPool(this.noOfCores);
this.noOfTasks = this.ruleStore.allRules.size();
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////
/** /**
...@@ -634,10 +546,6 @@ public final class ForwardChainer { ...@@ -634,10 +546,6 @@ public final class ForwardChainer {
* make sure that this equals obj by NOT distinguishing between first and second * make sure that this equals obj by NOT distinguishing between first and second
*/ */
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj == this)
return true;
if (!(obj instanceof Pair))
return false;
Pair pair = (Pair)obj; Pair pair = (Pair)obj;
if (this.first.equals(pair.first) && this.second.equals(pair.second)) if (this.first.equals(pair.first) && this.second.equals(pair.second))
return true; return true;
......
...@@ -56,22 +56,19 @@ public abstract class Operator { ...@@ -56,22 +56,19 @@ public abstract class Operator {
return id; return id;
} }
/**
/** * returns the id for a given literal (e.g., a string encoding a URI, blank node,
* returns the id for a given literal (e.g., a string encoding a URI, blank node, * XSD int, XSD string, etc.);
* XSD int, XSD string, etc.); * @return a positive int iff there exists a mapping in the tuple store between
* @return a positive int iff there exists a mapping in the tuple store between * the literal and this int
* the literal and this int * @return -1, otherwise
* @return -1, otherwise */
*/ public int getIdForPossiblyUnknownEntity(String literal) {
public int getIdForPossiblyUnknownEntity(String literal) { Integer id = this.tupleStore.objectToId.get(literal);
Integer id = this.tupleStore.objectToId.get(literal); synchronized (this.tupleStore) {
synchronized (this.tupleStore) { return id == null ? tupleStore.putObject(literal) : id;
return id == null ? tupleStore.putObject(literal) : id; }
} }
}
/** /**
* returns the proxy (the representative) for a given uri which serves as the internal * returns the proxy (the representative) for a given uri which serves as the internal
...@@ -149,6 +146,4 @@ public abstract class Operator { ...@@ -149,6 +146,4 @@ public abstract class Operator {
return this.tupleStore.allTuples; return this.tupleStore.allTuples;
} }
} }
...@@ -144,7 +144,7 @@ public final class OperatorRegistry { ...@@ -144,7 +144,7 @@ public final class OperatorRegistry {
* class name; if so, the operator is returned; * class name; if so, the operator is returned;
* if not, a new one is created, stored/registered, and returned * if not, a new one is created, stored/registered, and returned
*/ */
public Operator checkAndRegister(String className) { protected Operator checkAndRegister (String className) {
Operator op = this.nameToFo.get(className);