From: <lor...@us...> - 2012-02-06 14:15:23
|
Revision: 3570 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3570&view=rev Author: lorenz_b Date: 2012-02-06 14:15:12 +0000 (Mon, 06 Feb 2012) Log Message: ----------- Added CLI option to return only axioms which not already exist in KB. Modified Paths: -------------- trunk/interfaces/src/main/java/org/dllearner/cli/Enrichment.java trunk/interfaces/src/main/java/org/dllearner/cli/GlobalEnrichment.java Modified: trunk/interfaces/src/main/java/org/dllearner/cli/Enrichment.java =================================================================== --- trunk/interfaces/src/main/java/org/dllearner/cli/Enrichment.java 2012-02-06 13:48:50 UTC (rev 3569) +++ trunk/interfaces/src/main/java/org/dllearner/cli/Enrichment.java 2012-02-06 14:15:12 UTC (rev 3570) @@ -209,6 +209,7 @@ private int nrOfAxiomsToLearn = 10; private double threshold = 0.7; private int chunksize = 1000; + private boolean omitExistingAxioms; private boolean useInference; private SPARQLReasoner reasoner; @@ -232,7 +233,7 @@ private Set<OWLAxiom> learnedOWLAxioms; private Set<EvaluatedAxiom> learnedEvaluatedAxioms; - public Enrichment(SparqlEndpoint se, Entity resource, double threshold, int nrOfAxiomsToLearn, boolean useInference, boolean verbose, int chunksize, int maxExecutionTimeInSeconds) { + public Enrichment(SparqlEndpoint se, Entity resource, double threshold, int nrOfAxiomsToLearn, boolean useInference, boolean verbose, int chunksize, int maxExecutionTimeInSeconds, boolean omitExistingAxioms) { this.se = se; this.resource = resource; this.verbose = verbose; @@ -241,6 +242,7 @@ this.useInference = useInference; this.chunksize = chunksize; this.maxExecutionTimeInSeconds = maxExecutionTimeInSeconds; + this.omitExistingAxioms = omitExistingAxioms; try { cacheDir = "cache" + File.separator + URLEncoder.encode(se.getURL().toString(), "UTF-8"); @@ -426,6 +428,7 @@ ks2.setCacheDir(cacheDir); ks2.setRecursionDepth(2); ks2.setCloseAfterRecursion(true); + ks2.setDissolveBlankNodes(false); ks2.setSaveExtractedFragment(true); startTime = System.currentTimeMillis(); System.out.print("getting knowledge base fragment ... "); @@ -491,6 +494,7 @@ ConfigHelper.configure(learner, "maxExecutionTimeInSeconds", maxExecutionTimeInSeconds); ((AbstractAxiomLearningAlgorithm)learner).setLimit(chunksize); + ((AbstractAxiomLearningAlgorithm)learner).setReturnOnlyNewAxioms(omitExistingAxioms); learner.init(); if(reasoner != null){ ((AbstractAxiomLearningAlgorithm)learner).setReasoner(reasoner); @@ -809,6 +813,8 @@ "Specifies the chunk size for the query result as the approach is incrementally.").withRequiredArg().ofType(Integer.class).defaultsTo(1000); parser.acceptsAll(asList("maxExecutionTimeInSeconds"), "Specifies the max execution time for each algorithm run and each entity.").withRequiredArg().ofType(Integer.class).defaultsTo(10); + parser.acceptsAll(asList("omitExistingAxioms"), + "Specifies whether return only axioms which not already exist in the knowlegde base.").withOptionalArg().ofType(Boolean.class).defaultsTo(false); // parse options and display a message for the user in case of problems OptionSet options = null; @@ -896,7 +902,8 @@ } int chunksize = (Integer) options.valueOf("chunksize"); - int runtime = (Integer) options.valueOf("runtime"); + int maxExecutionTimeInSeconds = (Integer) options.valueOf("maxExecutionTimeInSeconds"); + boolean omitExistingAxioms = (Boolean) options.valueOf("omitExistingAxioms"); // TODO: some handling for inaccessible files or overwriting existing files File f = (File) options.valueOf("o"); @@ -907,7 +914,7 @@ System.setOut(printStream); } - Enrichment e = new Enrichment(se, resource, threshold, maxNrOfResults, useInference, false, chunksize, runtime); + Enrichment e = new Enrichment(se, resource, threshold, maxNrOfResults, useInference, false, chunksize, maxExecutionTimeInSeconds, omitExistingAxioms); e.start(); SparqlEndpointKS ks = new SparqlEndpointKS(se); Modified: trunk/interfaces/src/main/java/org/dllearner/cli/GlobalEnrichment.java =================================================================== --- trunk/interfaces/src/main/java/org/dllearner/cli/GlobalEnrichment.java 2012-02-06 13:48:50 UTC (rev 3569) +++ trunk/interfaces/src/main/java/org/dllearner/cli/GlobalEnrichment.java 2012-02-06 14:15:12 UTC (rev 3570) @@ -81,6 +81,7 @@ private static int queryChunkSize = 1000; private static int maxExecutionTimeInSeconds = 10; private static boolean useInference = true; + private static boolean omitExistingAxioms = false; // directory for generated schemata private static String baseDir = "log/lod-enriched/"; @@ -88,7 +89,7 @@ //parameters for thread pool //Parallel running Threads(Executor) on System - private static int corePoolSize = 5; + private static int corePoolSize = 1; //Maximum Threads allowed in Pool private static int maximumPoolSize = 20; //Keep alive time for waiting threads for jobs(Runnable) @@ -189,7 +190,8 @@ File log = new File(baseDir + File.separator + "failed" + File.separator + name + ".log"); System.out.println("Enriching " + name + " using " + se.getURL()); - Enrichment e = new Enrichment(se, null, threshold, nrOfAxiomsToLearn, useInference, false, queryChunkSize, maxExecutionTimeInSeconds); + Enrichment e = new Enrichment(se, null, threshold, nrOfAxiomsToLearn, useInference, + false, queryChunkSize, maxExecutionTimeInSeconds, omitExistingAxioms); e.maxEntitiesPerType = 3; // hack for faster testing of endpoints This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |