From: <jen...@us...> - 2009-07-06 13:02:01
|
Revision: 1813 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1813&view=rev Author: jenslehmann Date: 2009-07-06 13:01:57 +0000 (Mon, 06 Jul 2009) Log Message: ----------- - EL learning algorithm changes - SPARQL test modified Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/el/ELLearningAlgorithmDisjunctive.java trunk/src/dl-learner/org/dllearner/refinementoperators/Utility.java trunk/src/dl-learner/org/dllearner/tools/ore/SPARQLTest.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/el/ELLearningAlgorithmDisjunctive.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/el/ELLearningAlgorithmDisjunctive.java 2009-07-06 11:39:13 UTC (rev 1812) +++ trunk/src/dl-learner/org/dllearner/algorithms/el/ELLearningAlgorithmDisjunctive.java 2009-07-06 13:01:57 UTC (rev 1813) @@ -105,12 +105,12 @@ private TreeSet<ELDescriptionTree> trees; // tree search - private int treeSearchTimeSeconds = 10; + private double treeSearchTimeSeconds = 1.0; // private double noise = 0; private List<ELDescriptionTree> currentSolution = new LinkedList<ELDescriptionTree>(); private EvaluatedDescription bestEvaluatedDescription; // how important not to cover negatives - private double posWeight = 1.5; // 2; + private double posWeight = 1.2; // 2; private int startPosExamplesSize; // private int startNegExamplesSize; private SortedSet<Individual> currentPosExamples; Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/Utility.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/Utility.java 2009-07-06 11:39:13 UTC (rev 1812) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/Utility.java 2009-07-06 13:01:57 UTC (rev 1813) @@ -58,7 +58,8 @@ // specifies whether to do real disjoint tests or check that // two named classes do not have common instances - private boolean instanceBasedDisjoints = false; + // TODO: turn this into a parameter + private boolean instanceBasedDisjoints = true; // cache for reasoner queries private Map<Description,Map<Description,Boolean>> cachedDisjoints = new TreeMap<Description,Map<Description,Boolean>>(conceptComparator); Modified: trunk/src/dl-learner/org/dllearner/tools/ore/SPARQLTest.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/SPARQLTest.java 2009-07-06 11:39:13 UTC (rev 1812) +++ trunk/src/dl-learner/org/dllearner/tools/ore/SPARQLTest.java 2009-07-06 13:01:57 UTC (rev 1813) @@ -19,6 +19,8 @@ */ package org.dllearner.tools.ore; +import java.net.MalformedURLException; +import java.net.URL; import java.util.SortedSet; import java.util.TreeSet; @@ -31,55 +33,57 @@ import org.dllearner.kb.sparql.SPARQLTasks; import org.dllearner.kb.sparql.SparqlEndpoint; import org.dllearner.kb.sparql.SparqlKnowledgeSource; -import org.dllearner.learningproblems.PosOnlyLP; +import org.dllearner.learningproblems.ClassLearningProblem; import org.dllearner.reasoning.OWLAPIReasoner; import org.dllearner.utilities.examples.AutomaticNegativeExampleFinderSPARQL; import org.dllearner.utilities.examples.AutomaticPositiveExampleFinderSPARQL; /** * Test class for SPARQL mode. + * * @author Lorenz Buehmann - * + * */ -public class SPARQLTest{ - +public class SPARQLTest { + @SuppressWarnings("unused") - public static void main(String[] args){ - String example = "Angela_Merkel"; + public static void main(String[] args) throws MalformedURLException { + String exampleClass = "\"http://dbpedia.org/class/yago/LeadersOfPoliticalParties\""; ComponentManager cm = ComponentManager.getInstance(); - + SparqlEndpoint endPoint = SparqlEndpoint.getEndpointDBpedia(); - + SPARQLTasks task = new SPARQLTasks(endPoint); - + AutomaticPositiveExampleFinderSPARQL pos = new AutomaticPositiveExampleFinderSPARQL(task); - pos.makePositiveExamplesFromConcept(example); + pos.makePositiveExamplesFromConcept(exampleClass); SortedSet<String> posExamples = pos.getPosExamples(); - - AutomaticNegativeExampleFinderSPARQL neg = new AutomaticNegativeExampleFinderSPARQL(posExamples, task, new TreeSet<String>()); + System.out.println(posExamples); + + AutomaticNegativeExampleFinderSPARQL neg = new AutomaticNegativeExampleFinderSPARQL( + posExamples, task, new TreeSet<String>()); SortedSet<String> negExamples = neg.getNegativeExamples(20); System.out.println(negExamples); - - - - + + SortedSet<String> instances = new TreeSet<String>(posExamples); + instances.addAll(negExamples); + try { - - - - + SparqlKnowledgeSource ks = cm.knowledgeSource(SparqlKnowledgeSource.class); cm.applyConfigEntry(ks, "predefinedEndpoint", "DBPEDIA"); - ks.getConfigurator().setInstances(posExamples); + ks.getConfigurator().setInstances(instances); + ks.getConfigurator().setPredefinedFilter("YAGO"); ks.init(); ReasonerComponent reasoner = cm.reasoner(OWLAPIReasoner.class, ks); reasoner.init(); - PosOnlyLP lp = cm.learningProblem(PosOnlyLP.class, reasoner); - lp.getConfigurator().setPositiveExamples(posExamples); + ClassLearningProblem lp = cm.learningProblem(ClassLearningProblem.class, reasoner); +// lp.getConfigurator().setPositiveExamples(posExamples); + lp.getConfigurator().setClassToDescribe(new URL(exampleClass)); lp.init(); LearningAlgorithm la = cm.learningAlgorithm(CELOE.class, lp, reasoner); la.init(); - + la.start(); } catch (ComponentInitException e) { // TODO Auto-generated catch block This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |