From: <jen...@us...> - 2011-08-23 06:43:19
|
Revision: 3096 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3096&view=rev Author: jenslehmann Date: 2011-08-23 06:43:13 +0000 (Tue, 23 Aug 2011) Log Message: ----------- added support for specifying a confidence threshold in enrichment script Modified Paths: -------------- trunk/components-core/src/main/java/org/dllearner/core/AxiomLearningAlgorithm.java trunk/interfaces/src/main/java/org/dllearner/cli/Enrichment.java Modified: trunk/components-core/src/main/java/org/dllearner/core/AxiomLearningAlgorithm.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/AxiomLearningAlgorithm.java 2011-08-23 03:24:09 UTC (rev 3095) +++ trunk/components-core/src/main/java/org/dllearner/core/AxiomLearningAlgorithm.java 2011-08-23 06:43:13 UTC (rev 3096) @@ -49,6 +49,7 @@ */ public List<EvaluatedAxiom> getCurrentlyBestEvaluatedAxioms(int nrOfAxioms); - + public List<EvaluatedAxiom> getCurrentlyBestEvaluatedAxioms(int nrOfAxioms, + double accuracyThreshold); } Modified: trunk/interfaces/src/main/java/org/dllearner/cli/Enrichment.java =================================================================== --- trunk/interfaces/src/main/java/org/dllearner/cli/Enrichment.java 2011-08-23 03:24:09 UTC (rev 3095) +++ trunk/interfaces/src/main/java/org/dllearner/cli/Enrichment.java 2011-08-23 06:43:13 UTC (rev 3096) @@ -184,6 +184,7 @@ // number of axioms which will be learned/considered (only applies to // some learners) private int nrOfAxiomsToLearn = 10; + private double threshold = 0.7; // lists of algorithms to apply private List<Class<? extends AxiomLearningAlgorithm>> objectPropertyAlgorithms; @@ -195,10 +196,11 @@ private CommonPrefixMap prefixes = new CommonPrefixMap(); - public Enrichment(SparqlEndpoint se, Entity resource, boolean verbose) { + public Enrichment(SparqlEndpoint se, Entity resource, double threshold, boolean verbose) { this.se = se; this.resource = resource; this.verbose = verbose; + this.threshold = threshold; objectPropertyAlgorithms = new LinkedList<Class<? extends AxiomLearningAlgorithm>>(); objectPropertyAlgorithms.add(DisjointObjectPropertyAxiomLearner.class); @@ -374,7 +376,7 @@ System.out.println("done"); // convert the result to axioms (to make it compatible with the other algorithms) - TreeSet<? extends EvaluatedDescription> learnedDescriptions = la.getCurrentlyBestEvaluatedDescriptions(); + List<? extends EvaluatedDescription> learnedDescriptions = la.getCurrentlyBestEvaluatedDescriptions(threshold); List<EvaluatedAxiom> evaluatedAxioms = new LinkedList<EvaluatedAxiom>(); for(EvaluatedDescription learnedDescription : learnedDescriptions) { Axiom axiom; @@ -422,7 +424,7 @@ long runtime = System.currentTimeMillis() - startTime; System.out.println("done in " + runtime + "ms"); List<EvaluatedAxiom> learnedAxioms = learner - .getCurrentlyBestEvaluatedAxioms(nrOfAxiomsToLearn); + .getCurrentlyBestEvaluatedAxioms(nrOfAxiomsToLearn, threshold); System.out.println(prettyPrint(learnedAxioms)); algorithmRuns.add(new AlgorithmRun(learner.getClass(), learnedAxioms, ConfigHelper.getConfigOptionValuesString(learner))); @@ -656,6 +658,9 @@ parser.acceptsAll(asList("f", "format"), "Format of the generated output (plain, html, rdf/xml, turtle, manchester, sparul).").withOptionalArg() .ofType(String.class).defaultsTo("plain"); + parser.acceptsAll(asList("t", "threshold"), + "Confidence threshold for suggestions. Set it to a value between 0 and 1.").withOptionalArg() + .ofType(Double.class).defaultsTo(0.7); // parse options and display a message for the user in case of problems OptionSet options = null; @@ -701,8 +706,9 @@ } boolean verbose = (Boolean) options.valueOf("v"); + double threshold = (Double) options.valueOf("t"); - Enrichment e = new Enrichment(se, resource, verbose); + Enrichment e = new Enrichment(se, resource, threshold, verbose); e.start(); SparqlEndpointKS ks = new SparqlEndpointKS(se); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |