From: <lor...@us...> - 2011-11-15 20:14:46
|
Revision: 3405 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3405&view=rev Author: lorenz_b Date: 2011-11-15 20:14:39 +0000 (Tue, 15 Nov 2011) Log Message: ----------- Added workaround for CELOE for the case that the class is empty, e.g. also not found by the reasoner which will cause a ComponentInitException. Modified Paths: -------------- trunk/interfaces/src/main/java/org/dllearner/cli/Enrichment.java Modified: trunk/interfaces/src/main/java/org/dllearner/cli/Enrichment.java =================================================================== --- trunk/interfaces/src/main/java/org/dllearner/cli/Enrichment.java 2011-11-15 14:36:34 UTC (rev 3404) +++ trunk/interfaces/src/main/java/org/dllearner/cli/Enrichment.java 2011-11-15 20:14:39 UTC (rev 3405) @@ -39,6 +39,7 @@ import java.security.SecureRandom; import java.text.DecimalFormat; import java.util.ArrayList; +import java.util.Collections; import java.util.HashSet; import java.util.LinkedList; import java.util.List; @@ -283,7 +284,11 @@ Set<NamedClass> classes = st.getAllClasses(); int entities = 0; for(NamedClass nc : classes) { - runClassLearningAlgorithms(ks, nc); + try { + runClassLearningAlgorithms(ks, nc); + } catch (Exception e) { + e.printStackTrace(); + } entities++; if(maxEntitiesPerType != -1 && entities > maxEntitiesPerType) { break; @@ -355,6 +360,10 @@ // get instances of class as positive examples SPARQLReasoner sr = new SPARQLReasoner(ks); SortedSet<Individual> posExamples = sr.getIndividuals(nc, 20); + if(posExamples.isEmpty()){ + System.out.println("Skipping CELOE because class " + nc.toString() + " is empty."); + return Collections.emptyList(); + } SortedSet<String> posExStr = Helper.getStringSet(posExamples); // use own implementation of negative example finder This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |