Skip to content

Commit 0433605

Browse files
committed
make tmp dir os dependent
1 parent 92296e7 commit 0433605

20 files changed

Lines changed: 52 additions & 38 deletions

File tree

components-core/src/main/java/org/dllearner/algorithms/CELOEWrapper.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919
package org.dllearner.algorithms;
2020

21+
import com.google.common.base.StandardSystemProperty;
2122
import com.google.common.collect.Sets;
2223
import org.apache.jena.query.ParameterizedSparqlString;
2324
import org.apache.jena.query.QueryExecution;
@@ -41,6 +42,7 @@
4142
import org.semanticweb.owlapi.model.*;
4243
import uk.ac.manchester.cs.owl.owlapi.OWLClassImpl;
4344

45+
import java.io.File;
4446
import java.io.FileNotFoundException;
4547
import java.io.FileOutputStream;
4648
import java.util.Set;
@@ -113,7 +115,7 @@ protected void learnAxioms() {
113115

114116
OWLOntology fragment = buildFragment(posExamples, negExamples);
115117
try {
116-
fragment.getOWLOntologyManager().saveOntology(fragment, new RDFXMLDocumentFormat(), new FileOutputStream("/tmp/ont.owl"));
118+
fragment.getOWLOntologyManager().saveOntology(fragment, new RDFXMLDocumentFormat(), new FileOutputStream(System.getProperty("java.io.tmpdir") + File.separator + "ont.owl"));
117119
} catch (OWLOntologyStorageException | FileNotFoundException e1) {
118120
// TODO Auto-generated catch block
119121
e1.printStackTrace();

components-core/src/main/java/org/dllearner/algorithms/qtl/operations/lgg/LGGGeneratorRDFS.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919
package org.dllearner.algorithms.qtl.operations.lgg;
2020

21+
import com.google.common.base.StandardSystemProperty;
2122
import com.google.common.collect.Lists;
2223
import com.google.common.collect.Sets;
2324
import org.aksw.jena_sparql_api.cache.h2.CacheUtilsH2;
@@ -49,6 +50,7 @@
4950
import org.dllearner.utilities.NonStandardReasoningServices;
5051
import org.semanticweb.owlapi.model.EntityType;
5152

53+
import java.io.File;
5254
import java.util.*;
5355
import java.util.concurrent.TimeUnit;
5456
import java.util.function.Predicate;
@@ -214,7 +216,7 @@ public static void main(String[] args) throws Exception {
214216
endpoint = SparqlEndpoint.create("http://sake.informatik.uni-leipzig.de:8890/sparql", "http://dbpedia.org");
215217
QueryExecutionFactory qef = FluentQueryExecutionFactory
216218
.http(endpoint.getURL().toString(), endpoint.getDefaultGraphURIs()).config()
217-
.withCache(CacheUtilsH2.createCacheFrontend("/tmp/cache", false, TimeUnit.DAYS.toMillis(60)))
219+
.withCache(CacheUtilsH2.createCacheFrontend(System.getProperty("java.io.tmpdir") + File.separator + "cache", false, TimeUnit.DAYS.toMillis(60)))
218220
.withPagination(10000).withDelay(50, TimeUnit.MILLISECONDS).end().create();
219221

220222
// tree generation

components-core/src/main/java/org/dllearner/algorithms/qtl/operations/tuples/QTLTuples.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import java.util.stream.Collectors;
99
import java.util.stream.Stream;
1010

11+
import com.google.common.base.StandardSystemProperty;
1112
import com.google.common.collect.Lists;
1213
import com.google.common.collect.Maps;
1314
import com.google.common.collect.Sets;
@@ -308,7 +309,7 @@ private Map<String, Map.Entry<RDFResourceTree, List<Node>>> connect(List<Node> t
308309
});
309310
});
310311
log.debug("connected tree\n{}", tree::getStringRepresentation);
311-
QueryTreeUtils.asGraph(tree, baseIRI, pm, new File("/tmp/tree-" + FmtUtils.stringForNode(node, pm) + ".graphml"));
312+
QueryTreeUtils.asGraph(tree, baseIRI, pm, new File(System.getProperty("java.io.tmpdir") + File.separator + "tree-" + FmtUtils.stringForNode(node, pm) + ".graphml"));
312313
result.put(key, Maps.immutableEntry(tree, new ArrayList<>(nodes2Project)));
313314
};
314315

@@ -729,7 +730,7 @@ public static void main(String[] args) throws Exception {
729730

730731
Graph<Vertex, Edge> g = QueryTreeUtils.toGraph(tree, baseIRI, pm);
731732

732-
QueryTreeUtils.asGraph(tree, baseIRI, pm, new File("/tmp/lgg.graphml"));
733+
QueryTreeUtils.asGraph(tree, baseIRI, pm, new File(System.getProperty("java.io.tmpdir") + File.separator + "lgg.graphml"));
733734

734735
});
735736

components-core/src/main/java/org/dllearner/kb/repository/bioportal/BioPortalRepository.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
package org.dllearner.kb.repository.bioportal;
2020

2121
import com.google.common.base.Charsets;
22+
import com.google.common.base.StandardSystemProperty;
2223
import joptsimple.OptionParser;
2324
import joptsimple.OptionSet;
2425
import joptsimple.OptionSpec;
@@ -186,7 +187,7 @@ public static void main(String[] args) throws Exception{
186187
// create Options object
187188
OptionParser parser = new OptionParser();
188189
OptionSpec<File> baseDir =
189-
parser.accepts( "basedir" ).withRequiredArg().ofType( File.class ).defaultsTo(new File("/tmp/bioportal/"));
190+
parser.accepts( "basedir" ).withRequiredArg().ofType( File.class ).defaultsTo(new File(System.getProperty("java.io.tmpdir") + File.separator + "bioportal" + File.separator));
190191
OptionSpec<Void> downloadOption =
191192
parser.accepts( "download" );
192193
OptionSpec<Void> parseOption =

components-core/src/main/java/org/dllearner/reasoning/OWLAPIReasoner.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import com.clarkparsia.owlapi.explanation.PelletExplanation;
2222
import com.clarkparsia.owlapiv3.XSD;
2323
import com.clarkparsia.pellet.owlapiv3.PelletReasonerFactory;
24+
import com.google.common.base.StandardSystemProperty;
2425
import org.apache.log4j.Level;
2526
import org.apache.log4j.Logger;
2627
import org.dllearner.core.*;
@@ -1258,7 +1259,7 @@ public void setSynchronized() {
12581259
}
12591260

12601261
public static void main(String[] args) throws Exception{
1261-
OWLOntology o = OWLManager.createOWLOntologyManager().loadOntologyFromOntologyDocument(new File("/tmp/test2.rdf"));
1262+
OWLOntology o = OWLManager.createOWLOntologyManager().loadOntologyFromOntologyDocument(new File(System.getProperty("java.io.tmpdir") + File.separator + "test2.rdf"));
12621263
System.out.println(o.getClassesInSignature());
12631264
System.out.println(o.getDataPropertiesInSignature());
12641265
System.out.println(o.getIndividualsInSignature().size());

components-core/src/main/java/org/dllearner/reasoning/StructuralReasonerExtended.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919
package org.dllearner.reasoning;
2020

21+
import com.google.common.base.StandardSystemProperty;
2122
import org.dllearner.kb.OWLAPIOntology;
2223
import org.dllearner.kb.OWLOntologyKnowledgeSource;
2324
import org.joda.time.Period;
@@ -33,6 +34,7 @@
3334
import org.semanticweb.owlapi.util.Version;
3435

3536
import javax.annotation.Nonnull;
37+
import java.io.File;
3638
import java.util.*;
3739
import java.util.stream.Stream;
3840

@@ -1446,7 +1448,7 @@ public Collection<OWLDataProperty> getChildren(OWLDataProperty parent) {
14461448
public static void main(String[] args) throws Exception {
14471449
OWLOntologyManager man = OWLManager.createOWLOntologyManager();
14481450
OWLOntology schema = //man.loadOntology(IRI.create("http://downloads.dbpedia.org/2016-10/dbpedia_2016-10.nt"));
1449-
man.loadOntology(IRI.create("file:///tmp/merged.ttl"));
1451+
man.loadOntology(IRI.create("file://" + System.getProperty("java.io.tmpdir") + "/merged.ttl"));
14501452

14511453
OWLOntologyKnowledgeSource sampleKS = new OWLAPIOntology(schema);
14521454
sampleKS.init();

components-core/src/test/java/org/dllearner/algorithms/qtl/QTLTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
package org.dllearner.algorithms.qtl;
2020

2121
import com.google.common.base.Splitter;
22+
import com.google.common.base.StandardSystemProperty;
2223
import com.google.common.collect.Sets;
2324
import com.jamonapi.Monitor;
2425
import com.jamonapi.MonitorFactory;
@@ -218,7 +219,7 @@ public static void main(String[] args) throws Exception {
218219
System.out.println(filter.apply(bestSolution).getStringRepresentation());
219220
System.out.println(QueryTreeUtils.toSPARQLQueryString(filter.apply(bestSolution)));
220221

221-
QueryTreeUtils.asGraph(bestSolution, null, PrefixCCPrefixMapping.Full, new File("/tmp/tree.graphml"));
222+
QueryTreeUtils.asGraph(bestSolution, null, PrefixCCPrefixMapping.Full, new File(System.getProperty("java.io.tmpdir") + File.separator + "tree.graphml"));
222223
}
223224

224225
private static RDFResourceTree getQueryTree(String resource, CBDStructureTree cbdStructure,

components-core/src/test/java/org/dllearner/algorithms/qtl/experiments/LSQBenchmarkQueries.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.dllearner.algorithms.qtl.experiments;
22

3+
import com.google.common.base.StandardSystemProperty;
34
import com.google.common.collect.Lists;
45
import com.google.common.collect.Sets;
56
import com.google.common.io.FileWriteMode;
@@ -61,7 +62,7 @@ public static void main(String[] args) throws Exception{
6162
SparqlEndpoint endpoint = SparqlEndpoint.getEndpointDBpedia();
6263
endpoint = SparqlEndpoint.create("http://localhost:7200/repositories/dbpedia?infer=false", Collections.emptyList());
6364
SparqlEndpointKS ks = new SparqlEndpointKS(endpoint);
64-
ks.setCacheDir("/tmp/qtl/sparql-cache");
65+
ks.setCacheDir(System.getProperty("java.io.tmpdir") + File.separator + "qtl" + File.separator + "sparql-cache");
6566
ks.init();
6667

6768
QueryExecutionFactory qef = ks.getQueryExecutionFactory();
@@ -122,7 +123,7 @@ public boolean isMeaningless(Node predicate) {
122123

123124
List<Query> queries = getQueries();
124125

125-
File out = new File("/tmp/qtl.out");
126+
File out = new File(System.getProperty("java.io.tmpdir") + File.separator + "qtl.out");
126127

127128
queries.forEach(query -> {
128129
try {

components-core/src/test/java/org/dllearner/algorithms/qtl/experiments/PRConvergenceExperiment.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@
1818
*/
1919
package org.dllearner.algorithms.qtl.experiments;
2020

21-
import com.google.common.base.Charsets;
22-
import com.google.common.base.Function;
23-
import com.google.common.base.Joiner;
24-
import com.google.common.base.Splitter;
21+
import com.google.common.base.*;
2522
import com.google.common.collect.*;
2623
import com.google.common.hash.HashFunction;
2724
import com.google.common.hash.Hashing;
@@ -719,7 +716,7 @@ public void run(int maxNrOfProcessedQueries, int maxTreeDepth, int[] exampleInte
719716

720717
for (RDFResourceTree negTree : examples.negExamplesMapping.values()) {
721718
if (QueryTreeUtils.isSubsumedBy(negTree, bestMatchingTree.getTree())) {
722-
Files.append(sparqlQuery + "\n", new File("/tmp/negCovered.txt"), Charsets.UTF_8);
719+
Files.append(sparqlQuery + "\n", new File(System.getProperty("java.io.tmpdir") + File.separator + "negCovered.txt"), Charsets.UTF_8);
723720
break;
724721
}
725722
}
@@ -1362,7 +1359,7 @@ private Score computeScore(String referenceSparqlQuery, RDFResourceTree tree, do
13621359

13631360
// get the learned resources
13641361
List<String> learnedResources = splitComplexQueries ? getResultSplitted(learnedSPARQLQuery) : getResult(learnedSPARQLQuery);
1365-
Files.write(Joiner.on("\n").join(learnedResources), new File("/tmp/result.txt"), Charsets.UTF_8);
1362+
Files.write(Joiner.on("\n").join(learnedResources), new File(System.getProperty("java.io.tmpdir") + File.separator + "result.txt"), Charsets.UTF_8);
13661363
if (learnedResources.isEmpty()) {
13671364
logger.error("Learned SPARQL query returns no result.\n{}", learnedSPARQLQuery);
13681365
return new Score();

components-core/src/test/java/org/dllearner/algorithms/qtl/experiments/QTLEvaluation.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import com.google.common.base.Charsets;
2222
import com.google.common.base.Function;
2323
import com.google.common.base.Joiner;
24+
import com.google.common.base.StandardSystemProperty;
2425
import com.google.common.collect.*;
2526
import com.google.common.hash.HashFunction;
2627
import com.google.common.hash.Hashing;
@@ -695,7 +696,7 @@ public void run(int maxNrOfProcessedQueries, int maxTreeDepth, int[] exampleInte
695696

696697
for ( RDFResourceTree negTree : examples.negExamplesMapping.values()) {
697698
if(QueryTreeUtils.isSubsumedBy(negTree, bestMatchingTree.getTree())) {
698-
Files.append(sparqlQuery + "\n", new File("/tmp/negCovered.txt"), Charsets.UTF_8);
699+
Files.append(sparqlQuery + "\n", new File(System.getProperty("java.io.tmpdir") + File.separator + "negCovered.txt"), Charsets.UTF_8);
699700
break;
700701
}
701702
}
@@ -1695,7 +1696,7 @@ private Score computeScore(String referenceSparqlQuery, RDFResourceTree tree, do
16951696

16961697
// get the learned resources
16971698
List<String> learnedResources = splitComplexQueries ? getResultSplitted(learnedSPARQLQuery) : getResult(learnedSPARQLQuery);
1698-
Files.write(Joiner.on("\n").join(learnedResources), new File("/tmp/result.txt"), Charsets.UTF_8);
1699+
Files.write(Joiner.on("\n").join(learnedResources), new File(System.getProperty("java.io.tmpdir") + File.separator + "result.txt"), Charsets.UTF_8);
16991700
if (learnedResources.isEmpty()) {
17001701
logger.error("Learned SPARQL query returns no result.\n{}", learnedSPARQLQuery);
17011702
return new Score();

0 commit comments

Comments
 (0)