From: <jen...@us...> - 2007-10-08 15:04:17
|
Revision: 192 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=192&view=rev Author: jenslehmann Date: 2007-10-08 08:04:12 -0700 (Mon, 08 Oct 2007) Log Message: ----------- integrated accuracy and error penalty in strict definition learning problem Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/Config.java trunk/src/dl-learner/org/dllearner/ConfigurationManager.java trunk/src/dl-learner/org/dllearner/algorithms/gp/GPUtilities.java trunk/src/dl-learner/org/dllearner/core/DoubleConfigOption.java trunk/src/dl-learner/org/dllearner/core/IntegerConfigOption.java trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLPStrict.java trunk/src/dl-learner/org/dllearner/learningproblems/ScoreThreeValued.java Modified: trunk/src/dl-learner/org/dllearner/Config.java =================================================================== --- trunk/src/dl-learner/org/dllearner/Config.java 2007-10-08 14:39:16 UTC (rev 191) +++ trunk/src/dl-learner/org/dllearner/Config.java 2007-10-08 15:04:12 UTC (rev 192) @@ -19,15 +19,15 @@ // standardmäßig wird bis Tiefe 7 gesucht // public static int maxLength = 7; - public static int maxDepth; + // public static int maxDepth; // Punktabzug für "ungenaue" Klassifizierungen, also positiv als neutral, // neutral als negativ und negativ als neutral - public static double accuracyPenalty = 1; + // public static double accuracyPenalty = 1; // Punktabzug für fehlerhafte Klassifizierungen, also positiv als negativ // und negativ als positiv - public static double errorPenalty = 3; + // public static double errorPenalty = 3; public static ScoreMethod scoreMethod = ScoreMethod.POSITIVE; Modified: trunk/src/dl-learner/org/dllearner/ConfigurationManager.java =================================================================== --- trunk/src/dl-learner/org/dllearner/ConfigurationManager.java 2007-10-08 14:39:16 UTC (rev 191) +++ trunk/src/dl-learner/org/dllearner/ConfigurationManager.java 2007-10-08 15:04:12 UTC (rev 192) @@ -403,9 +403,9 @@ private void applyDoubleOptions(String option, double value) { // System.out.println(option + " " + value); if (option.equals("accuracyPenalty")) - Config.accuracyPenalty = value; + ; //Config.accuracyPenalty = value; else if (option.equals("errorPenalty")) - Config.errorPenalty = value; + ; //Config.errorPenalty = value; else if (option.equals("gp.crossoverPercent")) Config.GP.crossoverProbability = value / (double) 100; else if (option.equals("gp.mutationPercent")) Modified: trunk/src/dl-learner/org/dllearner/algorithms/gp/GPUtilities.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/gp/GPUtilities.java 2007-10-08 14:39:16 UTC (rev 191) +++ trunk/src/dl-learner/org/dllearner/algorithms/gp/GPUtilities.java 2007-10-08 15:04:12 UTC (rev 192) @@ -334,7 +334,10 @@ // damit stellen wir sicher, dass nur Konzepte in die Auswahl // genommen werden, die besser klassifizieren als das �bergebene // Konzept (falls das nicht existiert, dann hill climbing = reproduction) - double bestScore = score.getScore()+Config.accuracyPenalty/2; + System.err.println("Next line needs fixing to work."); + System.exit(0); + // double bestScore = score.getScore()+Config.accuracyPenalty/2; + double bestScore = 0; Map<Integer,List<String>> bestNeighbours = new TreeMap<Integer,List<String>>(); Score tmpScore; SortedSetTuple<String> tmp, tmp2; @@ -456,7 +459,7 @@ // neutClassified.retainAll(posClassified); neutClassified.retainAll(negClassified); PosNegDefinitionLPStrict lp = (PosNegDefinitionLPStrict)learningProblem; - return new ScoreThreeValued(conceptLength, posClassified, neutClassified, negClassified, lp.getPositiveExamples(),lp.getNeutralExamples(),lp.getNegativeExamples()); + return new ScoreThreeValued(conceptLength, lp.getAccuracyPenalty(), lp.getErrorPenalty(), posClassified, neutClassified, negClassified, lp.getPositiveExamples(),lp.getNeutralExamples(),lp.getNegativeExamples()); } // aktualisiert die besten Knoten Modified: trunk/src/dl-learner/org/dllearner/core/DoubleConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/DoubleConfigOption.java 2007-10-08 14:39:16 UTC (rev 191) +++ trunk/src/dl-learner/org/dllearner/core/DoubleConfigOption.java 2007-10-08 15:04:12 UTC (rev 192) @@ -35,6 +35,10 @@ super(name, description); } + public DoubleConfigOption(String name, String description, double defaultValue) { + super(name, description, defaultValue); + } + /* (non-Javadoc) * @see org.dllearner.core.ConfigOption#isValidValue(java.lang.Object) */ Modified: trunk/src/dl-learner/org/dllearner/core/IntegerConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/IntegerConfigOption.java 2007-10-08 14:39:16 UTC (rev 191) +++ trunk/src/dl-learner/org/dllearner/core/IntegerConfigOption.java 2007-10-08 15:04:12 UTC (rev 192) @@ -35,6 +35,10 @@ super(name, description); } + public IntegerConfigOption(String name, String description, int defaultValue) { + super(name, description, defaultValue); + } + /* (non-Javadoc) * @see org.dllearner.core.ConfigOption#isValidValue(java.lang.Object) */ Modified: trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLPStrict.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLPStrict.java 2007-10-08 14:39:16 UTC (rev 191) +++ trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLPStrict.java 2007-10-08 15:04:12 UTC (rev 192) @@ -26,6 +26,7 @@ import org.dllearner.core.BooleanConfigOption; import org.dllearner.core.ConfigEntry; import org.dllearner.core.ConfigOption; +import org.dllearner.core.DoubleConfigOption; import org.dllearner.core.InvalidConfigOptionValueException; import org.dllearner.core.ReasoningService; import org.dllearner.core.Score; @@ -45,6 +46,11 @@ private SortedSet<Individual> neutralExamples; private boolean penaliseNeutralExamples = false; + private static final double defaultAccuracyPenalty = 1; + private double accuracyPenalty = defaultAccuracyPenalty; + private static final double defaultErrorPenalty = 3; + private double errorPenalty = defaultErrorPenalty; + public PosNegDefinitionLPStrict(ReasoningService reasoningService) { super(reasoningService); } @@ -59,6 +65,8 @@ public static Collection<ConfigOption<?>> createConfigOptions() { Collection<ConfigOption<?>> options = PosNegLP.createConfigOptions(); options.add(new BooleanConfigOption("penaliseNeutralExamples", "if set to true neutral examples are penalised")); + options.add(new DoubleConfigOption("accuracyPenalty", "penalty for pos/neg examples which are classified as neutral", defaultAccuracyPenalty)); + options.add(new DoubleConfigOption("errorPenalty", "penalty for pos. examples classified as negative or vice versa", defaultErrorPenalty)); return options; } @@ -74,6 +82,7 @@ String name = entry.getOptionName(); if(name.equals("penaliseNeutralExamples")) penaliseNeutralExamples = (Boolean) entry.getValue(); + // else if } /* (non-Javadoc) @@ -100,13 +109,13 @@ // this.defPosSet = tuple.getPosSet(); // this.defNegSet = tuple.getNegSet(); SortedSet<Individual> neutClassified = Helper.intersectionTuple(reasoningService.getIndividuals(),tuple); - return new ScoreThreeValued(concept.getLength(),tuple.getPosSet(),neutClassified,tuple.getNegSet(),positiveExamples,neutralExamples,negativeExamples); + return new ScoreThreeValued(concept.getLength(),accuracyPenalty, errorPenalty, tuple.getPosSet(),neutClassified,tuple.getNegSet(),positiveExamples,neutralExamples,negativeExamples); } else if(reasoningService.getReasonerType() == ReasonerType.KAON2) { SortedSet<Individual> posClassified = reasoningService.retrieval(concept); SortedSet<Individual> negClassified = reasoningService.retrieval(new Negation(concept)); SortedSet<Individual> neutClassified = Helper.intersection(reasoningService.getIndividuals(),posClassified); neutClassified.retainAll(negClassified); - return new ScoreThreeValued(concept.getLength(), posClassified,neutClassified,negClassified,positiveExamples,neutralExamples,negativeExamples); + return new ScoreThreeValued(concept.getLength(), accuracyPenalty, errorPenalty, posClassified,neutClassified,negClassified,positiveExamples,neutralExamples,negativeExamples); } else throw new Error("score cannot be computed in this configuration"); } else { @@ -146,7 +155,7 @@ SortedSet<Individual> neutClassified = Helper.intersection(reasoningService.getIndividuals(),posClassified); neutClassified.retainAll(negClassified); - return new ScoreThreeValued(concept.getLength(), posClassified,neutClassified,negClassified,positiveExamples,neutralExamples,negativeExamples); + return new ScoreThreeValued(concept.getLength(), accuracyPenalty, errorPenalty, posClassified,neutClassified,negClassified,positiveExamples,neutralExamples,negativeExamples); } else throw new Error("score cannot be computed in this configuration"); } @@ -163,4 +172,18 @@ public SortedSet<Individual> getNeutralExamples() { return neutralExamples; } + + /** + * @return the accuracyPenalty + */ + public double getAccuracyPenalty() { + return accuracyPenalty; + } + + /** + * @return the errorPenalty + */ + public double getErrorPenalty() { + return errorPenalty; + } } Modified: trunk/src/dl-learner/org/dllearner/learningproblems/ScoreThreeValued.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/ScoreThreeValued.java 2007-10-08 14:39:16 UTC (rev 191) +++ trunk/src/dl-learner/org/dllearner/learningproblems/ScoreThreeValued.java 2007-10-08 15:04:12 UTC (rev 192) @@ -25,6 +25,9 @@ public enum ScoreMethod {POSITIVE, FULL}; + private double accuracyPenalty; + private double errorPenalty; + private SortedSet<Individual> posClassified; private SortedSet<Individual> neutClassified; private SortedSet<Individual> negClassified; @@ -52,6 +55,8 @@ private int conceptLength; public ScoreThreeValued(int conceptLength, + double accuracyPenalty, + double errorPenalty, SortedSet<Individual> posClassified, SortedSet<Individual> neutClassified, SortedSet<Individual> negClassified, @@ -59,6 +64,8 @@ SortedSet<Individual> neutExamples, SortedSet<Individual> negExamples) { this.conceptLength = conceptLength; + this.accuracyPenalty = accuracyPenalty; + this.errorPenalty = errorPenalty; this.posClassified = posClassified; this.neutClassified = neutClassified; this.negClassified = negClassified; @@ -85,20 +92,20 @@ } private void computeStatistics() { - score = - posAsNeg.size()*Config.errorPenalty - - negAsPos.size()*Config.errorPenalty - - posAsNeut.size()*Config.accuracyPenalty; + score = - posAsNeg.size()*errorPenalty + - negAsPos.size()*errorPenalty + - posAsNeut.size()*accuracyPenalty; if(Config.scoreMethod==ScoreMethod.FULL) - score -= negAsNeut.size()*Config.accuracyPenalty; + score -= negAsNeut.size()*accuracyPenalty; if(Config.penalizeNeutralExamples) - score -= (neutAsPos.size()*Config.accuracyPenalty - + neutAsNeg.size()*Config.accuracyPenalty); + score -= (neutAsPos.size()*accuracyPenalty + + neutAsNeg.size()*accuracyPenalty); // TODO: man könnte hier statt error penality auch accuracy penalty // nehmen - double worstValue = nrOfExamples * Config.errorPenalty; + double worstValue = nrOfExamples * errorPenalty; // ergibt Zahl zwischen -1 und 0 score = score / worstValue; score -= Config.percentPerLengthUnit * conceptLength; @@ -149,7 +156,7 @@ str += " neutral --> neutral: " + neutAsNeut + "\n"; str += " negative --> negative: " + negAsNeg + "\n"; } - str += "Inaccurately classified (penalty of " + df.format(Config.accuracyPenalty) + " per instance):\n"; + str += "Inaccurately classified (penalty of " + df.format(accuracyPenalty) + " per instance):\n"; str += " positive --> neutral: " + posAsNeut + "\n"; if(Config.penalizeNeutralExamples) { str += " neutral --> positive: " + neutAsPos + "\n"; @@ -157,7 +164,7 @@ } if(Config.scoreMethod == ScoreMethod.FULL) str += " negative --> neutral: " + negAsNeut + "\n"; - str += "Classification errors (penalty of " + df.format(Config.errorPenalty) + " per instance):\n"; + str += "Classification errors (penalty of " + df.format(errorPenalty) + " per instance):\n"; str += " positive --> negative: " + posAsNeg + "\n"; str += " negative --> positive: " + negAsPos + "\n"; str += "Statistics:\n"; @@ -194,7 +201,7 @@ @Override public Score getModifiedLengthScore(int newLength) { - return new ScoreThreeValued(newLength, posClassified, neutClassified, negClassified, posExamples, neutExamples, negExamples); + return new ScoreThreeValued(newLength, accuracyPenalty, errorPenalty, posClassified, neutClassified, negClassified, posExamples, neutExamples, negExamples); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2007-10-08 15:48:05
|
Revision: 195 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=195&view=rev Author: jenslehmann Date: 2007-10-08 08:48:00 -0700 (Mon, 08 Oct 2007) Log Message: ----------- readded search tree support for refinement operator based learning algorithm Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/Config.java trunk/src/dl-learner/org/dllearner/ConfigurationManager.java trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java trunk/src/dl-learner/org/dllearner/kb/SparqlEndpoint.java trunk/src/dl-learner/org/dllearner/reasoning/DIGReasoner.java Modified: trunk/src/dl-learner/org/dllearner/Config.java =================================================================== --- trunk/src/dl-learner/org/dllearner/Config.java 2007-10-08 15:23:41 UTC (rev 194) +++ trunk/src/dl-learner/org/dllearner/Config.java 2007-10-08 15:48:00 UTC (rev 195) @@ -1,6 +1,5 @@ package org.dllearner; -import java.io.File; import java.lang.reflect.Field; import java.net.URL; import java.util.LinkedList; @@ -139,9 +138,9 @@ public static boolean quiet = false; - public static boolean writeSearchTree = false; + // public static boolean writeSearchTree = false; - public static File searchTreeFile = new File("searchTree.txt"); + // public static File searchTreeFile = new File("searchTree.txt"); public enum Heuristic { LEXICOGRAPHIC, FLEXIBLE Modified: trunk/src/dl-learner/org/dllearner/ConfigurationManager.java =================================================================== --- trunk/src/dl-learner/org/dllearner/ConfigurationManager.java 2007-10-08 15:23:41 UTC (rev 194) +++ trunk/src/dl-learner/org/dllearner/ConfigurationManager.java 2007-10-08 15:48:00 UTC (rev 195) @@ -1,6 +1,5 @@ package org.dllearner; -import java.io.File; import java.net.MalformedURLException; import java.net.URL; import java.util.Arrays; @@ -497,9 +496,9 @@ } else if (option.equals("refinement.quiet")) Config.Refinement.quiet = Datastructures.strToBool(value); else if (option.equals("refinement.writeSearchTree")) - Config.Refinement.writeSearchTree = Datastructures.strToBool(value); + ; //Config.Refinement.writeSearchTree = Datastructures.strToBool(value); else if (option.equals("refinement.searchTreeFile")) { - Config.Refinement.searchTreeFile = new File(value); + ; // Config.Refinement.searchTreeFile = new File(value); } else if (option.equals("refinement.applyAllFilter")) Config.Refinement.applyAllFilter = Datastructures.strToBool(value); else if (option.equals("refinement.applyExistsFilter")) Modified: trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2007-10-08 15:23:41 UTC (rev 194) +++ trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2007-10-08 15:48:00 UTC (rev 195) @@ -1,5 +1,6 @@ package org.dllearner.algorithms.refinement; +import java.io.File; import java.text.DecimalFormat; import java.util.Collection; import java.util.Comparator; @@ -11,6 +12,7 @@ import java.util.TreeSet; import org.dllearner.Config; +import org.dllearner.core.BooleanConfigOption; import org.dllearner.core.ConfigEntry; import org.dllearner.core.ConfigOption; import org.dllearner.core.InvalidConfigOptionValueException; @@ -18,6 +20,7 @@ import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasoningService; import org.dllearner.core.Score; +import org.dllearner.core.StringConfigOption; import org.dllearner.core.dl.Concept; import org.dllearner.core.dl.MultiConjunction; import org.dllearner.core.dl.MultiDisjunction; @@ -30,6 +33,11 @@ public class ROLearner extends LearningAlgorithm { + // configuration options + private boolean writeSearchTree; + private File searchTreeFile; + private static String defaultSearchTreeFile = "log/searchTree.txt"; + private boolean stop = false; private ReasoningService rs; @@ -224,6 +232,8 @@ public static Collection<ConfigOption<?>> createConfigOptions() { Collection<ConfigOption<?>> options = new LinkedList<ConfigOption<?>>(); + options.add(new BooleanConfigOption("writeSearchTree", "specifies whether to write a search tree", false)); + options.add(new StringConfigOption("searchTreeFile","file to use for the search tree", defaultSearchTreeFile)); return options; } @@ -232,8 +242,11 @@ */ @Override public <T> void applyConfigEntry(ConfigEntry<T> entry) throws InvalidConfigOptionValueException { - // TODO Auto-generated method stub - + String name = entry.getOptionName(); + if(name.equals("writeSearchTree")) + writeSearchTree = (Boolean) entry.getValue(); + else if(name.equals("searchTreeFile")) + searchTreeFile = new File((String)entry.getValue()); } /* (non-Javadoc) @@ -241,6 +254,9 @@ */ @Override public void init() { + if(searchTreeFile == null) + searchTreeFile = new File(defaultSearchTreeFile); + // TODO: this needs to be changed Helper.autoDetectConceptsAndRoles(rs); // prepare subsumption and role hierarchies, because they are needed @@ -365,7 +381,7 @@ // System.out.println(n); //} - if(Config.Refinement.writeSearchTree) { + if(writeSearchTree) { // String treeString = ""; String treeString = "best expanded node: " + bestNode+ "\n"; if(expandedNodes.size()>1) { @@ -381,7 +397,7 @@ searchTree += treeString + "\n"; // TODO: ev. immer nur einen search tree speichern und den an die // Datei anhängen => spart Speicher - Files.createFile(Config.Refinement.searchTreeFile, searchTree); + Files.createFile(searchTreeFile, searchTree); } // Anzahl Schleifendurchläufe @@ -393,8 +409,8 @@ } // Suchbaum in Datei schreiben - if(Config.Refinement.writeSearchTree) - Files.createFile(Config.Refinement.searchTreeFile, searchTree); + if(writeSearchTree) + Files.createFile(searchTreeFile, searchTree); // Ergebnisausgabe /* @@ -440,7 +456,7 @@ // gefunden wurden long propCalcNsStart = System.nanoTime(); - if(Config.Refinement.writeSearchTree) + if(writeSearchTree) expandedNodes.add(node); if(node.getChildren().size()>maxNrOfChildren) Modified: trunk/src/dl-learner/org/dllearner/kb/SparqlEndpoint.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/SparqlEndpoint.java 2007-10-08 15:23:41 UTC (rev 194) +++ trunk/src/dl-learner/org/dllearner/kb/SparqlEndpoint.java 2007-10-08 15:48:00 UTC (rev 195) @@ -24,16 +24,9 @@ import java.net.MalformedURLException; import java.net.URI; import java.net.URL; -import java.util.ArrayList; import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; import java.util.LinkedList; -import java.util.Map; import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; import org.dllearner.core.ConfigEntry; import org.dllearner.core.ConfigOption; @@ -42,10 +35,7 @@ import org.dllearner.core.KnowledgeSource; import org.dllearner.core.StringConfigOption; import org.dllearner.core.StringSetConfigOption; -import org.dllearner.core.dl.AtomicConcept; -import org.dllearner.core.dl.Individual; import org.dllearner.reasoning.JenaOWLDIGConverter; -import org.dllearner.reasoning.OWLAPIDIGConverter; import org.dllearner.utilities.Datastructures; /** Modified: trunk/src/dl-learner/org/dllearner/reasoning/DIGReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/DIGReasoner.java 2007-10-08 15:23:41 UTC (rev 194) +++ trunk/src/dl-learner/org/dllearner/reasoning/DIGReasoner.java 2007-10-08 15:48:00 UTC (rev 195) @@ -102,7 +102,7 @@ private boolean writeDIGProtocol; private File digProtocolFile; - private static String defaultDIGProtocolFile = "log/digProtocol"; + private static String defaultDIGProtocolFile = "log/digProtocol.txt"; public DIGReasoner(Set<KnowledgeSource> sources) { this.sources = sources; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2007-10-08 16:33:35
|
Revision: 197 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=197&view=rev Author: jenslehmann Date: 2007-10-08 09:33:30 -0700 (Mon, 08 Oct 2007) Log Message: ----------- more config options integrated Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/Config.java trunk/src/dl-learner/org/dllearner/ConfigurationManager.java trunk/src/dl-learner/org/dllearner/learningproblems/ScoreThreeValued.java Modified: trunk/src/dl-learner/org/dllearner/Config.java =================================================================== --- trunk/src/dl-learner/org/dllearner/Config.java 2007-10-08 16:25:29 UTC (rev 196) +++ trunk/src/dl-learner/org/dllearner/Config.java 2007-10-08 16:33:30 UTC (rev 197) @@ -11,7 +11,6 @@ import org.dllearner.core.dl.AtomicConcept; import org.dllearner.core.dl.AtomicRole; import org.dllearner.learningproblems.PosNegLP.UseMultiInstanceChecks; -import org.dllearner.learningproblems.ScoreThreeValued.ScoreMethod; import org.dllearner.reasoning.ReasonerType; public class Config { @@ -28,13 +27,13 @@ // und negativ als positiv // public static double errorPenalty = 3; - public static ScoreMethod scoreMethod = ScoreMethod.POSITIVE; + // public static ScoreMethod scoreMethod = ScoreMethod.POSITIVE; // public static LearningProblemType learningProblemType = LearningProblemType.TWO_VALUED; // public static boolean penalizeNeutralExamples = false; - public static boolean showCorrectClassifications = false; + // public static boolean showCorrectClassifications = false; // wieviel Prozent darf ein um eine Einheit längeres Konzept schlechter // sein (aktuell: 5% sind eine Verlängerung um 1 wert) Modified: trunk/src/dl-learner/org/dllearner/ConfigurationManager.java =================================================================== --- trunk/src/dl-learner/org/dllearner/ConfigurationManager.java 2007-10-08 16:25:29 UTC (rev 196) +++ trunk/src/dl-learner/org/dllearner/ConfigurationManager.java 2007-10-08 16:33:30 UTC (rev 197) @@ -17,7 +17,6 @@ import org.dllearner.cli.ConfFileOption; import org.dllearner.core.dl.AtomicConcept; import org.dllearner.core.dl.AtomicRole; -import org.dllearner.learningproblems.ScoreThreeValued.ScoreMethod; import org.dllearner.parser.KBParser; import org.dllearner.reasoning.ReasonerType; import org.dllearner.utilities.ConceptComparator; @@ -423,7 +422,7 @@ if (option.equals("penalizeNeutralExamples")) ; // Config.penalizeNeutralExamples = Datastructures.strToBool(value); else if (option.equals("showCorrectClassifications")) - Config.showCorrectClassifications = Datastructures.strToBool(value); + ; // Config.showCorrectClassifications = Datastructures.strToBool(value); else if (option.equals("statMode")) Config.statisticMode = Datastructures.strToBool(value); else if (option.equals("una")) @@ -433,10 +432,10 @@ else if (option.equals("gp.useFixedNumberOfGenerations")) Config.GP.useFixedNumberOfGenerations = Datastructures.strToBool(value); else if (option.equals("scoreMethod")) { - if (value.equals("full")) - Config.scoreMethod = ScoreMethod.FULL; - else - Config.scoreMethod = ScoreMethod.POSITIVE; +// if (value.equals("full")) +// Config.scoreMethod = ScoreMethod.FULL; +// else +// Config.scoreMethod = ScoreMethod.POSITIVE; } else if (option.equals("returnType")) Config.returnType = value; else if (option.equals("algorithm")) { Modified: trunk/src/dl-learner/org/dllearner/learningproblems/ScoreThreeValued.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/ScoreThreeValued.java 2007-10-08 16:25:29 UTC (rev 196) +++ trunk/src/dl-learner/org/dllearner/learningproblems/ScoreThreeValued.java 2007-10-08 16:33:30 UTC (rev 197) @@ -1,3 +1,23 @@ +/** + * Copyright (C) 2007, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + package org.dllearner.learningproblems; import java.text.DecimalFormat; @@ -10,13 +30,13 @@ import org.dllearner.utilities.Helper; /** - * Berechnet die Punktzahl (negativ), indem es die Ergebnisse einer Definition - * mit den Soll-Ergebnissen vergleicht. + * Computes the score (a negative value) by comparing the classification results + * with ideal results. * - * TODO: die Implementierung ist momentan dahingehend unguenstig, dass viele Sachen - * nur fuer die optische Aufbereitung berechnet werden; effizienter waere es - * nur die Klassifikationsfehler zu beruecksichtigen und andere statistische Werte nur - * dann wenn sie benoetigt werden + * @todo: The implementation is not very efficient, because some things are + * only computed to be able to present the score results. This means that + * it would be better to compute only the necessary computations and do + * the other ones only when they are needed to calculate statistical values. * * @author Jens Lehmann * @@ -25,10 +45,16 @@ public enum ScoreMethod {POSITIVE, FULL}; + // configuration options private double accuracyPenalty; private double errorPenalty; private boolean penaliseNeutralExamples; + // potential configuration options (not implemented as such, but one + // could so) + private boolean showCorrectClassifications = false; + private static ScoreMethod scoreMethod = ScoreMethod.POSITIVE; + private SortedSet<Individual> posClassified; private SortedSet<Individual> neutClassified; private SortedSet<Individual> negClassified; @@ -98,7 +124,7 @@ - negAsPos.size()*errorPenalty - posAsNeut.size()*accuracyPenalty; - if(Config.scoreMethod==ScoreMethod.FULL) + if(scoreMethod==ScoreMethod.FULL) score -= negAsNeut.size()*accuracyPenalty; if(penaliseNeutralExamples) @@ -145,14 +171,14 @@ DecimalFormat df = new DecimalFormat("0.00"); String str = ""; str += "score method "; - if(Config.scoreMethod == ScoreMethod.FULL) + if(scoreMethod == ScoreMethod.FULL) str += "full"; else str += "positive"; if(!penaliseNeutralExamples) str += " (neutral examples not penalized)"; str += "\n"; - if(Config.showCorrectClassifications) { + if(showCorrectClassifications) { str += "Correctly classified:\n"; str += " positive --> positive: " + posAsPos + "\n"; str += " neutral --> neutral: " + neutAsNeut + "\n"; @@ -164,7 +190,7 @@ str += " neutral --> positive: " + neutAsPos + "\n"; str += " neutral --> negative: " + neutAsNeg + "\n"; } - if(Config.scoreMethod == ScoreMethod.FULL) + if(scoreMethod == ScoreMethod.FULL) str += " negative --> neutral: " + negAsNeut + "\n"; str += "Classification errors (penalty of " + df.format(errorPenalty) + " per instance):\n"; str += " positive --> negative: " + posAsNeg + "\n"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2007-10-08 16:44:17
|
Revision: 196 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=196&view=rev Author: jenslehmann Date: 2007-10-08 09:25:29 -0700 (Mon, 08 Oct 2007) Log Message: ----------- another configuration option (penaliseNeutralExamples) adapted to new structure Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/Config.java trunk/src/dl-learner/org/dllearner/ConfigurationManager.java trunk/src/dl-learner/org/dllearner/algorithms/gp/GPUtilities.java trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLPStrict.java trunk/src/dl-learner/org/dllearner/learningproblems/ScoreThreeValued.java Modified: trunk/src/dl-learner/org/dllearner/Config.java =================================================================== --- trunk/src/dl-learner/org/dllearner/Config.java 2007-10-08 15:48:00 UTC (rev 195) +++ trunk/src/dl-learner/org/dllearner/Config.java 2007-10-08 16:25:29 UTC (rev 196) @@ -32,7 +32,7 @@ // public static LearningProblemType learningProblemType = LearningProblemType.TWO_VALUED; - public static boolean penalizeNeutralExamples = false; + // public static boolean penalizeNeutralExamples = false; public static boolean showCorrectClassifications = false; Modified: trunk/src/dl-learner/org/dllearner/ConfigurationManager.java =================================================================== --- trunk/src/dl-learner/org/dllearner/ConfigurationManager.java 2007-10-08 15:48:00 UTC (rev 195) +++ trunk/src/dl-learner/org/dllearner/ConfigurationManager.java 2007-10-08 16:25:29 UTC (rev 196) @@ -421,7 +421,7 @@ private void applyStringOptions(String option, String value) { if (option.equals("penalizeNeutralExamples")) - Config.penalizeNeutralExamples = Datastructures.strToBool(value); + ; // Config.penalizeNeutralExamples = Datastructures.strToBool(value); else if (option.equals("showCorrectClassifications")) Config.showCorrectClassifications = Datastructures.strToBool(value); else if (option.equals("statMode")) Modified: trunk/src/dl-learner/org/dllearner/algorithms/gp/GPUtilities.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/gp/GPUtilities.java 2007-10-08 15:48:00 UTC (rev 195) +++ trunk/src/dl-learner/org/dllearner/algorithms/gp/GPUtilities.java 2007-10-08 16:25:29 UTC (rev 196) @@ -459,7 +459,7 @@ // neutClassified.retainAll(posClassified); neutClassified.retainAll(negClassified); PosNegDefinitionLPStrict lp = (PosNegDefinitionLPStrict)learningProblem; - return new ScoreThreeValued(conceptLength, lp.getAccuracyPenalty(), lp.getErrorPenalty(), posClassified, neutClassified, negClassified, lp.getPositiveExamples(),lp.getNeutralExamples(),lp.getNegativeExamples()); + return new ScoreThreeValued(conceptLength, lp.getAccuracyPenalty(), lp.getErrorPenalty(), lp.isPenaliseNeutralExamples(), posClassified, neutClassified, negClassified, lp.getPositiveExamples(),lp.getNeutralExamples(),lp.getNegativeExamples()); } // aktualisiert die besten Knoten Modified: trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLPStrict.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLPStrict.java 2007-10-08 15:48:00 UTC (rev 195) +++ trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLPStrict.java 2007-10-08 16:25:29 UTC (rev 196) @@ -82,7 +82,10 @@ String name = entry.getOptionName(); if(name.equals("penaliseNeutralExamples")) penaliseNeutralExamples = (Boolean) entry.getValue(); - // else if + else if(name.equals("accuracyPenalty")) + accuracyPenalty = (Double) entry.getValue(); + else if(name.equals("errorPenalty")) + errorPenalty = (Double) entry.getValue(); } /* (non-Javadoc) @@ -109,13 +112,13 @@ // this.defPosSet = tuple.getPosSet(); // this.defNegSet = tuple.getNegSet(); SortedSet<Individual> neutClassified = Helper.intersectionTuple(reasoningService.getIndividuals(),tuple); - return new ScoreThreeValued(concept.getLength(),accuracyPenalty, errorPenalty, tuple.getPosSet(),neutClassified,tuple.getNegSet(),positiveExamples,neutralExamples,negativeExamples); + return new ScoreThreeValued(concept.getLength(),accuracyPenalty, errorPenalty, penaliseNeutralExamples, tuple.getPosSet(),neutClassified,tuple.getNegSet(),positiveExamples,neutralExamples,negativeExamples); } else if(reasoningService.getReasonerType() == ReasonerType.KAON2) { SortedSet<Individual> posClassified = reasoningService.retrieval(concept); SortedSet<Individual> negClassified = reasoningService.retrieval(new Negation(concept)); SortedSet<Individual> neutClassified = Helper.intersection(reasoningService.getIndividuals(),posClassified); neutClassified.retainAll(negClassified); - return new ScoreThreeValued(concept.getLength(), accuracyPenalty, errorPenalty, posClassified,neutClassified,negClassified,positiveExamples,neutralExamples,negativeExamples); + return new ScoreThreeValued(concept.getLength(), accuracyPenalty, errorPenalty, penaliseNeutralExamples, posClassified,neutClassified,negClassified,positiveExamples,neutralExamples,negativeExamples); } else throw new Error("score cannot be computed in this configuration"); } else { @@ -155,7 +158,7 @@ SortedSet<Individual> neutClassified = Helper.intersection(reasoningService.getIndividuals(),posClassified); neutClassified.retainAll(negClassified); - return new ScoreThreeValued(concept.getLength(), accuracyPenalty, errorPenalty, posClassified,neutClassified,negClassified,positiveExamples,neutralExamples,negativeExamples); + return new ScoreThreeValued(concept.getLength(), accuracyPenalty, errorPenalty, penaliseNeutralExamples, posClassified,neutClassified,negClassified,positiveExamples,neutralExamples,negativeExamples); } else throw new Error("score cannot be computed in this configuration"); } @@ -186,4 +189,11 @@ public double getErrorPenalty() { return errorPenalty; } + + /** + * @return the penaliseNeutralExamples + */ + public boolean isPenaliseNeutralExamples() { + return penaliseNeutralExamples; + } } Modified: trunk/src/dl-learner/org/dllearner/learningproblems/ScoreThreeValued.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/ScoreThreeValued.java 2007-10-08 15:48:00 UTC (rev 195) +++ trunk/src/dl-learner/org/dllearner/learningproblems/ScoreThreeValued.java 2007-10-08 16:25:29 UTC (rev 196) @@ -27,6 +27,7 @@ private double accuracyPenalty; private double errorPenalty; + private boolean penaliseNeutralExamples; private SortedSet<Individual> posClassified; private SortedSet<Individual> neutClassified; @@ -57,6 +58,7 @@ public ScoreThreeValued(int conceptLength, double accuracyPenalty, double errorPenalty, + boolean penaliseNeutralExamples, SortedSet<Individual> posClassified, SortedSet<Individual> neutClassified, SortedSet<Individual> negClassified, @@ -99,7 +101,7 @@ if(Config.scoreMethod==ScoreMethod.FULL) score -= negAsNeut.size()*accuracyPenalty; - if(Config.penalizeNeutralExamples) + if(penaliseNeutralExamples) score -= (neutAsPos.size()*accuracyPenalty + neutAsNeg.size()*accuracyPenalty); @@ -147,7 +149,7 @@ str += "full"; else str += "positive"; - if(!Config.penalizeNeutralExamples) + if(!penaliseNeutralExamples) str += " (neutral examples not penalized)"; str += "\n"; if(Config.showCorrectClassifications) { @@ -158,7 +160,7 @@ } str += "Inaccurately classified (penalty of " + df.format(accuracyPenalty) + " per instance):\n"; str += " positive --> neutral: " + posAsNeut + "\n"; - if(Config.penalizeNeutralExamples) { + if(penaliseNeutralExamples) { str += " neutral --> positive: " + neutAsPos + "\n"; str += " neutral --> negative: " + neutAsNeg + "\n"; } @@ -201,7 +203,7 @@ @Override public Score getModifiedLengthScore(int newLength) { - return new ScoreThreeValued(newLength, accuracyPenalty, errorPenalty, posClassified, neutClassified, negClassified, posExamples, neutExamples, negExamples); + return new ScoreThreeValued(newLength, accuracyPenalty, errorPenalty, penaliseNeutralExamples, posClassified, neutClassified, negClassified, posExamples, neutExamples, negExamples); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2007-10-11 16:17:23
|
Revision: 215 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=215&view=rev Author: jenslehmann Date: 2007-10-11 09:17:19 -0700 (Thu, 11 Oct 2007) Log Message: ----------- - (re-)enabled heuristic choosing for refinement operator approach (lexicographic standard heuristic and flexible heuristic) Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/Config.java trunk/src/dl-learner/org/dllearner/ConfigurationManager.java trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java trunk/src/dl-learner/org/dllearner/core/CommonConfigOptions.java trunk/src/dl-learner/org/dllearner/core/StringConfigOption.java Modified: trunk/src/dl-learner/org/dllearner/Config.java =================================================================== --- trunk/src/dl-learner/org/dllearner/Config.java 2007-10-11 13:45:35 UTC (rev 214) +++ trunk/src/dl-learner/org/dllearner/Config.java 2007-10-11 16:17:19 UTC (rev 215) @@ -141,12 +141,8 @@ // public static File searchTreeFile = new File("searchTree.txt"); - public enum Heuristic { - LEXICOGRAPHIC, FLEXIBLE - }; + // public static Heuristic heuristic = Heuristic.LEXICOGRAPHIC; - public static Heuristic heuristic = Heuristic.LEXICOGRAPHIC; - // multi instance check => es wird versucht mehrere instance checks pro // Anfrage auf einmal an den Reasoner zu schicken; Vorteil bei DIG: // weniger Kommunikation; Nachteil: es müssen alle instanceChecks Modified: trunk/src/dl-learner/org/dllearner/ConfigurationManager.java =================================================================== --- trunk/src/dl-learner/org/dllearner/ConfigurationManager.java 2007-10-11 13:45:35 UTC (rev 214) +++ trunk/src/dl-learner/org/dllearner/ConfigurationManager.java 2007-10-11 16:17:19 UTC (rev 215) @@ -415,7 +415,7 @@ else if (option.equals("refinement.horizontalExpansionFactor")) Config.Refinement.horizontalExpansionFactor = value; else if (option.equals("percentPerLengthUnit")) - Config.percentPerLengthUnit = value; + ; // Config.percentPerLengthUnit = value; } private void applyStringOptions(String option, String value) { @@ -488,10 +488,10 @@ } else if (option.equals("gp.adc")) { Config.GP.adc = Datastructures.strToBool(value); } else if (option.equals("refinement.heuristic")) { - if(value.equals("lexicographic")) - Config.Refinement.heuristic = Config.Refinement.Heuristic.LEXICOGRAPHIC; - else - Config.Refinement.heuristic = Config.Refinement.Heuristic.FLEXIBLE; +// if(value.equals("lexicographic")) +// Config.Refinement.heuristic = Config.Refinement.Heuristic.LEXICOGRAPHIC; +// else +// Config.Refinement.heuristic = Config.Refinement.Heuristic.FLEXIBLE; } else if (option.equals("refinement.quiet")) Config.Refinement.quiet = Datastructures.strToBool(value); else if (option.equals("refinement.writeSearchTree")) Modified: trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2007-10-11 13:45:35 UTC (rev 214) +++ trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2007-10-11 16:17:19 UTC (rev 215) @@ -33,10 +33,13 @@ public class ROLearner extends LearningAlgorithm { + public enum Heuristic { LEXICOGRAPHIC, FLEXIBLE } + // configuration options private boolean writeSearchTree; private File searchTreeFile; private static String defaultSearchTreeFile = "log/searchTree.txt"; + private Heuristic heuristic = Heuristic.LEXICOGRAPHIC; private boolean stop = false; @@ -123,105 +126,12 @@ this.learningProblem = learningProblem; this.rs = rs; - // rs.getR - // this.learningProblem2 = learningProblem2; operator = new RhoDown(learningProblem); - // Heuristik je nach Konfiguration einstellen - if(Config.Refinement.heuristic == Config.Refinement.Heuristic.LEXICOGRAPHIC) - nodeComparator = new NodeComparator(); - else - nodeComparator = new NodeComparator2(learningProblem.getNegativeExamples().size()); - // candidate sets entsprechend der gewählten Heuristik initialisieren candidates = new TreeSet<Node>(nodeComparator); // newCandidates = new TreeSet<Node>(nodeComparator); - - // System.out.println("==="); - - - // short concept test - // Concept c = DLLearner.parseConcept("((male OR (male OR EXISTS hasChild.TOP)) AND male)"); - // c = ConceptTransformation.transformToMultiClean(c); - // System.out.println("parsed: " + c); - // Concept c2 = ConceptTransformation.getShortConcept(c, conceptComparator); - // ConceptTransformation.cleanConcept(c); - // System.out.println("old: " + c); - // System.out.println("new: " + c2); - // System.exit(0); - - // Subsumption-Test - // Concept superConcept = DLLearner.parseConcept("BOTTOM"); - // Concept subConcept = DLLearner.parseConcept("TOP"); - // Concept subConcept = DLLearner.parseConcept("(male AND TOP)"); - - // boolean result = learningProblem.getReasoningService().subsumes(superConcept, subConcept); - // System.out.println(result); - // System.exit(0); - - // Set<Concept> superConcepts = new HashSet<Concept>(); - // superConcepts.add(c1); - // superConcepts.add(c2); - // Set<Concept> result = learningProblem.getReasoningService().subsumes(superConcepts, subConcept); - // System.out.println(result); - // System.exit(0); - - // boolean result = learningProblem.getReasoningService().subsumes(c1, c2); - // System.out.println(c1 + " subsumes " + c2 + ": " +result); - // System.exit(0); - - // Subsumption-Hierarchie-Test - // Concept c = DLLearner.parseConcept("top"); - // System.out.println(learningProblem.getReasoningService().getMoreGeneralConcepts(c)); - // System.exit(0); - - // Zerlegungstest - - /* - int length = 10; - - System.out.println("length " + length); - long startTime = System.nanoTime(); - List<List<Integer>> combos2 = ((RhoDown)operator).getCombos(length); - long duration = System.nanoTime() - startTime; - for(List<Integer> combo : combos2) { - System.out.println(combo); - } - - System.out.println("--"); - startTime = System.nanoTime(); - RhoDown.summen(length,length,"",0); - long duration2 = System.nanoTime() - startTime; - System.out.println("--"); - - System.out.println("duration 1: " + Helper.prettyPrintNanoSeconds(duration)); - System.out.println("duration 2: " + Helper.prettyPrintNanoSeconds(duration2)); - - System.exit(0); - */ - - - // Refinement-Test - /* - // RhoDown rho = new RhoDown(learningProblem); - Concept concept = DLLearner.parseConcept("male"); - concept = ConceptTransformation.transformToMulti(concept); - - Set<Concept> refinements = operator.refine(concept, 3, null); - - - System.out.println("=== testing refinements of " + concept + " ==="); - // rho.computeTopRefinements(5); - // for(Concept c : rho.topRefinementsCumulative.get(5)) { - // for(Concept c : rho.m.get(3)) { - for(Concept c : refinements) { - System.out.println(c); - } - */ - - - // start(); } public static Collection<Class<? extends LearningProblem>> supportedLearningProblems() { @@ -234,6 +144,9 @@ Collection<ConfigOption<?>> options = new LinkedList<ConfigOption<?>>(); options.add(new BooleanConfigOption("writeSearchTree", "specifies whether to write a search tree", false)); options.add(new StringConfigOption("searchTreeFile","file to use for the search tree", defaultSearchTreeFile)); + StringConfigOption heuristicOption = new StringConfigOption("heuristic", "specifiy the heuristic to use", "lexicographic"); + heuristicOption.setAllowedValues(new String[] {"lexicographic", "flexible"}); + options.add(heuristicOption); return options; } @@ -247,6 +160,13 @@ writeSearchTree = (Boolean) entry.getValue(); else if(name.equals("searchTreeFile")) searchTreeFile = new File((String)entry.getValue()); + else if(name.equals("heuristic")) { + String value = (String) entry.getValue(); + if(value.equals("lexicographic")) + heuristic = Heuristic.LEXICOGRAPHIC; + else + heuristic = Heuristic.FLEXIBLE; + } } /* (non-Javadoc) @@ -257,6 +177,12 @@ if(searchTreeFile == null) searchTreeFile = new File(defaultSearchTreeFile); + // adjust heuristic + if(heuristic == Heuristic.LEXICOGRAPHIC) + nodeComparator = new NodeComparator(); + else + nodeComparator = new NodeComparator2(learningProblem.getNegativeExamples().size()); + // TODO: this needs to be changed Helper.autoDetectConceptsAndRoles(rs); // prepare subsumption and role hierarchies, because they are needed @@ -896,6 +822,4 @@ stop = true; } - - } Modified: trunk/src/dl-learner/org/dllearner/core/CommonConfigOptions.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/CommonConfigOptions.java 2007-10-11 13:45:35 UTC (rev 214) +++ trunk/src/dl-learner/org/dllearner/core/CommonConfigOptions.java 2007-10-11 16:17:19 UTC (rev 215) @@ -31,4 +31,11 @@ return verbosityOption; } + public static DoubleConfigOption getPercentPerLenghtUnitOption(double defaultValue) { + DoubleConfigOption option = new DoubleConfigOption("percentPerLenghtUnit", "describes the reduction in classification accuracy in percent one is willing to accept for reducing the length of the concept by one", defaultValue); + option.setLowerLimit(0.0); + option.setUpperLimit(1.0); + return option; + } + } Modified: trunk/src/dl-learner/org/dllearner/core/StringConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/StringConfigOption.java 2007-10-11 13:45:35 UTC (rev 214) +++ trunk/src/dl-learner/org/dllearner/core/StringConfigOption.java 2007-10-11 16:17:19 UTC (rev 215) @@ -19,6 +19,7 @@ */ package org.dllearner.core; +import java.util.Arrays; import java.util.Set; import java.util.TreeSet; @@ -66,6 +67,10 @@ this.allowedValues = allowedValues; } + public void setAllowedValues(String[] allowedValues) { + this.allowedValues = new TreeSet<String>(Arrays.asList(allowedValues)); + } + /* (non-Javadoc) * @see org.dllearner.core.ConfigOption#checkType(java.lang.Object) */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2007-10-11 18:35:13
|
Revision: 216 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=216&view=rev Author: jenslehmann Date: 2007-10-11 11:35:03 -0700 (Thu, 11 Oct 2007) Log Message: ----------- - enabled another couple of options (tedious work) - code beautifications Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/Config.java trunk/src/dl-learner/org/dllearner/ConfigurationManager.java trunk/src/dl-learner/org/dllearner/algorithms/BruteForceLearner.java trunk/src/dl-learner/org/dllearner/algorithms/gp/GP.java trunk/src/dl-learner/org/dllearner/algorithms/gp/GPUtilities.java trunk/src/dl-learner/org/dllearner/algorithms/refinement/NodeComparator.java trunk/src/dl-learner/org/dllearner/algorithms/refinement/NodeComparator2.java trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java trunk/src/dl-learner/org/dllearner/core/CommonConfigOptions.java trunk/src/dl-learner/org/dllearner/core/LearningProblem.java trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLP.java trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLPStrict.java trunk/src/dl-learner/org/dllearner/learningproblems/PosNegLP.java trunk/src/dl-learner/org/dllearner/learningproblems/ScoreThreeValued.java trunk/src/dl-learner/org/dllearner/learningproblems/ScoreTwoValued.java trunk/src/dl-learner/org/dllearner/server/ClientState.java trunk/src/dl-learner/org/dllearner/server/DLLearnerWSNew.java trunk/src/dl-learner/org/dllearner/server/DLLearnerWSoriginal.java trunk/src/dl-learner/org/dllearner/utilities/PaperStatistics.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/algorithms/refinement/Heuristic.java Modified: trunk/src/dl-learner/org/dllearner/Config.java =================================================================== --- trunk/src/dl-learner/org/dllearner/Config.java 2007-10-11 16:17:19 UTC (rev 215) +++ trunk/src/dl-learner/org/dllearner/Config.java 2007-10-11 18:35:03 UTC (rev 216) @@ -1,7 +1,6 @@ package org.dllearner; import java.lang.reflect.Field; -import java.net.URL; import java.util.LinkedList; import java.util.List; import java.util.Set; @@ -11,7 +10,6 @@ import org.dllearner.core.dl.AtomicConcept; import org.dllearner.core.dl.AtomicRole; import org.dllearner.learningproblems.PosNegLP.UseMultiInstanceChecks; -import org.dllearner.reasoning.ReasonerType; public class Config { // standardmäßig wird bis Tiefe 7 gesucht @@ -52,34 +50,34 @@ // 0.05) // angebracht // public static double percentPerLengthUnit = 0.0025; - public static double percentPerLengthUnit = 0.05; + // public static double percentPerLengthUnit = 0.05; - public enum Algorithm { - GP, BRUTE_FORCE, RANDOM_GUESSER, REFINEMENT, HYBRID_GP - }; +// public enum Algorithm { +// GP, BRUTE_FORCE, RANDOM_GUESSER, REFINEMENT, HYBRID_GP +// }; +// +// public static Algorithm algorithm = Algorithm.REFINEMENT; - public static Algorithm algorithm = Algorithm.REFINEMENT; - // Rückgabetyp des gelernten Konzepts - public static String returnType = ""; + // public static String returnType = ""; - public static boolean statisticMode = false; + // public static boolean statisticMode = false; // if set to true a retrieval algorithm is used for classification // instead of single instance checks (default is now false, because // we can send all instance checks in a single request), for KAON2 // as reasoner it should in many cases be set to true - public static boolean useRetrievalForClassification = false; + // public static boolean useRetrievalForClassification = false; // welche Art von Reasoning wird benutzt (eigener Algorithmus, // KAON2-API, DIG-Interface) - public static ReasonerType reasonerType = ReasonerType.DIG; + // public static ReasonerType reasonerType = ReasonerType.DIG; // bei fast retrieval muss trotzdem irgendein Reasoner gesetzt // werden um die flat ABox zu erzeugen - public static ReasonerType startUpReasoningType = ReasonerType.KAON2; + // public static ReasonerType startUpReasoningType = ReasonerType.KAON2; - public static URL digReasonerURL = null; + // public static URL digReasonerURL = null; // unique names assumption public static boolean una = false; Modified: trunk/src/dl-learner/org/dllearner/ConfigurationManager.java =================================================================== --- trunk/src/dl-learner/org/dllearner/ConfigurationManager.java 2007-10-11 16:17:19 UTC (rev 215) +++ trunk/src/dl-learner/org/dllearner/ConfigurationManager.java 2007-10-11 18:35:03 UTC (rev 216) @@ -1,7 +1,5 @@ package org.dllearner; -import java.net.MalformedURLException; -import java.net.URL; import java.util.Arrays; import java.util.Collection; import java.util.HashMap; @@ -11,14 +9,12 @@ import java.util.Set; import java.util.TreeSet; -import org.dllearner.Config.Algorithm; import org.dllearner.algorithms.gp.GP.AlgorithmType; import org.dllearner.algorithms.gp.GP.SelectionType; import org.dllearner.cli.ConfFileOption; import org.dllearner.core.dl.AtomicConcept; import org.dllearner.core.dl.AtomicRole; import org.dllearner.parser.KBParser; -import org.dllearner.reasoning.ReasonerType; import org.dllearner.utilities.ConceptComparator; import org.dllearner.utilities.Datastructures; import org.dllearner.utilities.RoleComparator; @@ -80,14 +76,14 @@ // DIG-Reasoner-URL setzen, falls nicht schon geschehen (kann wegen Exception // nicht in Config gesetzt werden) - if(Config.digReasonerURL == null) { - try { - Config.digReasonerURL = new URL("http://localhost:8081"); - } catch (MalformedURLException e) { - // Exception tritt nie auf, da URL korrekt - e.printStackTrace(); - } - } +// if(Config.digReasonerURL == null) { +// try { +// Config.digReasonerURL = new URL("http://localhost:8081"); +// } catch (MalformedURLException e) { +// // Exception tritt nie auf, da URL korrekt +// e.printStackTrace(); +// } +// } // der parserinterne Namespace wird immer ausgeblendet Config.hidePrefixes.add(KBParser.internalNamespace); @@ -424,38 +420,38 @@ else if (option.equals("showCorrectClassifications")) ; // Config.showCorrectClassifications = Datastructures.strToBool(value); else if (option.equals("statMode")) - Config.statisticMode = Datastructures.strToBool(value); + ; // Config.statisticMode = Datastructures.strToBool(value); else if (option.equals("una")) Config.una = Datastructures.strToBool(value); else if (option.equals("owa")) Config.owa = Datastructures.strToBool(value); else if (option.equals("gp.useFixedNumberOfGenerations")) Config.GP.useFixedNumberOfGenerations = Datastructures.strToBool(value); - else if (option.equals("scoreMethod")) { +// else if (option.equals("scoreMethod")) { // if (value.equals("full")) // Config.scoreMethod = ScoreMethod.FULL; // else // Config.scoreMethod = ScoreMethod.POSITIVE; - } else if (option.equals("returnType")) - Config.returnType = value; - else if (option.equals("algorithm")) { - if (value.equals("gp")) - Config.algorithm = Algorithm.GP; - else if (value.equals("random")) - Config.algorithm = Algorithm.RANDOM_GUESSER; - else if(value.equals("bruteForce")) - Config.algorithm = Algorithm.BRUTE_FORCE; - else if(value.equals("refinement")) - Config.algorithm = Algorithm.REFINEMENT; - // hybrid GP = Menge von Konfigurationsoptionen - else { - Config.algorithm = Algorithm.HYBRID_GP; - Config.GP.refinementProbability = 1.0d; - Config.GP.crossoverProbability = 0.0d; - Config.GP.hillClimbingProbability = 0.0d; - Config.GP.mutationProbability = 0.0d; - } - } else if(option.equals("hidePrefix")) { +// } else if (option.equals("returnType")) +// Config.returnType = value; +// else if (option.equals("algorithm")) { +// if (value.equals("gp")) +// Config.algorithm = Algorithm.GP; +// else if (value.equals("random")) +// Config.algorithm = Algorithm.RANDOM_GUESSER; +// else if(value.equals("bruteForce")) +// Config.algorithm = Algorithm.BRUTE_FORCE; +// else if(value.equals("refinement")) +// Config.algorithm = Algorithm.REFINEMENT; +// // hybrid GP = Menge von Konfigurationsoptionen +// else { +// Config.algorithm = Algorithm.HYBRID_GP; +// Config.GP.refinementProbability = 1.0d; +// Config.GP.crossoverProbability = 0.0d; +// Config.GP.hillClimbingProbability = 0.0d; +// Config.GP.mutationProbability = 0.0d; +// } + else if(option.equals("hidePrefix")) { Config.hidePrefixes.add(value); } else if (option.equals("showIndividuals")) { Config.showIndividuals = Datastructures.strToBool(value); @@ -514,23 +510,24 @@ Config.Refinement.useExistsConstructor = Datastructures.strToBool(value); else if (option.equals("refinement.useNegation")) Config.Refinement.useNegation = Datastructures.strToBool(value); - else if (option.equals("reasoner")) { - if(value.equals("dig")) - Config.reasonerType = ReasonerType.DIG; - else if(value.equals("kaon2")) - Config.reasonerType = ReasonerType.KAON2; - else if(value.equals("fastRetrieval")) - Config.reasonerType = ReasonerType.FAST_RETRIEVAL; - } else if (option.equals("digReasonerURL")) { - try { - Config.digReasonerURL = new URL(value); - } catch (MalformedURLException e) { - e.printStackTrace(); - System.err.println("Malformed URL for DIG reasoner was given."); - System.exit(0); - } - } else if (option.equals("useRetrievalForClassification")) - Config.useRetrievalForClassification = Datastructures.strToBool(value); +// else if (option.equals("reasoner")) { +// if(value.equals("dig")) +// Config.reasonerType = ReasonerType.DIG; +// else if(value.equals("kaon2")) +// Config.reasonerType = ReasonerType.KAON2; +// else if(value.equals("fastRetrieval")) +// Config.reasonerType = ReasonerType.FAST_RETRIEVAL; + else if (option.equals("digReasonerURL")) { +// try { +// Config.digReasonerURL = new URL(value); +// } catch (MalformedURLException e) { +// e.printStackTrace(); +// System.err.println("Malformed URL for DIG reasoner was given."); +// System.exit(0); +// } + } +// } else if (option.equals("useRetrievalForClassification")) +// Config.useRetrievalForClassification = Datastructures.strToBool(value); // else if (option.equals("refinement.useDIGMultiInstanceChecks")) { // if(value.equals("never")) // Config.Refinement.useDIGMultiInstanceChecks = Config.Refinement.UseDIGMultiInstanceChecks.NEVER; Modified: trunk/src/dl-learner/org/dllearner/algorithms/BruteForceLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/BruteForceLearner.java 2007-10-11 16:17:19 UTC (rev 215) +++ trunk/src/dl-learner/org/dllearner/algorithms/BruteForceLearner.java 2007-10-11 18:35:03 UTC (rev 216) @@ -26,7 +26,7 @@ import java.util.List; import java.util.Map; -import org.dllearner.Config; +import org.dllearner.core.CommonConfigOptions; import org.dllearner.core.ConfigEntry; import org.dllearner.core.ConfigOption; import org.dllearner.core.IntegerConfigOption; @@ -63,6 +63,7 @@ private Score bestScore; private int maxLength = 7; + private String returnType; // list of all generated concepts sorted by length private Map<Integer,List<Concept>> generatedDefinitions = new HashMap<Integer,List<Concept>>(); @@ -80,6 +81,7 @@ public static Collection<ConfigOption<?>> createConfigOptions() { Collection<ConfigOption<?>> options = new LinkedList<ConfigOption<?>>(); options.add(new IntegerConfigOption("maxLength", "maximum length of generated concepts")); + options.add(CommonConfigOptions.getReturnType()); return options; } @@ -91,6 +93,8 @@ String name = entry.getOptionName(); if(name.equals("maxLength")) maxLength = (Integer) entry.getValue(); + else if(name.equals("returnType")) + returnType = (String) returnType; } /* (non-Javadoc) @@ -148,8 +152,8 @@ // if a return type is already given an appropriate tree is // generated here Concept newRoot; - if(!Config.returnType.equals("")) { - newRoot = new Conjunction(new AtomicConcept(Config.returnType),program); + if(returnType != null) { + newRoot = new Conjunction(new AtomicConcept(returnType),program); } else newRoot = program; Modified: trunk/src/dl-learner/org/dllearner/algorithms/gp/GP.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/gp/GP.java 2007-10-11 16:17:19 UTC (rev 215) +++ trunk/src/dl-learner/org/dllearner/algorithms/gp/GP.java 2007-10-11 18:35:03 UTC (rev 216) @@ -414,8 +414,9 @@ // nachschauen, ob ev. noch bessere Konzepte im Psi-Cache sind boolean betterValueFoundInPsiCache = false; - double bestValue = bestScore.getScore(); - if(Config.algorithm == Config.Algorithm.HYBRID_GP) { + double bestValue = bestScore.getScore(); + + if(Config.GP.refinementProbability > 0) { // das Problem ist hier, dass die gecachte Score nicht unbedingt // der echten Score entsprechen muss, d.h. hier muss die // Konzeptlänge mit einberechnet werden => deswegen werden @@ -445,7 +446,7 @@ System.out.println("runtime in ms: " + Helper.prettyPrintNanoSeconds(endTime - startTime)); System.out.println("fitness evaluations: " + GPUtilities.fitnessEvaluations); - if(Config.algorithm == Config.Algorithm.HYBRID_GP) { + if(refinementProbability > 0) { System.out.println("operator applications: " + psi.getNrOfRequests() + " psi, " + GPUtilities.crossover + " crossover, " + GPUtilities.mutation + " mutation, " + GPUtilities.hillClimbing + " hillClimbing"); } @@ -735,7 +736,7 @@ // System.out.println(); System.out.println("best definition found: " + n); - if(Config.algorithm == Config.Algorithm.HYBRID_GP) { + if(refinementProbability > 0) { double cacheHitRate=0; double pdCacheHitRate=0, puCacheHitRate=0; if(psi.getNrOfRequests()>0) { Modified: trunk/src/dl-learner/org/dllearner/algorithms/gp/GPUtilities.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/gp/GPUtilities.java 2007-10-11 16:17:19 UTC (rev 215) +++ trunk/src/dl-learner/org/dllearner/algorithms/gp/GPUtilities.java 2007-10-11 18:35:03 UTC (rev 216) @@ -68,22 +68,25 @@ private static Score calculateFitness(LearningProblem learningProblem, Concept hypothesis, Concept adc) { Concept extendedHypothesis; - if (!Config.returnType.equals("")) { - System.out.println("return type"); - - // newRoot.addChild(new AtomicConcept(Config.returnType)); - // newRoot.addChild(hypothesis); - Concept newRoot; - if(Config.GP.useMultiStructures) - newRoot = new MultiConjunction(new AtomicConcept(Config.returnType),hypothesis); - else - newRoot = new Conjunction(new AtomicConcept(Config.returnType),hypothesis); - // parent wieder auf null setzen, damit es nicht inkonsistent wird - // TODO: ist nicht wirklich elegant und auch inkompatibel mit - // dem Hill-Climbing-Operator - hypothesis.setParent(null); - extendedHypothesis = newRoot; - } else + // return type temporarily disabled + // => it is probably more appropriate to have the + // number of superclasses of a target concept + // as parameter of the learning problem +// +// if (!Config.returnType.equals("")) { +// System.out.println("return type"); +// +// Concept newRoot; +// if(Config.GP.useMultiStructures) +// newRoot = new MultiConjunction(new AtomicConcept(Config.returnType),hypothesis); +// else +// newRoot = new Conjunction(new AtomicConcept(Config.returnType),hypothesis); +// // parent wieder auf null setzen, damit es nicht inkonsistent wird +// // TODO: ist nicht wirklich elegant und auch inkompatibel mit +// // dem Hill-Climbing-Operator +// hypothesis.setParent(null); +// extendedHypothesis = newRoot; +// } else extendedHypothesis = hypothesis; Score score; @@ -459,7 +462,7 @@ // neutClassified.retainAll(posClassified); neutClassified.retainAll(negClassified); PosNegDefinitionLPStrict lp = (PosNegDefinitionLPStrict)learningProblem; - return new ScoreThreeValued(conceptLength, lp.getAccuracyPenalty(), lp.getErrorPenalty(), lp.isPenaliseNeutralExamples(), posClassified, neutClassified, negClassified, lp.getPositiveExamples(),lp.getNeutralExamples(),lp.getNegativeExamples()); + return new ScoreThreeValued(conceptLength, lp.getAccuracyPenalty(), lp.getErrorPenalty(), lp.isPenaliseNeutralExamples(), lp.getPercentPerLengthUnit(), posClassified, neutClassified, negClassified, lp.getPositiveExamples(),lp.getNeutralExamples(),lp.getNegativeExamples()); } // aktualisiert die besten Knoten Added: trunk/src/dl-learner/org/dllearner/algorithms/refinement/Heuristic.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refinement/Heuristic.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/algorithms/refinement/Heuristic.java 2007-10-11 18:35:03 UTC (rev 216) @@ -0,0 +1,35 @@ +/** + * Copyright (C) 2007, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package org.dllearner.algorithms.refinement; + +import java.util.Comparator; + +/** + * Marker interface for heuristics in the refinement operator + * based learning approach. A heuristic implements a method + * to decide which one of two given nodes seems to be more + * promising with respect to the learning problem we consider. + * + * @author Jens Lehmann + * + */ +public interface Heuristic extends Comparator<Node>{ + +} Modified: trunk/src/dl-learner/org/dllearner/algorithms/refinement/NodeComparator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refinement/NodeComparator.java 2007-10-11 16:17:19 UTC (rev 215) +++ trunk/src/dl-learner/org/dllearner/algorithms/refinement/NodeComparator.java 2007-10-11 18:35:03 UTC (rev 216) @@ -1,10 +1,8 @@ package org.dllearner.algorithms.refinement; -import java.util.Comparator; - import org.dllearner.utilities.ConceptComparator; -public class NodeComparator implements Comparator<Node> { +public class NodeComparator implements Heuristic { // Vergleich von Konzepten, falls alle anderen Kriterien fehlschlagen ConceptComparator conceptComparator = new ConceptComparator(); Modified: trunk/src/dl-learner/org/dllearner/algorithms/refinement/NodeComparator2.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refinement/NodeComparator2.java 2007-10-11 16:17:19 UTC (rev 215) +++ trunk/src/dl-learner/org/dllearner/algorithms/refinement/NodeComparator2.java 2007-10-11 18:35:03 UTC (rev 216) @@ -1,30 +1,62 @@ +/** + * Copyright (C) 2007, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + package org.dllearner.algorithms.refinement; -import java.util.Comparator; - -import org.dllearner.Config; import org.dllearner.utilities.ConceptComparator; /** + * This heuristic compares two nodes by computing a score + * using the number of covered negatives and the horizontal + * expansion factor of a node as input. Using this score + * it decides which one of the nodes seems to be more promising. + * The heuristic is flexible, because it offers a tradeoff + * between accurary and horizontal expansion (concept length). + * In contrast to the lexicographic heuristic this means that + * it sometimes prefers worse classifiers with low horizontal + * expansion over a better classifier with high horizontal + * expansion. * - * Die zweite Heuristik ist flexibel, das sie einen Tradeoff zwischen - * prozentualer Richtigkeit und horizontal expansion bietet (die - * Standardheuristik ist lexikographisch, d.h. ein schlecht klassifizierendes - * Konzept wird nie vorgezogen). + * It can be configured by using the "percentPerLenghtUnit" + * constructor argument. A higher + * value means that the algorithm is more likely to search in + * unexplored areas (= low horizontal expansion) of the search + * space vs. looking in promising but already explored (= high + * horizontal expansion) areas of the search space. * - * @author jl + * @author Jens Lehmann * */ -public class NodeComparator2 implements Comparator<Node> { +public class NodeComparator2 implements Heuristic { // Vergleich von Konzepten, falls alle anderen Kriterien fehlschlagen - ConceptComparator conceptComparator = new ConceptComparator(); - int nrOfNegativeExamples; + private ConceptComparator conceptComparator = new ConceptComparator(); + private int nrOfNegativeExamples; + private double percentPerLengthUnit; + // 5% sind eine Verlängerung um 1 wert // double percentPerLengthUnit = 0.05; - public NodeComparator2(int nrOfNegativeExamples) { + public NodeComparator2(int nrOfNegativeExamples, double percentPerLengthUnit) { this.nrOfNegativeExamples = nrOfNegativeExamples; + this.percentPerLengthUnit = percentPerLengthUnit; } // implementiert einfach die Definition in der Diplomarbeit @@ -35,10 +67,10 @@ // alle scores sind negativ, größere scores sind besser double score1 = -n1.getCoveredNegativeExamples()/(double)nrOfNegativeExamples; - score1 -= Config.percentPerLengthUnit * n1.getConcept().getLength(); + score1 -= percentPerLengthUnit * n1.getConcept().getLength(); double score2 = -n2.getCoveredNegativeExamples()/(double)nrOfNegativeExamples; - score2 -= Config.percentPerLengthUnit * n2.getConcept().getLength(); + score2 -= percentPerLengthUnit * n2.getConcept().getLength(); double diff = score1 - score2; Modified: trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2007-10-11 16:17:19 UTC (rev 215) +++ trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2007-10-11 18:35:03 UTC (rev 216) @@ -39,7 +39,7 @@ private boolean writeSearchTree; private File searchTreeFile; private static String defaultSearchTreeFile = "log/searchTree.txt"; - private Heuristic heuristic = Heuristic.LEXICOGRAPHIC; + private Heuristic heuristic = Heuristic.LEXICOGRAPHIC; private boolean stop = false; @@ -166,7 +166,7 @@ heuristic = Heuristic.LEXICOGRAPHIC; else heuristic = Heuristic.FLEXIBLE; - } + } } /* (non-Javadoc) @@ -181,7 +181,7 @@ if(heuristic == Heuristic.LEXICOGRAPHIC) nodeComparator = new NodeComparator(); else - nodeComparator = new NodeComparator2(learningProblem.getNegativeExamples().size()); + nodeComparator = new NodeComparator2(learningProblem.getNegativeExamples().size(), learningProblem.getPercentPerLengthUnit()); // TODO: this needs to be changed Helper.autoDetectConceptsAndRoles(rs); Modified: trunk/src/dl-learner/org/dllearner/core/CommonConfigOptions.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/CommonConfigOptions.java 2007-10-11 16:17:19 UTC (rev 215) +++ trunk/src/dl-learner/org/dllearner/core/CommonConfigOptions.java 2007-10-11 18:35:03 UTC (rev 216) @@ -38,4 +38,7 @@ return option; } + public static StringConfigOption getReturnType() { + return new StringConfigOption("returnType", "Specifies the type which the solution has to belong to (if already) known. This means we inform the learning algorithm that the solution is a subclass of this type."); + } } Modified: trunk/src/dl-learner/org/dllearner/core/LearningProblem.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/LearningProblem.java 2007-10-11 16:17:19 UTC (rev 215) +++ trunk/src/dl-learner/org/dllearner/core/LearningProblem.java 2007-10-11 18:35:03 UTC (rev 216) @@ -24,6 +24,18 @@ /** * Base class for all learning problems. * + * @todo The current learning problem implementations + * assume that we learn a concept, which does not exist + * in the knowledge base so far. However, often we want + * to learn a complex definition for a concept which + * is already integrated in a subsumption hierarchy. This + * means it would make sense to specifiy the list of these + * superclasses as an additional argument of the learning + * problem. The learning algorithms could then make use of + * this to optimise their search for a solution. (More + * generally, one could specify the name of the concept, which + * should be improved.) + * * @author Jens Lehmann * */ Modified: trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLP.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLP.java 2007-10-11 16:17:19 UTC (rev 215) +++ trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLP.java 2007-10-11 18:35:03 UTC (rev 216) @@ -170,7 +170,7 @@ if (!posClassified.contains(negExample)) negAsNeg.add(negExample); } - return new ScoreTwoValued(concept.getLength(), posAsPos, posAsNeg, negAsPos, negAsNeg); + return new ScoreTwoValued(concept.getLength(), percentPerLengthUnit, posAsPos, posAsNeg, negAsPos, negAsNeg); // instance checks for classification } else { SortedSet<Individual> posAsPos = new TreeSet<Individual>(); @@ -187,7 +187,7 @@ posAsNeg = Helper.intersection(positiveExamples, negClassified); negAsPos = Helper.intersection(negativeExamples, posClassified); negAsNeg = Helper.intersection(negativeExamples, negClassified); - return new ScoreTwoValued(concept.getLength(), posAsPos, posAsNeg, negAsPos, + return new ScoreTwoValued(concept.getLength(), percentPerLengthUnit, posAsPos, posAsNeg, negAsPos, negAsNeg); } else { @@ -203,7 +203,7 @@ else negAsNeg.add(example); } - return new ScoreTwoValued(concept.getLength(), posAsPos, posAsNeg, negAsPos, + return new ScoreTwoValued(concept.getLength(), percentPerLengthUnit, posAsPos, posAsNeg, negAsPos, negAsNeg); } } Modified: trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLPStrict.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLPStrict.java 2007-10-11 16:17:19 UTC (rev 215) +++ trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLPStrict.java 2007-10-11 18:35:03 UTC (rev 216) @@ -112,13 +112,13 @@ // this.defPosSet = tuple.getPosSet(); // this.defNegSet = tuple.getNegSet(); SortedSet<Individual> neutClassified = Helper.intersectionTuple(reasoningService.getIndividuals(),tuple); - return new ScoreThreeValued(concept.getLength(),accuracyPenalty, errorPenalty, penaliseNeutralExamples, tuple.getPosSet(),neutClassified,tuple.getNegSet(),positiveExamples,neutralExamples,negativeExamples); + return new ScoreThreeValued(concept.getLength(),accuracyPenalty, errorPenalty, penaliseNeutralExamples, percentPerLengthUnit, tuple.getPosSet(),neutClassified,tuple.getNegSet(),positiveExamples,neutralExamples,negativeExamples); } else if(reasoningService.getReasonerType() == ReasonerType.KAON2) { SortedSet<Individual> posClassified = reasoningService.retrieval(concept); SortedSet<Individual> negClassified = reasoningService.retrieval(new Negation(concept)); SortedSet<Individual> neutClassified = Helper.intersection(reasoningService.getIndividuals(),posClassified); neutClassified.retainAll(negClassified); - return new ScoreThreeValued(concept.getLength(), accuracyPenalty, errorPenalty, penaliseNeutralExamples, posClassified,neutClassified,negClassified,positiveExamples,neutralExamples,negativeExamples); + return new ScoreThreeValued(concept.getLength(), accuracyPenalty, errorPenalty, penaliseNeutralExamples, percentPerLengthUnit, posClassified,neutClassified,negClassified,positiveExamples,neutralExamples,negativeExamples); } else throw new Error("score cannot be computed in this configuration"); } else { @@ -158,7 +158,7 @@ SortedSet<Individual> neutClassified = Helper.intersection(reasoningService.getIndividuals(),posClassified); neutClassified.retainAll(negClassified); - return new ScoreThreeValued(concept.getLength(), accuracyPenalty, errorPenalty, penaliseNeutralExamples, posClassified,neutClassified,negClassified,positiveExamples,neutralExamples,negativeExamples); + return new ScoreThreeValued(concept.getLength(), accuracyPenalty, errorPenalty, penaliseNeutralExamples, percentPerLengthUnit, posClassified,neutClassified,negClassified,positiveExamples,neutralExamples,negativeExamples); } else throw new Error("score cannot be computed in this configuration"); } Modified: trunk/src/dl-learner/org/dllearner/learningproblems/PosNegLP.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/PosNegLP.java 2007-10-11 16:17:19 UTC (rev 215) +++ trunk/src/dl-learner/org/dllearner/learningproblems/PosNegLP.java 2007-10-11 18:35:03 UTC (rev 216) @@ -26,6 +26,7 @@ import org.dllearner.core.BooleanConfigOption; import org.dllearner.core.CommonConfigMappings; +import org.dllearner.core.CommonConfigOptions; import org.dllearner.core.ConfigEntry; import org.dllearner.core.ConfigOption; import org.dllearner.core.InvalidConfigOptionValueException; @@ -48,6 +49,7 @@ protected boolean useRetrievalForClassification = false; protected UseMultiInstanceChecks useDIGMultiInstanceChecks = UseMultiInstanceChecks.TWOCHECKS; + protected double percentPerLengthUnit = 0.05; /** * If instance checks are used for testing concepts (e.g. no retrieval), then @@ -87,6 +89,7 @@ "negative examples")); options.add(new BooleanConfigOption("useRetrievalForClassficiation", "Specifies whether to use retrieval or instance checks for testing a concept.")); + options.add(CommonConfigOptions.getPercentPerLenghtUnitOption(0.05)); return options; } @@ -107,6 +110,8 @@ .getIndividualSet((Set<String>) entry.getValue()); else if (name.equals("useRetrievalForClassification")) useRetrievalForClassification = (Boolean) entry.getValue(); + else if (name.equals("percentPerLengthUnit")) + percentPerLengthUnit = (Double) entry.getValue(); } /* @@ -128,5 +133,9 @@ } public abstract int coveredNegativeExamplesOrTooWeak(Concept concept); + + public double getPercentPerLengthUnit() { + return percentPerLengthUnit; + } } Modified: trunk/src/dl-learner/org/dllearner/learningproblems/ScoreThreeValued.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/ScoreThreeValued.java 2007-10-11 16:17:19 UTC (rev 215) +++ trunk/src/dl-learner/org/dllearner/learningproblems/ScoreThreeValued.java 2007-10-11 18:35:03 UTC (rev 216) @@ -24,7 +24,6 @@ import java.util.Set; import java.util.SortedSet; -import org.dllearner.Config; import org.dllearner.core.Score; import org.dllearner.core.dl.Individual; import org.dllearner.utilities.Helper; @@ -49,6 +48,7 @@ private double accuracyPenalty; private double errorPenalty; private boolean penaliseNeutralExamples; + private double percentPerLengthUnit; // potential configuration options (not implemented as such, but one // could so) @@ -85,6 +85,7 @@ double accuracyPenalty, double errorPenalty, boolean penaliseNeutralExamples, + double percentPerLengthUnit, SortedSet<Individual> posClassified, SortedSet<Individual> neutClassified, SortedSet<Individual> negClassified, @@ -94,6 +95,8 @@ this.conceptLength = conceptLength; this.accuracyPenalty = accuracyPenalty; this.errorPenalty = errorPenalty; + this.penaliseNeutralExamples = penaliseNeutralExamples; + this.percentPerLengthUnit = percentPerLengthUnit; this.posClassified = posClassified; this.neutClassified = neutClassified; this.negClassified = negClassified; @@ -136,7 +139,7 @@ double worstValue = nrOfExamples * errorPenalty; // ergibt Zahl zwischen -1 und 0 score = score / worstValue; - score -= Config.percentPerLengthUnit * conceptLength; + score -= percentPerLengthUnit * conceptLength; // die folgenden Berechnungen k�nnten aus Performancegr�nden auch // ausgegliedert werden @@ -229,7 +232,7 @@ @Override public Score getModifiedLengthScore(int newLength) { - return new ScoreThreeValued(newLength, accuracyPenalty, errorPenalty, penaliseNeutralExamples, posClassified, neutClassified, negClassified, posExamples, neutExamples, negExamples); + return new ScoreThreeValued(newLength, accuracyPenalty, errorPenalty, penaliseNeutralExamples, percentPerLengthUnit, posClassified, neutClassified, negClassified, posExamples, neutExamples, negExamples); } } Modified: trunk/src/dl-learner/org/dllearner/learningproblems/ScoreTwoValued.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/ScoreTwoValued.java 2007-10-11 16:17:19 UTC (rev 215) +++ trunk/src/dl-learner/org/dllearner/learningproblems/ScoreTwoValued.java 2007-10-11 18:35:03 UTC (rev 216) @@ -2,7 +2,6 @@ import java.util.Set; -import org.dllearner.Config; import org.dllearner.core.Score; import org.dllearner.core.dl.Individual; @@ -23,9 +22,11 @@ private double classificationScore; private int nrOfExamples; private int conceptLength; + private double percentPerLengthUnit; - public ScoreTwoValued(int conceptLength, Set<Individual> posAsPos, Set<Individual> posAsNeg, Set<Individual> negAsPos, Set<Individual> negAsNeg) { - this.conceptLength = conceptLength; + public ScoreTwoValued(int conceptLength, double percentPerLengthUnit, Set<Individual> posAsPos, Set<Individual> posAsNeg, Set<Individual> negAsPos, Set<Individual> negAsNeg) { + this.conceptLength = conceptLength; + this.percentPerLengthUnit = percentPerLengthUnit; this.posAsPos = posAsPos; this.posAsNeg = posAsNeg; this.negAsPos = negAsPos; @@ -40,7 +41,7 @@ // Anteil falscher Klassifikationen (Zahl zwischen -1 und 0) classificationScore = classificationScore / (double) nrOfExamples; // Berücksichtigung des Längenfaktors - score = classificationScore - Config.percentPerLengthUnit * conceptLength; + score = classificationScore - percentPerLengthUnit * conceptLength; } @Override @@ -82,6 +83,6 @@ @Override public Score getModifiedLengthScore(int newLength) { - return new ScoreTwoValued(newLength, posAsPos, posAsNeg, negAsPos, negAsNeg); + return new ScoreTwoValued(newLength, percentPerLengthUnit, posAsPos, posAsNeg, negAsPos, negAsNeg); } } Modified: trunk/src/dl-learner/org/dllearner/server/ClientState.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/ClientState.java 2007-10-11 16:17:19 UTC (rev 215) +++ trunk/src/dl-learner/org/dllearner/server/ClientState.java 2007-10-11 18:35:03 UTC (rev 216) @@ -28,7 +28,7 @@ public class ClientState { - private String reasonerURL="http://localhost:8081"; + // private String reasonerURL="http://localhost:8081"; //private String reasonerURL="http://localhost:3490"; private SortedSet<Individual> positiveExamples = new TreeSet<Individual>(); @@ -417,12 +417,12 @@ // Default-URI für DIG-Reasoner setzen - try { - Config.digReasonerURL = new URL(reasonerURL); - } catch (MalformedURLException e) { - // Exception tritt nie auf, da URL korrekt - e.printStackTrace(); - } +// try { +// Config.digReasonerURL = new URL(reasonerURL); +// } catch (MalformedURLException e) { +// // Exception tritt nie auf, da URL korrekt +// e.printStackTrace(); +// } // reasoner = Main.createReasoner(new KB(), m); System.err.println("TODO: rewrite webservice code"); Modified: trunk/src/dl-learner/org/dllearner/server/DLLearnerWSNew.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/DLLearnerWSNew.java 2007-10-11 16:17:19 UTC (rev 215) +++ trunk/src/dl-learner/org/dllearner/server/DLLearnerWSNew.java 2007-10-11 18:35:03 UTC (rev 216) @@ -100,6 +100,7 @@ } // returns the class which is referred to by the string + @SuppressWarnings({"unused"}) private Class<? extends Component> getComponent(String component) throws UnknownComponentException { if(knowledgeSourceMapping.containsKey(component)) return knowledgeSourceMapping.get(component); Modified: trunk/src/dl-learner/org/dllearner/server/DLLearnerWSoriginal.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/DLLearnerWSoriginal.java 2007-10-11 16:17:19 UTC (rev 215) +++ trunk/src/dl-learner/org/dllearner/server/DLLearnerWSoriginal.java 2007-10-11 18:35:03 UTC (rev 216) @@ -88,12 +88,12 @@ m.put(ontology, ofFormat); // Default-URI für DIG-Reasoner setzen - try { - Config.digReasonerURL = new URL("http://localhost:8081"); - } catch (MalformedURLException e) { - // Exception tritt nie auf, da URL korrekt - e.printStackTrace(); - } +// try { +// Config.digReasonerURL = new URL("http://localhost:8081"); +// } catch (MalformedURLException e) { +// // Exception tritt nie auf, da URL korrekt +// e.printStackTrace(); +// } // reasoner = Main.createReasoner(new KB(), m); Modified: trunk/src/dl-learner/org/dllearner/utilities/PaperStatistics.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/PaperStatistics.java 2007-10-11 16:17:19 UTC (rev 215) +++ trunk/src/dl-learner/org/dllearner/utilities/PaperStatistics.java 2007-10-11 18:35:03 UTC (rev 216) @@ -29,7 +29,6 @@ import org.dllearner.Config; import org.dllearner.ConfigurationManager; -import org.dllearner.Config.Algorithm; import org.dllearner.algorithms.gp.GP; import org.dllearner.core.ComponentManager; import org.dllearner.core.KnowledgeSource; @@ -215,15 +214,15 @@ LearningAlgorithm learningAlgorithm = null; if(algorithmNr==0) { - Config.algorithm = Algorithm.REFINEMENT; + // Config.algorithm = Algorithm.REFINEMENT; // Config.Refinement.heuristic = Config.Refinement.Heuristic.FLEXIBLE; Config.Refinement.horizontalExpansionFactor = 0.6; Config.Refinement.quiet = true; - Config.percentPerLengthUnit = 0.05; + // Config.percentPerLengthUnit = 0.05; // learningAlgorithm = new ROLearner(learningProblem); // learningAlgorithm = cm.learningAlgorithm(ROLearner.class, learningProblem); } else if(algorithmNr==1) { - Config.algorithm = Algorithm.GP; + // Config.algorithm = Algorithm.GP; Config.GP.algorithmType = GP.AlgorithmType.GENERATIONAL; Config.GP.selectionType = GP.SelectionType.RANK_SELECTION; Config.GP.generations = 50; @@ -235,15 +234,15 @@ Config.GP.mutationProbability = 0.02; Config.GP.crossoverProbability = 0.8; Config.GP.hillClimbingProbability = 0; - Config.percentPerLengthUnit = 0.005; + // Config.percentPerLengthUnit = 0.005; // give GP a chance to find the long solution of the // uncle problem - if(exampleNr==3 || exampleNr==5 || exampleNr == 6) - Config.percentPerLengthUnit = 0.002; + // if(exampleNr==3 || exampleNr==5 || exampleNr == 6) + // Config.percentPerLengthUnit = 0.002; // learningAlgorithm = new GP(learningProblem); learningAlgorithm = cm.learningAlgorithm(GP.class, learningProblem, rs); } else if(algorithmNr==2) { - Config.algorithm = Algorithm.HYBRID_GP; + // Config.algorithm = Algorithm.HYBRID_GP; Config.GP.algorithmType = GP.AlgorithmType.GENERATIONAL; Config.GP.selectionType = GP.SelectionType.RANK_SELECTION; Config.GP.generations = 50; @@ -255,9 +254,9 @@ Config.GP.mutationProbability = 0.02; Config.GP.crossoverProbability = 0.2; Config.GP.hillClimbingProbability = 0; - Config.percentPerLengthUnit = 0.005; - if(exampleNr == 3 || exampleNr==5 || exampleNr==6) - Config.percentPerLengthUnit = 0.002; + // Config.percentPerLengthUnit = 0.005; + // if(exampleNr == 3 || exampleNr==5 || exampleNr==6) +// Config.percentPerLengthUnit = 0.002; // learningAlgorithm = new GP(learningProblem); learningAlgorithm = cm.learningAlgorithm(GP.class, learningProblem, rs); } @@ -439,28 +438,28 @@ cm.applyConfigEntry(learningProblem, "negativeExamples", null); if (j == 0) { - Config.algorithm = Algorithm.HYBRID_GP; + // Config.algorithm = Algorithm.HYBRID_GP; Config.GP.numberOfIndividuals = i + 1; Config.GP.refinementProbability = 0.85; Config.GP.mutationProbability = 0.02; Config.GP.crossoverProbability = 0.05; Config.GP.hillClimbingProbability = 0; } else if (j == 1) { - Config.algorithm = Algorithm.HYBRID_GP; + // Config.algorithm = Algorithm.HYBRID_GP; Config.GP.numberOfIndividuals = i + 1; Config.GP.refinementProbability = 0.4; Config.GP.mutationProbability = 0.02; Config.GP.crossoverProbability = 0.4; Config.GP.hillClimbingProbability = 0; } else if (j == 2) { - Config.algorithm = Algorithm.GP; + // Config.algorithm = Algorithm.GP; Config.GP.numberOfIndividuals = i + 1; Config.GP.refinementProbability = 0; Config.GP.mutationProbability = 0.02; Config.GP.crossoverProbability = 0.8; Config.GP.hillClimbingProbability = 0; } else if (j == 3) { - Config.algorithm = Algorithm.HYBRID_GP; + // Config.algorithm = Algorithm.HYBRID_GP; Config.GP.numberOfIndividuals = i + 1; Config.GP.refinementProbability = 0.7; Config.GP.mutationProbability = 0.02; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2007-10-12 08:44:26
|
Revision: 218 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=218&view=rev Author: jenslehmann Date: 2007-10-12 01:44:21 -0700 (Fri, 12 Oct 2007) Log Message: ----------- - made another couple of options thread safe - implemented support for printing any KBElement with a base URI and prefixes Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/Config.java trunk/src/dl-learner/org/dllearner/ConfigurationManager.java trunk/src/dl-learner/org/dllearner/algorithms/gp/ADC.java trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java trunk/src/dl-learner/org/dllearner/core/CommonConfigOptions.java trunk/src/dl-learner/org/dllearner/core/dl/All.java trunk/src/dl-learner/org/dllearner/core/dl/AssertionalAxiom.java trunk/src/dl-learner/org/dllearner/core/dl/AtomicConcept.java trunk/src/dl-learner/org/dllearner/core/dl/AtomicRole.java trunk/src/dl-learner/org/dllearner/core/dl/Axiom.java trunk/src/dl-learner/org/dllearner/core/dl/Bottom.java trunk/src/dl-learner/org/dllearner/core/dl/Concept.java trunk/src/dl-learner/org/dllearner/core/dl/ConceptAssertion.java trunk/src/dl-learner/org/dllearner/core/dl/Conjunction.java trunk/src/dl-learner/org/dllearner/core/dl/Disjunction.java trunk/src/dl-learner/org/dllearner/core/dl/Equality.java trunk/src/dl-learner/org/dllearner/core/dl/Exists.java trunk/src/dl-learner/org/dllearner/core/dl/FunctionalRoleAxiom.java trunk/src/dl-learner/org/dllearner/core/dl/GreaterEqual.java trunk/src/dl-learner/org/dllearner/core/dl/Inclusion.java trunk/src/dl-learner/org/dllearner/core/dl/Individual.java trunk/src/dl-learner/org/dllearner/core/dl/InverseRole.java trunk/src/dl-learner/org/dllearner/core/dl/InverseRoleAxiom.java trunk/src/dl-learner/org/dllearner/core/dl/KB.java trunk/src/dl-learner/org/dllearner/core/dl/KBElement.java trunk/src/dl-learner/org/dllearner/core/dl/LessEqual.java trunk/src/dl-learner/org/dllearner/core/dl/MultiConjunction.java trunk/src/dl-learner/org/dllearner/core/dl/MultiDisjunction.java trunk/src/dl-learner/org/dllearner/core/dl/Negation.java trunk/src/dl-learner/org/dllearner/core/dl/Quantification.java trunk/src/dl-learner/org/dllearner/core/dl/RBoxAxiom.java trunk/src/dl-learner/org/dllearner/core/dl/Role.java trunk/src/dl-learner/org/dllearner/core/dl/RoleAssertion.java trunk/src/dl-learner/org/dllearner/core/dl/SubRoleAxiom.java trunk/src/dl-learner/org/dllearner/core/dl/SymmetricRoleAxiom.java trunk/src/dl-learner/org/dllearner/core/dl/TerminologicalAxiom.java trunk/src/dl-learner/org/dllearner/core/dl/Top.java trunk/src/dl-learner/org/dllearner/core/dl/TransitiveRoleAxiom.java trunk/src/dl-learner/org/dllearner/reasoning/KAON2Reasoner.java trunk/src/dl-learner/org/dllearner/utilities/Helper.java Modified: trunk/src/dl-learner/org/dllearner/Config.java =================================================================== --- trunk/src/dl-learner/org/dllearner/Config.java 2007-10-12 08:17:02 UTC (rev 217) +++ trunk/src/dl-learner/org/dllearner/Config.java 2007-10-12 08:44:21 UTC (rev 218) @@ -1,8 +1,6 @@ package org.dllearner; import java.lang.reflect.Field; -import java.util.LinkedList; -import java.util.List; import java.util.Set; import org.dllearner.algorithms.gp.GP.AlgorithmType; @@ -80,22 +78,22 @@ // public static URL digReasonerURL = null; // unique names assumption - public static boolean una = false; + // public static boolean una = false; // open world assumption; momentan wird closed world assumption nur // fuer Rollen unterstuetzt - public static boolean owa = true; + // public static boolean owa = true; // an-/abschalten von System.nanoTime()-Aufrufen außerhalb des // Reasoningservice - public static boolean useNonReasonerBenchmarks = false; + // public static boolean useNonReasonerBenchmarks = false; // erlaubt das abschalten von Benchmarks bei der Subsumptionhierarchie, // da diese ohnehin gecacht wird, also die System.nanoTime()-Aufrufe nur // Zeit kosten // public static boolean useHierarchyReasonerBenchmarks = false; - public static List<String> hidePrefixes = new LinkedList<String>(); + // public static List<String> hidePrefixes = new LinkedList<String>(); // Informationen (Rollen, Konzepte, Individuen, Anzahl Axiome) über // Wissensbasis anzeigen => alles konfigurierbar um Output in Grenzen Modified: trunk/src/dl-learner/org/dllearner/ConfigurationManager.java =================================================================== --- trunk/src/dl-learner/org/dllearner/ConfigurationManager.java 2007-10-12 08:17:02 UTC (rev 217) +++ trunk/src/dl-learner/org/dllearner/ConfigurationManager.java 2007-10-12 08:44:21 UTC (rev 218) @@ -86,7 +86,7 @@ // } // der parserinterne Namespace wird immer ausgeblendet - Config.hidePrefixes.add(KBParser.internalNamespace); + ; // Config.hidePrefixes.add(KBParser.internalNamespace); } @@ -422,9 +422,9 @@ else if (option.equals("statMode")) ; // Config.statisticMode = Datastructures.strToBool(value); else if (option.equals("una")) - Config.una = Datastructures.strToBool(value); + ; // Config.una = Datastructures.strToBool(value); else if (option.equals("owa")) - Config.owa = Datastructures.strToBool(value); + ; // Config.owa = Datastructures.strToBool(value); else if (option.equals("gp.useFixedNumberOfGenerations")) Config.GP.useFixedNumberOfGenerations = Datastructures.strToBool(value); // else if (option.equals("scoreMethod")) { @@ -452,7 +452,7 @@ // Config.GP.mutationProbability = 0.0d; // } else if(option.equals("hidePrefix")) { - Config.hidePrefixes.add(value); +// Config.hidePrefixes.add(value); } else if (option.equals("showIndividuals")) { Config.showIndividuals = Datastructures.strToBool(value); } else if (option.equals("showConcepts")) { Modified: trunk/src/dl-learner/org/dllearner/algorithms/gp/ADC.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/gp/ADC.java 2007-10-12 08:17:02 UTC (rev 217) +++ trunk/src/dl-learner/org/dllearner/algorithms/gp/ADC.java 2007-10-12 08:44:21 UTC (rev 218) @@ -1,5 +1,7 @@ package org.dllearner.algorithms.gp; +import java.util.Map; + import org.dllearner.core.dl.Concept; public class ADC extends Concept { @@ -19,8 +21,7 @@ return 1; } - @Override - public String toString() { + public String toString(String baseURI, Map<String,String> prefixes) { return "ADC"; } Modified: trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2007-10-12 08:17:02 UTC (rev 217) +++ trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2007-10-12 08:44:21 UTC (rev 218) @@ -126,12 +126,7 @@ this.learningProblem = learningProblem; this.rs = rs; - // this.learningProblem2 = learningProblem2; - operator = new RhoDown(learningProblem); - - // candidate sets entsprechend der gewählten Heuristik initialisieren - candidates = new TreeSet<Node>(nodeComparator); - // newCandidates = new TreeSet<Node>(nodeComparator); + } public static Collection<Class<? extends LearningProblem>> supportedLearningProblems() { @@ -183,6 +178,13 @@ else nodeComparator = new NodeComparator2(learningProblem.getNegativeExamples().size(), learningProblem.getPercentPerLengthUnit()); + // this.learningProblem2 = learningProblem2; + operator = new RhoDown(learningProblem); + + // candidate sets entsprechend der gewählten Heuristik initialisieren + candidates = new TreeSet<Node>(nodeComparator); + // newCandidates = new TreeSet<Node>(nodeComparator); + // TODO: this needs to be changed Helper.autoDetectConceptsAndRoles(rs); // prepare subsumption and role hierarchies, because they are needed Modified: trunk/src/dl-learner/org/dllearner/core/CommonConfigOptions.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/CommonConfigOptions.java 2007-10-12 08:17:02 UTC (rev 217) +++ trunk/src/dl-learner/org/dllearner/core/CommonConfigOptions.java 2007-10-12 08:44:21 UTC (rev 218) @@ -41,4 +41,12 @@ public static StringConfigOption getReturnType() { return new StringConfigOption("returnType", "Specifies the type which the solution has to belong to (if already) known. This means we inform the learning algorithm that the solution is a subclass of this type."); } + + public static BooleanConfigOption getUNA() { + return new BooleanConfigOption("una", "unique names assumption", false); + } + + public static BooleanConfigOption getOWA() { + return new BooleanConfigOption("owa", "open world assumption (if set to false, we try to close the world", true); + } } Modified: trunk/src/dl-learner/org/dllearner/core/dl/All.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/dl/All.java 2007-10-12 08:17:02 UTC (rev 217) +++ trunk/src/dl-learner/org/dllearner/core/dl/All.java 2007-10-12 08:44:21 UTC (rev 218) @@ -1,6 +1,8 @@ package org.dllearner.core.dl; +import java.util.Map; + public class All extends Quantification { public All(Role role, Concept c) { @@ -83,10 +85,9 @@ return true; } */ - - @Override - public String toString() { - return "ALL " + role + "." + children.get(0).toString(); + + public String toString(String baseURI, Map<String,String> prefixes) { + return "ALL " + role + "." + children.get(0).toString(baseURI, prefixes); } /* Modified: trunk/src/dl-learner/org/dllearner/core/dl/AssertionalAxiom.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/dl/AssertionalAxiom.java 2007-10-12 08:17:02 UTC (rev 217) +++ trunk/src/dl-learner/org/dllearner/core/dl/AssertionalAxiom.java 2007-10-12 08:44:21 UTC (rev 218) @@ -1,5 +1,5 @@ package org.dllearner.core.dl; -public interface AssertionalAxiom extends Axiom { +public abstract class AssertionalAxiom extends Axiom { } Modified: trunk/src/dl-learner/org/dllearner/core/dl/AtomicConcept.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/dl/AtomicConcept.java 2007-10-12 08:17:02 UTC (rev 217) +++ trunk/src/dl-learner/org/dllearner/core/dl/AtomicConcept.java 2007-10-12 08:44:21 UTC (rev 218) @@ -1,5 +1,7 @@ package org.dllearner.core.dl; +import java.util.Map; + import org.dllearner.utilities.Helper; @@ -34,11 +36,11 @@ public String toString() { // es soll ein Prefix ausgeblendet werden um Konzepte // lesbarer zu machen (z.B. http://blabla.org/bla/bla#eigentlicher Name - String prefixToHide = Helper.findPrefixToHide(name); - - if(prefixToHide != null) - return name.substring(prefixToHide.length()); - else +// String prefixToHide = Helper.findPrefixToHide(name); +// +// if(prefixToHide != null) +// return name.substring(prefixToHide.length()); +// else return name; } @@ -51,4 +53,8 @@ return 0; } + public String toString(String baseURI, Map<String,String> prefixes) { + return Helper.getAbbreviatedString(name, baseURI, prefixes); + } + } Modified: trunk/src/dl-learner/org/dllearner/core/dl/AtomicRole.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/dl/AtomicRole.java 2007-10-12 08:17:02 UTC (rev 217) +++ trunk/src/dl-learner/org/dllearner/core/dl/AtomicRole.java 2007-10-12 08:44:21 UTC (rev 218) @@ -1,5 +1,7 @@ package org.dllearner.core.dl; +import java.util.Map; + import org.dllearner.utilities.Helper; public class AtomicRole extends Role { @@ -15,12 +17,16 @@ @Override public String toString() { - String name = getName(); - String prefixToHide = Helper.findPrefixToHide(name); - - if(prefixToHide != null) - return name.substring(prefixToHide.length()); - else +// String name = getName(); +// String prefixToHide = Helper.findPrefixToHide(name); +// +// if(prefixToHide != null) +// return name.substring(prefixToHide.length()); +// else return name; } + + public String toString(String baseURI, Map<String,String> prefixes) { + return Helper.getAbbreviatedString(name, baseURI, prefixes); + } } Modified: trunk/src/dl-learner/org/dllearner/core/dl/Axiom.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/dl/Axiom.java 2007-10-12 08:17:02 UTC (rev 217) +++ trunk/src/dl-learner/org/dllearner/core/dl/Axiom.java 2007-10-12 08:44:21 UTC (rev 218) @@ -1,5 +1,10 @@ package org.dllearner.core.dl; -public interface Axiom extends KBElement { +public abstract class Axiom implements KBElement { + @Override + public String toString() { + return toString(null, null); + } + } Modified: trunk/src/dl-learner/org/dllearner/core/dl/Bottom.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/dl/Bottom.java 2007-10-12 08:17:02 UTC (rev 217) +++ trunk/src/dl-learner/org/dllearner/core/dl/Bottom.java 2007-10-12 08:44:21 UTC (rev 218) @@ -1,7 +1,9 @@ package org.dllearner.core.dl; +import java.util.Map; + public class Bottom extends Concept { /* @@ -11,8 +13,8 @@ negSet = abox.top; } */ - @Override - public String toString() { + + public String toString(String baseURI, Map<String,String> prefixes) { return "BOTTOM"; } Modified: trunk/src/dl-learner/org/dllearner/core/dl/Concept.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/dl/Concept.java 2007-10-12 08:17:02 UTC (rev 217) +++ trunk/src/dl-learner/org/dllearner/core/dl/Concept.java 2007-10-12 08:44:21 UTC (rev 218) @@ -269,4 +269,10 @@ public Concept getChild(int i) { return children.get(i); } + + @Override + public String toString() { + return toString(null, null); + } + } Modified: trunk/src/dl-learner/org/dllearner/core/dl/ConceptAssertion.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/dl/ConceptAssertion.java 2007-10-12 08:17:02 UTC (rev 217) +++ trunk/src/dl-learner/org/dllearner/core/dl/ConceptAssertion.java 2007-10-12 08:44:21 UTC (rev 218) @@ -1,6 +1,8 @@ package org.dllearner.core.dl; -public class ConceptAssertion implements AssertionalAxiom { +import java.util.Map; + +public class ConceptAssertion extends AssertionalAxiom { private Concept concept; private Individual individual; @@ -21,9 +23,8 @@ public int getLength() { return 1 + concept.getLength(); } - - @Override - public String toString() { - return concept.toString() + "(" + individual + ")"; + + public String toString(String baseURI, Map<String,String> prefixes) { + return concept.toString(baseURI, prefixes) + "(" + individual + ")"; } } Modified: trunk/src/dl-learner/org/dllearner/core/dl/Conjunction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/dl/Conjunction.java 2007-10-12 08:17:02 UTC (rev 217) +++ trunk/src/dl-learner/org/dllearner/core/dl/Conjunction.java 2007-10-12 08:44:21 UTC (rev 218) @@ -1,7 +1,9 @@ package org.dllearner.core.dl; +import java.util.Map; + public class Conjunction extends Concept { /* @@ -20,9 +22,8 @@ addChild(c2); } - @Override - public String toString() { - return "(" + children.get(0).toString() + " AND " + children.get(1).toString() + ")"; + public String toString(String baseURI, Map<String,String> prefixes) { + return "(" + children.get(0).toString(baseURI, prefixes) + " AND " + children.get(1).toString(baseURI, prefixes) + ")"; } public int getLength() { Modified: trunk/src/dl-learner/org/dllearner/core/dl/Disjunction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/dl/Disjunction.java 2007-10-12 08:17:02 UTC (rev 217) +++ trunk/src/dl-learner/org/dllearner/core/dl/Disjunction.java 2007-10-12 08:44:21 UTC (rev 218) @@ -1,6 +1,8 @@ package org.dllearner.core.dl; +import java.util.Map; + public class Disjunction extends Concept { /* @@ -19,9 +21,8 @@ addChild(c2); } - @Override - public String toString() { - return "(" + children.get(0).toString() + " OR " + children.get(1).toString() + ")"; + public String toString(String baseURI, Map<String,String> prefixes) { + return "(" + children.get(0).toString(baseURI, prefixes) + " OR " + children.get(1).toString(baseURI, prefixes) + ")"; } public int getLength() { Modified: trunk/src/dl-learner/org/dllearner/core/dl/Equality.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/dl/Equality.java 2007-10-12 08:17:02 UTC (rev 217) +++ trunk/src/dl-learner/org/dllearner/core/dl/Equality.java 2007-10-12 08:44:21 UTC (rev 218) @@ -1,6 +1,8 @@ package org.dllearner.core.dl; -public class Equality implements TerminologicalAxiom { +import java.util.Map; + +public class Equality extends TerminologicalAxiom { private Concept concept1; private Concept concept2; @@ -21,9 +23,8 @@ public int getLength() { return 1 + concept1.getLength() + concept2.getLength(); } - - @Override - public String toString() { - return concept1.toString() + " = " + concept2.toString(); + + public String toString(String baseURI, Map<String,String> prefixes) { + return concept1.toString(baseURI, prefixes) + " = " + concept2.toString(baseURI, prefixes); } } Modified: trunk/src/dl-learner/org/dllearner/core/dl/Exists.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/dl/Exists.java 2007-10-12 08:17:02 UTC (rev 217) +++ trunk/src/dl-learner/org/dllearner/core/dl/Exists.java 2007-10-12 08:44:21 UTC (rev 218) @@ -1,6 +1,8 @@ package org.dllearner.core.dl; +import java.util.Map; + public class Exists extends Quantification { public Exists(Role role, Concept c) { @@ -85,9 +87,8 @@ } */ - @Override - public String toString() { - return "EXISTS " + role + "." + children.get(0).toString(); + public String toString(String baseURI, Map<String,String> prefixes) { + return "EXISTS " + role.toString(baseURI, prefixes) + "." + children.get(0).toString(baseURI, prefixes); } /* Modified: trunk/src/dl-learner/org/dllearner/core/dl/FunctionalRoleAxiom.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/dl/FunctionalRoleAxiom.java 2007-10-12 08:17:02 UTC (rev 217) +++ trunk/src/dl-learner/org/dllearner/core/dl/FunctionalRoleAxiom.java 2007-10-12 08:44:21 UTC (rev 218) @@ -1,7 +1,9 @@ package org.dllearner.core.dl; -public class FunctionalRoleAxiom implements RBoxAxiom { +import java.util.Map; +public class FunctionalRoleAxiom extends RBoxAxiom { + private AtomicRole role; public FunctionalRoleAxiom(AtomicRole role) { @@ -15,9 +17,8 @@ public int getLength() { return 1 + role.getLength(); } - - @Override - public String toString() { - return "Functional(" + role.toString() + ")"; + + public String toString(String baseURI, Map<String,String> prefixes) { + return "Functional(" + role.toString(baseURI, prefixes) + ")"; } } Modified: trunk/src/dl-learner/org/dllearner/core/dl/GreaterEqual.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/dl/GreaterEqual.java 2007-10-12 08:17:02 UTC (rev 217) +++ trunk/src/dl-learner/org/dllearner/core/dl/GreaterEqual.java 2007-10-12 08:44:21 UTC (rev 218) @@ -1,5 +1,7 @@ package org.dllearner.core.dl; +import java.util.Map; + public class GreaterEqual extends NumberRestriction { public GreaterEqual(int number, Role role, Concept c) { @@ -11,8 +13,7 @@ return 1; } - @Override - public String toString() { - return ">= " + number + " " + role + " " + getChild(0); + public String toString(String baseURI, Map<String,String> prefixes) { + return ">= " + number + " " + role.toString(baseURI, prefixes) + " " + getChild(0).toString(baseURI, prefixes); } } Modified: trunk/src/dl-learner/org/dllearner/core/dl/Inclusion.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/dl/Inclusion.java 2007-10-12 08:17:02 UTC (rev 217) +++ trunk/src/dl-learner/org/dllearner/core/dl/Inclusion.java 2007-10-12 08:44:21 UTC (rev 218) @@ -1,6 +1,8 @@ package org.dllearner.core.dl; -public class Inclusion implements TerminologicalAxiom { +import java.util.Map; + +public class Inclusion extends TerminologicalAxiom { private Concept subConcept; private Concept superConcept; @@ -22,8 +24,7 @@ return 1 + subConcept.getLength() + superConcept.getLength(); } - @Override - public String toString() { - return subConcept.toString() + " SUBCONCEPTOF " + superConcept.toString(); + public String toString(String baseURI, Map<String,String> prefixes) { + return subConcept.toString(baseURI, prefixes) + " SUBCONCEPTOF " + superConcept.toString(baseURI, prefixes); } } Modified: trunk/src/dl-learner/org/dllearner/core/dl/Individual.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/dl/Individual.java 2007-10-12 08:17:02 UTC (rev 217) +++ trunk/src/dl-learner/org/dllearner/core/dl/Individual.java 2007-10-12 08:44:21 UTC (rev 218) @@ -1,5 +1,7 @@ package org.dllearner.core.dl; +import java.util.Map; + import org.dllearner.utilities.Helper; /** @@ -40,11 +42,11 @@ @Override public String toString() { - String prefixToHide = Helper.findPrefixToHide(name); - - if(prefixToHide != null) - return name.substring(prefixToHide.length()); - else +// String prefixToHide = Helper.findPrefixToHide(name); +// +// if(prefixToHide != null) +// return name.substring(prefixToHide.length()); +// else return name; } @@ -56,6 +58,9 @@ public boolean equals(Object o) { return (compareTo((Individual)o)==0); } + + public String toString(String baseURI, Map<String,String> prefixes) { + return Helper.getAbbreviatedString(name, baseURI, prefixes); + } - } Modified: trunk/src/dl-learner/org/dllearner/core/dl/InverseRole.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/dl/InverseRole.java 2007-10-12 08:17:02 UTC (rev 217) +++ trunk/src/dl-learner/org/dllearner/core/dl/InverseRole.java 2007-10-12 08:44:21 UTC (rev 218) @@ -1,14 +1,33 @@ +/** + * Copyright (C) 2007, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + package org.dllearner.core.dl; +import java.util.Map; + +import org.dllearner.utilities.Helper; + /** - * TODO: nochmal ueberlegen, ob es sinnvoll ist, dass InverseRole von - * Role erbt; ev. besser trennen oder ein eine gemeinsame Oberklasse - * von beiden; genau wie Concept alle Konzeptkonstruktoren zusammenfasst, - * koennte Role alle Rollenkonstruktoren zusammenfassen + * An inverse role. * - * Role => Unterklassen: AtomicRole, InverseRole - * - * @author jl + * @author Jens Lehmann * */ public class InverseRole extends Role { @@ -18,12 +37,10 @@ } public int getLength() { - // TODO Auto-generated method stub return 2; } - - @Override - public String toString() { - return getName() + "-"; + + public String toString(String baseURI, Map<String,String> prefixes) { + return Helper.getAbbreviatedString(name, baseURI, prefixes) + "-"; } } Modified: trunk/src/dl-learner/org/dllearner/core/dl/InverseRoleAxiom.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/dl/InverseRoleAxiom.java 2007-10-12 08:17:02 UTC (rev 217) +++ trunk/src/dl-learner/org/dllearner/core/dl/InverseRoleAxiom.java 2007-10-12 08:44:21 UTC (rev 218) @@ -1,7 +1,9 @@ package org.dllearner.core.dl; -public class InverseRoleAxiom implements RBoxAxiom { +import java.util.Map; +public class InverseRoleAxiom extends RBoxAxiom { + private AtomicRole inverseRole; private AtomicRole role; @@ -22,8 +24,7 @@ return 1 + role.getLength() + inverseRole.getLength(); } - @Override - public String toString() { - return "Inverse(" + inverseRole + "," + role.toString() + ")"; + public String toString(String baseURI, Map<String,String> prefixes) { + return "Inverse(" + inverseRole + "," + role.toString(baseURI, prefixes) + ")"; } } Modified: trunk/src/dl-learner/org/dllearner/core/dl/KB.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/dl/KB.java 2007-10-12 08:17:02 UTC (rev 217) +++ trunk/src/dl-learner/org/dllearner/core/dl/KB.java 2007-10-12 08:44:21 UTC (rev 218) @@ -1,6 +1,7 @@ package org.dllearner.core.dl; import java.util.HashSet; +import java.util.Map; import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; @@ -155,22 +156,20 @@ length += a.getLength(); return length; } - - @Override - public String toString() { + + public String toString(String baseURI, Map<String,String> prefixes) { String str = "TBox["+tbox.size()+"]:\n"; for(Axiom a : tbox) - str += " " + a.toString()+"\n"; + str += " " + a.toString(baseURI, prefixes)+"\n"; str += "RBox["+rbox.size()+"]:\n"; for(Axiom a : rbox) - str += " " + a.toString()+"\n"; + str += " " + a.toString(baseURI, prefixes)+"\n"; str += "ABox["+abox.size()+"]:\n"; for(Axiom a : abox) - str += " " + a.toString()+"\n"; + str += " " + a.toString(baseURI, prefixes)+"\n"; return str; } - public Set<Individual> findRelatedIndividuals(Individual individual) { return findRelatedIndividuals(individual, new TreeSet<Individual>()); } Modified: trunk/src/dl-learner/org/dllearner/core/dl/KBElement.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/dl/KBElement.java 2007-10-12 08:17:02 UTC (rev 217) +++ trunk/src/dl-learner/org/dllearner/core/dl/KBElement.java 2007-10-12 08:44:21 UTC (rev 218) @@ -1,10 +1,16 @@ package org.dllearner.core.dl; +import java.util.Map; + /** - * Interface fuer alle Elemente der Wissensbasis. - * @author jl + * Interface for all elements of the knowledge base. + * + * @author Jens Lehmann * */ public interface KBElement { + public int getLength(); + + public String toString(String baseURI, Map<String,String> prefixes); } Modified: trunk/src/dl-learner/org/dllearner/core/dl/LessEqual.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/dl/LessEqual.java 2007-10-12 08:17:02 UTC (rev 217) +++ trunk/src/dl-learner/org/dllearner/core/dl/LessEqual.java 2007-10-12 08:44:21 UTC (rev 218) @@ -1,5 +1,7 @@ package org.dllearner.core.dl; +import java.util.Map; + public class LessEqual extends NumberRestriction { public LessEqual(int number, Role role, Concept c) { @@ -11,8 +13,7 @@ return 1; } - @Override - public String toString() { - return "<= " + number + " " + role + " " + getChild(0); + public String toString(String baseURI, Map<String,String> prefixes) { + return "<= " + number + " " + role.toString(baseURI, prefixes) + " " + getChild(0).toString(baseURI, prefixes); } } Modified: trunk/src/dl-learner/org/dllearner/core/dl/MultiConjunction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/dl/MultiConjunction.java 2007-10-12 08:17:02 UTC (rev 217) +++ trunk/src/dl-learner/org/dllearner/core/dl/MultiConjunction.java 2007-10-12 08:44:21 UTC (rev 218) @@ -1,6 +1,7 @@ package org.dllearner.core.dl; import java.util.List; +import java.util.Map; public class MultiConjunction extends Concept { @@ -33,16 +34,15 @@ return length + children.size() - 1; } - @Override - public String toString() { + public String toString(String baseURI, Map<String,String> prefixes) { if(children.size()==0) return "EMPTY_AND"; String ret = "("; for(int i=0; i<children.size()-1; i++) { - ret += children.get(i).toString() + " AND "; + ret += children.get(i).toString(baseURI, prefixes) + " AND "; } - ret += children.get(children.size()-1).toString() + ")"; + ret += children.get(children.size()-1).toString(baseURI, prefixes) + ")"; return ret; } Modified: trunk/src/dl-learner/org/dllearner/core/dl/MultiDisjunction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/dl/MultiDisjunction.java 2007-10-12 08:17:02 UTC (rev 217) +++ trunk/src/dl-learner/org/dllearner/core/dl/MultiDisjunction.java 2007-10-12 08:44:21 UTC (rev 218) @@ -1,6 +1,7 @@ package org.dllearner.core.dl; import java.util.List; +import java.util.Map; public class MultiDisjunction extends Concept { @@ -34,17 +35,16 @@ } return length + children.size() - 1; } - - @Override - public String toString() { + + public String toString(String baseURI, Map<String,String> prefixes) { if(children.size()==0) return "EMPTY_OR"; String ret = "("; for(int i=0; i<children.size()-1; i++) { - ret += children.get(i).toString() + " OR "; + ret += children.get(i).toString(baseURI, prefixes) + " OR "; } - ret += children.get(children.size()-1).toString() + ")"; + ret += children.get(children.size()-1).toString(baseURI, prefixes) + ")"; return ret; } Modified: trunk/src/dl-learner/org/dllearner/core/dl/Negation.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/dl/Negation.java 2007-10-12 08:17:02 UTC (rev 217) +++ trunk/src/dl-learner/org/dllearner/core/dl/Negation.java 2007-10-12 08:44:21 UTC (rev 218) @@ -1,6 +1,8 @@ package org.dllearner.core.dl; +import java.util.Map; + public class Negation extends Concept { /* @@ -16,9 +18,8 @@ addChild(c); } - @Override - public String toString() { - return "(NOT " +children.get(0).toString() + ")"; + public String toString(String baseURI, Map<String,String> prefixes) { + return "(NOT " +children.get(0).toString(baseURI, prefixes) + ")"; } public int getLength() { Modified: trunk/src/dl-learner/org/dllearner/core/dl/Quantification.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/dl/Quantification.java 2007-10-12 08:17:02 UTC (rev 217) +++ trunk/src/dl-learner/org/dllearner/core/dl/Quantification.java 2007-10-12 08:44:21 UTC (rev 218) @@ -1,6 +1,6 @@ package org.dllearner.core.dl; -public class Quantification extends Concept { +public abstract class Quantification extends Concept { Role role; Modified: trunk/src/dl-learner/org/dllearner/core/dl/RBoxAxiom.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/dl/RBoxAxiom.java 2007-10-12 08:17:02 UTC (rev 217) +++ trunk/src/dl-learner/org/dllearner/core/dl/RBoxAxiom.java 2007-10-12 08:44:21 UTC (rev 218) @@ -1,5 +1,5 @@ package org.dllearner.core.dl; -public interface RBoxAxiom extends Axiom { +public abstract class RBoxAxiom extends Axiom { } Modified: trunk/src/dl-learner/org/dllearner/core/dl/Role.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/dl/Role.java 2007-10-12 08:17:02 UTC (rev 217) +++ trunk/src/dl-learner/org/dllearner/core/dl/Role.java 2007-10-12 08:44:21 UTC (rev 218) @@ -1,8 +1,10 @@ package org.dllearner.core.dl; +import java.util.Map; + public abstract class Role implements KBElement { - private String name; + protected String name; public Role(String name) { this.name = name; @@ -11,4 +13,5 @@ public String getName() { return name; } + } Modified: trunk/src/dl-learner/org/dllearner/core/dl/RoleAssertion.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/dl/RoleAssertion.java 2007-10-12 08:17:02 UTC (rev 217) +++ trunk/src/dl-learner/org/dllearner/core/dl/RoleAssertion.java 2007-10-12 08:44:21 UTC (rev 218) @@ -1,7 +1,9 @@ package org.dllearner.core.dl; -public class RoleAssertion implements AssertionalAxiom { +import java.util.Map; +public class RoleAssertion extends AssertionalAxiom { + private AtomicRole role; private Individual individual1; private Individual individual2; @@ -28,8 +30,7 @@ return 2 + role.getLength(); } - @Override - public String toString() { - return role.toString() + "(" + individual1 + "," + individual2 +")"; + public String toString(String baseURI, Map<String,String> prefixes) { + return role.toString(baseURI, prefixes) + "(" + individual1.toString(baseURI, prefixes) + "," + individual2.toString(baseURI, prefixes) +")"; } } Modified: trunk/src/dl-learner/org/dllearner/core/dl/SubRoleAxiom.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/dl/SubRoleAxiom.java 2007-10-12 08:17:02 UTC (rev 217) +++ trunk/src/dl-learner/org/dllearner/core/dl/SubRoleAxiom.java 2007-10-12 08:44:21 UTC (rev 218) @@ -1,7 +1,9 @@ package org.dllearner.core.dl; -public class SubRoleAxiom implements RBoxAxiom { +import java.util.Map; +public class SubRoleAxiom extends RBoxAxiom { + private AtomicRole role; private AtomicRole subRole; @@ -21,9 +23,8 @@ public int getLength() { return 1 + role.getLength() + subRole.getLength(); } - - @Override - public String toString() { - return "Subrole(" + subRole + "," + role.toString() + ")"; + + public String toString(String baseURI, Map<String,String> prefixes) { + return "Subrole(" + subRole.toString(baseURI, prefixes) + "," + role.toString(baseURI, prefixes) + ")"; } } Modified: trunk/src/dl-learner/org/dllearner/core/dl/SymmetricRoleAxiom.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/dl/SymmetricRoleAxiom.java 2007-10-12 08:17:02 UTC (rev 217) +++ trunk/src/dl-learner/org/dllearner/core/dl/SymmetricRoleAxiom.java 2007-10-12 08:44:21 UTC (rev 218) @@ -1,7 +1,9 @@ package org.dllearner.core.dl; -public class SymmetricRoleAxiom implements RBoxAxiom { +import java.util.Map; +public class SymmetricRoleAxiom extends RBoxAxiom { + private AtomicRole role; public SymmetricRoleAxiom(AtomicRole role) { @@ -16,8 +18,7 @@ return 1 + role.getLength(); } - @Override - public String toString() { - return "Symmetric(" + role.toString() + ")"; + public String toString(String baseURI, Map<String,String> prefixes) { + return "Symmetric(" + role.toString(baseURI, prefixes) + ")"; } } Modified: trunk/src/dl-learner/org/dllearner/core/dl/TerminologicalAxiom.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/dl/TerminologicalAxiom.java 2007-10-12 08:17:02 UTC (rev 217) +++ trunk/src/dl-learner/org/dllearner/core/dl/TerminologicalAxiom.java 2007-10-12 08:44:21 UTC (rev 218) @@ -1,5 +1,5 @@ package org.dllearner.core.dl; -public interface TerminologicalAxiom extends Axiom { +public abstract class TerminologicalAxiom extends Axiom { } Modified: trunk/src/dl-learner/org/dllearner/core/dl/Top.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/dl/Top.java 2007-10-12 08:17:02 UTC (rev 217) +++ trunk/src/dl-learner/org/dllearner/core/dl/Top.java 2007-10-12 08:44:21 UTC (rev 218) @@ -1,7 +1,7 @@ package org.dllearner.core.dl; +import java.util.Map; - public class Top extends Concept { /* @@ -12,8 +12,7 @@ } */ - @Override - public String toString() { + public String toString(String baseURI, Map<String,String> prefixes) { return "TOP"; } Modified: trunk/src/dl-learner/org/dllearner/core/dl/TransitiveRoleAxiom.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/dl/TransitiveRoleAxiom.java 2007-10-12 08:17:02 UTC (rev 217) +++ trunk/src/dl-learner/org/dllearner/core/dl/TransitiveRoleAxiom.java 2007-10-12 08:44:21 UTC (rev 218) @@ -1,7 +1,9 @@ package org.dllearner.core.dl; -public class TransitiveRoleAxiom implements RBoxAxiom { +import java.util.Map; +public class TransitiveRoleAxiom extends RBoxAxiom { + private Role role; public TransitiveRoleAxiom(Role role) { @@ -16,8 +18,7 @@ return role; } - @Override - public String toString() { - return "Transitive(" + role.toString() + ")"; - } + public String toString(String baseURI, Map<String,String> prefixes) { + return "Transitive(" + role.toString(baseURI, prefixes) + ")"; + } } Modified: trunk/src/dl-learner/org/dllearner/reasoning/KAON2Reasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/KAON2Reasoner.java 2007-10-12 08:17:02 UTC (rev 217) +++ trunk/src/dl-learner/org/dllearner/reasoning/KAON2Reasoner.java 2007-10-12 08:44:21 UTC (rev 218) @@ -3,6 +3,7 @@ import java.io.File; import java.io.IOException; import java.net.URL; +import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -14,8 +15,9 @@ import java.util.TreeMap; import java.util.TreeSet; -import org.dllearner.Config; +import org.dllearner.core.CommonConfigOptions; import org.dllearner.core.ConfigEntry; +import org.dllearner.core.ConfigOption; import org.dllearner.core.InvalidConfigOptionValueException; import org.dllearner.core.ReasonerComponent; import org.dllearner.core.dl.All; @@ -75,6 +77,9 @@ */ public class KAON2Reasoner extends ReasonerComponent { + // configuration options + private boolean una = false; + ConceptComparator conceptComparator = new ConceptComparator(); Set<AtomicConcept> atomicConcepts; @@ -198,7 +203,7 @@ // je nachdem, ob unique names assumption aktiviert ist, muss // man jetzt noch hinzuf�gen, dass die Individuen verschieden sind - if (Config.una) { + if (una) { Set<org.semanticweb.kaon2.api.owl.elements.Individual> individualsSet = new HashSet<org.semanticweb.kaon2.api.owl.elements.Individual>(); for (Individual individual : individuals) individualsSet.add(KAON2Manager.factory().individual(individual.getName())); @@ -699,15 +704,15 @@ Formula f = null; // falls closed world assumption, dann reicht default negation - if (Config.owa) +// if (Config.owa) // wegen BUG IN KAON2 momentan auskommentiert // f = KAON2Manager.factory().classicalNegation(l); - ; - else +// ; +// else f = KAON2Manager.factory().defaultNegation(l); // if-Teil entf�llt, sobald Bug in KAON2 gefixt wurde - if (!Config.owa) { +// if (!Config.owa) { // ClassicalNegation cn = // KAON2Manager.factory().classicalNegation(l); try { @@ -736,7 +741,7 @@ // TODO Auto-generated catch block e.printStackTrace(); } - } +// } return returnMap; } @@ -766,13 +771,20 @@ return individuals; } + public static Collection<ConfigOption<?>> createConfigOptions() { + Collection<ConfigOption<?>> options = new LinkedList<ConfigOption<?>>(); + options.add(CommonConfigOptions.getUNA()); + return options; + } + /* (non-Javadoc) * @see org.dllearner.core.Component#applyConfigEntry(org.dllearner.core.ConfigEntry) */ @Override public <T> void applyConfigEntry(ConfigEntry<T> entry) throws InvalidConfigOptionValueException { - // TODO Auto-generated method stub - + String name = entry.getOptionName(); + if(name.equals("una")) + una = (Boolean) entry.getValue(); } /* (non-Javadoc) Modified: trunk/src/dl-learner/org/dllearner/utilities/Helper.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/Helper.java 2007-10-12 08:17:02 UTC (rev 217) +++ trunk/src/dl-learner/org/dllearner/utilities/Helper.java 2007-10-12 08:44:21 UTC (rev 218) @@ -9,6 +9,7 @@ import java.util.SortedSet; import java.util.TreeMap; import java.util.TreeSet; +import java.util.Map.Entry; import org.dllearner.Config; import org.dllearner.core.ReasoningMethodUnsupportedException; @@ -69,12 +70,40 @@ // sucht, ob der übergebene String mit einem Prefix beginnt der // versteckt werden soll und gibt diesen zurück, ansonsten wird // null zurück gegeben - public static String findPrefixToHide(String name) { - for(String prefix : Config.hidePrefixes) { - if(name.startsWith(prefix)) - return prefix; - } - return null; +// public static String findPrefixToHide(String name) { +// for(String prefix : Config.hidePrefixes) { +// if(name.startsWith(prefix)) +// return prefix; +// } +// return null; +// } + + /** + * + * Transforms an URI to an abbreviated version, e.g. if the base URI is + * "http://example.com/" and the uri is "http://example.com/test", then + * "test" is returned. If the the uri is "http://anotherexample.com/test2" + * and a prefix "ns1" is given for "http://anotherexample.com", then + * "ns1:test2" is returned. If there is no match, uri is returned. + * + * @param uri The full uri, which should be transformed to an abbreviated version. + * @param baseURI The base uri (ignored if null). + * @param prefixes A prefix map (ignored if null), where each entry contains a short string e.g. ns1 + * as key and the corresponding uri as value. + * @return Abbreviated version of the parameter uri. + */ + public static String getAbbreviatedString(String uri, String baseURI, Map<String,String> prefixes) { + if(baseURI != null && uri.startsWith(baseURI)) { + return uri.substring(baseURI.length()); + } else { + if(prefixes != null) { + for(Entry<String,String> prefix : prefixes.entrySet()) { + if(uri.startsWith(prefix.getValue())) + return prefix.getKey() + ":" + uri.substring(prefix.getValue().length()); + } + } + return uri; + } } public static String prettyPrintNanoSeconds(long nanoSeconds) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2007-10-12 12:56:21
|
Revision: 220 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=220&view=rev Author: jenslehmann Date: 2007-10-12 05:56:15 -0700 (Fri, 12 Oct 2007) Log Message: ----------- started to readd the refinement based learning configuration options Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/Config.java trunk/src/dl-learner/org/dllearner/ConfigurationManager.java trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java trunk/src/dl-learner/org/dllearner/core/CommonConfigOptions.java Modified: trunk/src/dl-learner/org/dllearner/Config.java =================================================================== --- trunk/src/dl-learner/org/dllearner/Config.java 2007-10-12 09:20:39 UTC (rev 219) +++ trunk/src/dl-learner/org/dllearner/Config.java 2007-10-12 12:56:15 UTC (rev 220) @@ -7,7 +7,6 @@ import org.dllearner.algorithms.gp.GP.SelectionType; import org.dllearner.core.dl.AtomicConcept; import org.dllearner.core.dl.AtomicRole; -import org.dllearner.learningproblems.PosNegLP.UseMultiInstanceChecks; public class Config { // standardmäßig wird bis Tiefe 7 gesucht @@ -98,13 +97,13 @@ // Informationen (Rollen, Konzepte, Individuen, Anzahl Axiome) über // Wissensbasis anzeigen => alles konfigurierbar um Output in Grenzen // zu halten - public static boolean showRoles = false; - public static boolean showConcepts = false; - public static boolean showIndividuals = false; - public static boolean showSubsumptionHierarchy = false; +// public static boolean showRoles = false; +// public static boolean showConcepts = false; +// public static boolean showIndividuals = false; +// public static boolean showSubsumptionHierarchy = false; // zeigt die interne Wissensbasis an (d.h. keine externen OWL-Dateien) - public static boolean showInternalKB = false; - public static int maxLineLength = 100; +// public static boolean showInternalKB = false; +// public static int maxLineLength = 100; // public static boolean writeDIGProtocol = false; // public static File digProtocolFile = new File("log/digProtocol.txt"); @@ -145,7 +144,7 @@ // ausgeführt // werden, bevor too weak festgestellt werden kann // TODO: not implemented - public static UseMultiInstanceChecks useDIGMultiInstanceChecks = UseMultiInstanceChecks.TWOCHECKS; +// public static UseMultiInstanceChecks useDIGMultiInstanceChecks = UseMultiInstanceChecks.TWOCHECKS; // geplante Optionen um den Suchraum einzuschränken @@ -185,7 +184,7 @@ // Domain und Range beim Verschachteln von Rollen beachten // nicht implementiert // TODO: Wie soll man das in DIG machen? - public static boolean useDomainRange = false; +// public static boolean useDomainRange = false; // bereits vorher allgemeinere Konzepte festlegen (Default: keine) // nicht implementiert Modified: trunk/src/dl-learner/org/dllearner/ConfigurationManager.java =================================================================== --- trunk/src/dl-learner/org/dllearner/ConfigurationManager.java 2007-10-12 09:20:39 UTC (rev 219) +++ trunk/src/dl-learner/org/dllearner/ConfigurationManager.java 2007-10-12 12:56:15 UTC (rev 220) @@ -454,15 +454,15 @@ else if(option.equals("hidePrefix")) { // Config.hidePrefixes.add(value); } else if (option.equals("showIndividuals")) { - Config.showIndividuals = Datastructures.strToBool(value); +// Config.showIndividuals = Datastructures.strToBool(value); } else if (option.equals("showConcepts")) { - Config.showConcepts = Datastructures.strToBool(value); +// Config.showConcepts = Datastructures.strToBool(value); } else if (option.equals("showRoles")) { - Config.showRoles = Datastructures.strToBool(value); +// Config.showRoles = Datastructures.strToBool(value); } else if (option.equals("showInternalKB")) { - Config.showInternalKB = Datastructures.strToBool(value); +// Config.showInternalKB = Datastructures.strToBool(value); } else if (option.equals("showSubsumptionHierarchy")) { - Config.showSubsumptionHierarchy = Datastructures.strToBool(value); +// Config.showSubsumptionHierarchy = Datastructures.strToBool(value); } else if (option.equals("writeDIGProtocol")) { // Config.writeDIGProtocol = Datastructures.strToBool(value); } else if (option.equals("digProtocolFile")) { Modified: trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2007-10-12 09:20:39 UTC (rev 219) +++ trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2007-10-12 12:56:15 UTC (rev 220) @@ -13,8 +13,10 @@ import org.dllearner.Config; import org.dllearner.core.BooleanConfigOption; +import org.dllearner.core.CommonConfigOptions; import org.dllearner.core.ConfigEntry; import org.dllearner.core.ConfigOption; +import org.dllearner.core.DoubleConfigOption; import org.dllearner.core.InvalidConfigOptionValueException; import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.LearningProblem; @@ -142,6 +144,25 @@ StringConfigOption heuristicOption = new StringConfigOption("heuristic", "specifiy the heuristic to use", "lexicographic"); heuristicOption.setAllowedValues(new String[] {"lexicographic", "flexible"}); options.add(heuristicOption); + options.add(new BooleanConfigOption("applyAllFilter", "usage of equivalence ALL R.C AND ALL R.D = ALL R.(C AND D)", true)); + options.add(new BooleanConfigOption("applyExistsFilter", "usage of equivalence EXISTS R.C OR EXISTS R.D = EXISTS R.(C OR D)", true)); + options.add(new BooleanConfigOption("useTooWeakList", "try to filter out too weak concepts without sending them to the reasoner", true)); + options.add(new BooleanConfigOption("useOverlyGeneralList", "try to find overly general concept without sending them to the reasoner", true)); + options.add(new BooleanConfigOption("useShortConceptConstruction", "shorten concept to see whether they already exist", true)); + DoubleConfigOption horizExp = new DoubleConfigOption("horizontalExpansionFactor", "horizontal expansion factor (see publication for description)", 0.6); + horizExp.setLowerLimit(0.0); + horizExp.setUpperLimit(1.0); + options.add(horizExp); + options.add(new BooleanConfigOption("improveSubsumptionHierarchy", "simplify subsumption hierarchy to reduce search space (see publication for description)", true)); + // TODO: replace by a general verbosity option for all components + options.add(new BooleanConfigOption("quiet", "may be deprecated soon", false)); + options.add(CommonConfigOptions.allowedConcepts()); + options.add(CommonConfigOptions.ignoredConcepts()); + options.add(CommonConfigOptions.allowedRoles()); + options.add(CommonConfigOptions.ignoredRoles()); + options.add(CommonConfigOptions.useAllConstructor()); + options.add(CommonConfigOptions.useExistsConstructor()); + options.add(CommonConfigOptions.useNegation()); return options; } Modified: trunk/src/dl-learner/org/dllearner/core/CommonConfigOptions.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/CommonConfigOptions.java 2007-10-12 09:20:39 UTC (rev 219) +++ trunk/src/dl-learner/org/dllearner/core/CommonConfigOptions.java 2007-10-12 12:56:15 UTC (rev 220) @@ -49,4 +49,32 @@ public static BooleanConfigOption getOWA() { return new BooleanConfigOption("owa", "open world assumption (if set to false, we try to close the world", true); } + + public static StringSetConfigOption allowedConcepts() { + return new StringSetConfigOption("allowedConcepts", "concepts the algorithm is allowed to use"); + } + + public static StringSetConfigOption allowedRoles() { + return new StringSetConfigOption("allowedRoles", "roles the algorithm is allowed to use"); + } + + public static StringSetConfigOption ignoredConcepts() { + return new StringSetConfigOption("ignoredConcepts", "concepts the algorithm must ignore"); + } + + public static StringSetConfigOption ignoredRoles() { + return new StringSetConfigOption("ignoredRoles", "roles the algorithm must ignore"); + } + + public static BooleanConfigOption useAllConstructor() { + return new BooleanConfigOption("useAllConstructor", "specifies whether to universal concept constructor is used in the learning algorothm"); + } + + public static BooleanConfigOption useExistsConstructor() { + return new BooleanConfigOption("useExistsConstructor", "specifies whether to existential concept constructor is used in the learning algorothm"); + } + + public static BooleanConfigOption useNegation() { + return new BooleanConfigOption("useNegation", "specifies whether negation is used in the learning algorothm"); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2007-10-16 09:19:38
|
Revision: 225 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=225&view=rev Author: jenslehmann Date: 2007-10-16 02:19:34 -0700 (Tue, 16 Oct 2007) Log Message: ----------- - extended web service interface by reasoning methods - continued evaluation cache Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/learningproblems/EvaluationCache.java trunk/src/dl-learner/org/dllearner/server/DLLearnerWSNew.java trunk/src/dl-learner/org/dllearner/utilities/Datastructures.java trunk/src/dl-learner/org/dllearner/utilities/SortedSetTuple.java Modified: trunk/src/dl-learner/org/dllearner/learningproblems/EvaluationCache.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/EvaluationCache.java 2007-10-15 16:37:22 UTC (rev 224) +++ trunk/src/dl-learner/org/dllearner/learningproblems/EvaluationCache.java 2007-10-16 09:19:34 UTC (rev 225) @@ -22,15 +22,14 @@ import java.util.Map; import java.util.SortedSet; import java.util.TreeMap; -import java.util.TreeSet; -import org.dllearner.core.dl.AtomicConcept; import org.dllearner.core.dl.Concept; import org.dllearner.core.dl.Individual; import org.dllearner.core.dl.MultiConjunction; import org.dllearner.core.dl.MultiDisjunction; import org.dllearner.utilities.ConceptComparator; import org.dllearner.utilities.Helper; +import org.dllearner.utilities.SortedSetTuple; /** * Caches results of previous concept evaluation to speed up @@ -46,6 +45,7 @@ // maps a concept to a list of individuals it covers private Map<Concept,SortedSet<Individual>> cache; + private boolean checkForEqualConcepts = false; // concept comparator for concept indexing // (so only logarithmic time complexity is needed to access a cached object) @@ -66,44 +66,49 @@ /** * Determines which examples are instances of a concept. * @param concept - * @return Set of inferred individuals or null if none were infered. + * @return A tuple of two sets, where the first element is the + * set of individuals belonging to the class and the second element + * is the set of individuals not belonging to the class. For all + * elements, which are in neither of the sets, the cache cannot + * safely determine whether they are concept instances or not. */ - public SortedSet<Individual> inferMember(Concept concept) { - // return examples for atomic concepts if it is in the cache - if(concept instanceof AtomicConcept) - return cache.get(concept); - // for a negation NOT C we can only say which concepts are not in it - // (those in C), but we cannot say which ones are in NOT C -// else if(concept instanceof Negation) -// return Helper.difference(examples, inferPos(concept.getChild(0))); - // for a conjunction we know that the intersection of instances - // of all children belongs to the concept - else if(concept instanceof MultiConjunction) { - SortedSet<Individual> ret = inferMember(concept.getChild(0)); - for(int i=1; i<concept.getChildren().size(); i++) { - ret = Helper.intersection(ret, inferMember(concept.getChild(i))); + public SortedSetTuple<Individual> infer(Concept concept) { + if(checkForEqualConcepts) { + SortedSet<Individual> pos = cache.get(concept); + SortedSet<Individual> neg = Helper.difference(examples, pos); + return new SortedSetTuple<Individual>(pos,neg); + } else { + // for a negation NOT C we can only say which concepts are not in it + // (those in C), but we cannot say which ones are in NOT C + + // for a conjunction we know that the intersection of instances + // of all children belongs to the concept + if(concept instanceof MultiConjunction) { + handleMultiConjunction((MultiConjunction)concept); + // disjunctions are similar to conjunctions but we use union here; + // note that there can be instances which are neither in a concept + // C nor in a concept D, but in (C OR D) + } else if(concept instanceof MultiDisjunction) { + SortedSet<Individual> ret = cache.get(concept.getChild(0)); + for(int i=1; i<concept.getChildren().size(); i++) { + ret = Helper.union(ret, cache.get(concept.getChild(i))); + } + // in all other cases we cannot infer anything, so we return an + // empty tuple + } else { + return new SortedSetTuple<Individual>(); } - return ret; - // disjunctions are similar to conjunctions but we use union here; - // note that there can be instances which are neither in a concept - // C nor in a concept D, but in (C OR D) - } else if(concept instanceof MultiDisjunction) { - SortedSet<Individual> ret = inferMember(concept.getChild(0)); - for(int i=1; i<concept.getChildren().size(); i++) { - ret = Helper.union(ret, inferMember(concept.getChild(i))); - } - return ret; } - return new TreeSet<Individual>(); + return null; } - /** - * Determines which examples are not instance of a concept. - * @param concept - * @return - */ - public SortedSet<Individual> inferNonMember(Concept concept) { + private SortedSetTuple<Individual> handleMultiConjunction(MultiConjunction mc) { + SortedSet<Individual> pos = cache.get(mc.getChild(0)); + for(int i=1; i<mc.getChildren().size(); i++) { + pos = Helper.intersection(pos, cache.get(mc.getChild(i))); + } + // TODO: handle the case that some children may not be in cache return null; } } Modified: trunk/src/dl-learner/org/dllearner/server/DLLearnerWSNew.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/DLLearnerWSNew.java 2007-10-15 16:37:22 UTC (rev 224) +++ trunk/src/dl-learner/org/dllearner/server/DLLearnerWSNew.java 2007-10-16 09:19:34 UTC (rev 225) @@ -23,6 +23,7 @@ import java.util.Map; import java.util.Random; import java.util.Set; +import java.util.SortedSet; import java.util.TreeMap; import java.util.TreeSet; @@ -38,11 +39,17 @@ import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasonerComponent; import org.dllearner.core.dl.AtomicConcept; +import org.dllearner.core.dl.AtomicRole; +import org.dllearner.core.dl.Concept; +import org.dllearner.core.dl.Individual; import org.dllearner.kb.OWLFile; import org.dllearner.kb.SparqlEndpoint; import org.dllearner.learningproblems.PosNegDefinitionLP; import org.dllearner.learningproblems.PosNegInclusionLP; +import org.dllearner.parser.KBParser; +import org.dllearner.parser.ParseException; import org.dllearner.reasoning.DIGReasoner; +import org.dllearner.utilities.Datastructures; /** * DL-Learner web service interface. @@ -140,36 +147,36 @@ } @WebMethod - public void setReasoner(int id, String component) throws ClientNotKnownException, UnknownComponentException { + public int setReasoner(int id, String component) throws ClientNotKnownException, UnknownComponentException { State state = getState(id); Class<? extends ReasonerComponent> rcClass = reasonerMapping.get(component); if(rcClass == null) throw new UnknownComponentException(component); ReasonerComponent rc = cm.reasoner(rcClass, state.getKnowledgeSources()); - state.setReasonerComponent(rc); + return state.setReasonerComponent(rc); } @WebMethod - public void setLearningProblem(int id, String component) throws ClientNotKnownException, UnknownComponentException { + public int setLearningProblem(int id, String component) throws ClientNotKnownException, UnknownComponentException { State state = getState(id); Class<? extends LearningProblem> lpClass = learningProblemMapping.get(component); if(lpClass == null) throw new UnknownComponentException(component); LearningProblem lp = cm.learningProblem(lpClass, state.getReasoningService()); - state.setLearningProblem(lp); + return state.setLearningProblem(lp); } @WebMethod - public void setLearningAlgorithm(int id, String component) throws ClientNotKnownException, UnknownComponentException { + public int setLearningAlgorithm(int id, String component) throws ClientNotKnownException, UnknownComponentException { State state = getState(id); Class<? extends LearningAlgorithm> laClass = learningAlgorithmMapping.get(component); if(laClass == null) throw new UnknownComponentException(component); LearningAlgorithm la = cm.learningAlgorithm(laClass, state.getLearningProblem(), state.getReasoningService()); - state.setLearningAlgorithm(la); + return state.setLearningAlgorithm(la); } /** @@ -263,27 +270,23 @@ } @WebMethod - public void applyConfigEntryInt(int sessionID, int componentID, String optionName, Integer value) throws ClientNotKnownException, UnknownComponentException - { + public void applyConfigEntryInt(int sessionID, int componentID, String optionName, Integer value) throws ClientNotKnownException, UnknownComponentException { applyConfigEntry(sessionID, componentID,optionName,value); } @WebMethod - public void applyConfigEntryString(int sessionID, int componentID, String optionName, String value) throws ClientNotKnownException, UnknownComponentException - { + public void applyConfigEntryString(int sessionID, int componentID, String optionName, String value) throws ClientNotKnownException, UnknownComponentException { applyConfigEntry(sessionID, componentID,optionName,value); } @WebMethod - public void applyConfigEntryStringArray(int sessionID, int componentID, String optionName, String[] value) throws ClientNotKnownException, UnknownComponentException - { + public void applyConfigEntryStringArray(int sessionID, int componentID, String optionName, String[] value) throws ClientNotKnownException, UnknownComponentException { Set<String> stringSet = new TreeSet<String>(Arrays.asList(value)); applyConfigEntry(sessionID, componentID,optionName,stringSet); } @WebMethod - public void applyConfigEntryBoolean(int sessionID, int componentID, String optionName, Boolean value) throws ClientNotKnownException, UnknownComponentException - { + public void applyConfigEntryBoolean(int sessionID, int componentID, String optionName, Boolean value) throws ClientNotKnownException, UnknownComponentException { applyConfigEntry(sessionID, componentID,optionName,value); } @@ -300,14 +303,48 @@ @WebMethod public String[] getAtomicConcepts(int id) throws ClientNotKnownException { Set<AtomicConcept> atomicConcepts = getState(id).getReasoningService().getAtomicConcepts(); - // convert to String-Array - String[] result = new String[atomicConcepts.size()]; - int i=0; - for(AtomicConcept ac : atomicConcepts) { - result[i] = ac.getName(); - i++; + return Datastructures.sortedSet2StringListConcepts(atomicConcepts); + } + + @WebMethod + public String getSubsumptionHierarchy(int id) throws ClientNotKnownException { + return getState(id).getReasoningService().toString(); + } + + @WebMethod + public String[] retrieval(int id, String conceptString) throws ClientNotKnownException { + State state = getState(id); + // call parser to parse atomic concept + Concept concept = null; + try { + concept = KBParser.parseConcept(conceptString); + } catch (ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); } - return result; + Set<Individual> individuals = state.getReasoningService().retrieval(concept); + return Datastructures.sortedSet2StringListIndividuals(individuals); } + @WebMethod + public String[] getAtomicRoles(int id) throws ClientNotKnownException { + State state = getState(id); + Set<AtomicRole> roles = state.getReasoningService().getAtomicRoles(); + return Datastructures.sortedSet2StringListRoles(roles); + } + + @WebMethod + public String[] getInstances(int id) throws ClientNotKnownException { + State state = getState(id); + Set<Individual> individuals = state.getReasoningService().getIndividuals(); + return Datastructures.sortedSet2StringListIndividuals(individuals); + } + + @WebMethod + public String[] getIndividualsForARole(int id, String role) throws ClientNotKnownException { + State state = getState(id); + Map<Individual,SortedSet<Individual>> m = state.getReasoningService().getRoleMembers(new AtomicRole(role)); + Set<Individual> individuals = m.keySet(); + return Datastructures.sortedSet2StringListIndividuals(individuals); + } } Modified: trunk/src/dl-learner/org/dllearner/utilities/Datastructures.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/Datastructures.java 2007-10-15 16:37:22 UTC (rev 224) +++ trunk/src/dl-learner/org/dllearner/utilities/Datastructures.java 2007-10-16 09:19:34 UTC (rev 225) @@ -19,10 +19,17 @@ */ package org.dllearner.utilities; +import java.util.Arrays; import java.util.Iterator; import java.util.Set; +import org.dllearner.core.dl.AtomicConcept; +import org.dllearner.core.dl.AtomicRole; +import org.dllearner.core.dl.Individual; + /** + * Conversion between different data structures. + * * @author Jens Lehmann * @author Sebastian Hellmann * @@ -44,7 +51,7 @@ * @param s * @return */ - public static String[] setToArray(Set<String> s){ + public static String[] setToArray(Set<String> s) { if(s==null)return null; String[] ret=new String[s.size()]; int i=0; @@ -57,4 +64,39 @@ } + public static String[] sortedSet2StringListIndividuals(Set<Individual> individuals){ + + String[] ret=new String[individuals.size()]; + Iterator<Individual> i=individuals.iterator(); + int a=0; + while (i.hasNext()){ + ret[a++]=((Individual)i.next()).getName(); + } + Arrays.sort(ret); + return ret; + } + + public static String[] sortedSet2StringListRoles(Set<AtomicRole> s){ + + String[] ret=new String[s.size()]; + Iterator<AtomicRole> i=s.iterator(); + int a=0; + while (i.hasNext()){ + ret[a++]=((AtomicRole)i.next()).getName(); + } + Arrays.sort(ret); + return ret; + } + + public static String[] sortedSet2StringListConcepts(Set<AtomicConcept> s){ + + String[] ret=new String[s.size()]; + Iterator<AtomicConcept> i=s.iterator(); + int a=0; + while (i.hasNext()){ + ret[a++]=((AtomicConcept)i.next()).getName(); + } + Arrays.sort(ret); + return ret; + } } Modified: trunk/src/dl-learner/org/dllearner/utilities/SortedSetTuple.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/SortedSetTuple.java 2007-10-15 16:37:22 UTC (rev 224) +++ trunk/src/dl-learner/org/dllearner/utilities/SortedSetTuple.java 2007-10-16 09:19:34 UTC (rev 225) @@ -1,12 +1,18 @@ package org.dllearner.utilities; import java.util.SortedSet; +import java.util.TreeSet; public class SortedSetTuple<T> { private SortedSet<T> posSet; private SortedSet<T> negSet; + public SortedSetTuple() { + posSet = new TreeSet<T>(); + negSet = new TreeSet<T>(); + } + public SortedSetTuple(SortedSet<T> posSet, SortedSet<T> negSet) { this.posSet = posSet; this.negSet = negSet; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2007-10-16 13:24:45
|
Revision: 228 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=228&view=rev Author: jenslehmann Date: 2007-10-16 06:24:32 -0700 (Tue, 16 Oct 2007) Log Message: ----------- created component pool for storing all live components (intermediate commit) Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/BruteForceLearner.java trunk/src/dl-learner/org/dllearner/core/Component.java trunk/src/dl-learner/org/dllearner/core/ComponentManager.java trunk/src/dl-learner/org/dllearner/server/ClientState.java trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/core/ComponentPool.java trunk/src/dl-learner/org/dllearner/core/UnknownConfigOptionException.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/BruteForceLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/BruteForceLearner.java 2007-10-16 09:32:08 UTC (rev 227) +++ trunk/src/dl-learner/org/dllearner/algorithms/BruteForceLearner.java 2007-10-16 13:24:32 UTC (rev 228) @@ -62,7 +62,7 @@ private Concept bestDefinition; private Score bestScore; - private int maxLength = 7; + private Integer maxLength = 7; private String returnType; // list of all generated concepts sorted by length @@ -97,6 +97,13 @@ returnType = (String) returnType; } +// public Object getConfigValue(String optionName) throws UnknownConfigOptionException { +// if(optionName.equals("maxLength")) +// return maxLength; +// else +// throw new UnknownConfigOptionException(getClass(), optionName); +// } + /* (non-Javadoc) * @see org.dllearner.core.Component#init() */ @@ -264,4 +271,5 @@ @Override public void stop() { } + } Modified: trunk/src/dl-learner/org/dllearner/core/Component.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/Component.java 2007-10-16 09:32:08 UTC (rev 227) +++ trunk/src/dl-learner/org/dllearner/core/Component.java 2007-10-16 13:24:32 UTC (rev 228) @@ -23,6 +23,8 @@ import java.util.LinkedList; /** + * General component base class. + * * @author Jens Lehmann * */ @@ -54,4 +56,13 @@ * @param entry A configuration entry. */ public abstract <T> void applyConfigEntry(ConfigEntry<T> entry) throws InvalidConfigOptionValueException; + + /** + * Gets the value of a configuration option of this component. + * + * @param <T> Option type. + * @param option A configuration option of this component. + * @return Current value of the configuration option. + */ +// public abstract <T> T getConfigValue(ConfigOption<T> option) throws UnknownConfigOptionException; } Modified: trunk/src/dl-learner/org/dllearner/core/ComponentManager.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ComponentManager.java 2007-10-16 09:32:08 UTC (rev 227) +++ trunk/src/dl-learner/org/dllearner/core/ComponentManager.java 2007-10-16 13:24:32 UTC (rev 228) @@ -56,6 +56,8 @@ */ public class ComponentManager { + private ComponentPool pool = new ComponentPool(); + // these variables are valid for the complete lifetime of DL-Learner private static String componentsFile = "lib/components.ini"; private static ComponentManager cm = new ComponentManager(); @@ -71,6 +73,9 @@ private static Map<Class<? extends Component>, Map<String, ConfigOption<?>>> componentOptionsByName; private static Map<Class<? extends LearningAlgorithm>, Collection<Class<? extends LearningProblem>>> algorithmProblemsMapping; + // list of default values of config options +// private static Map<ConfigOption<?>,Object> configOptionDefaults; + private Comparator<Class<?>> classComparator = new Comparator<Class<?>>() { public int compare(Class<?> c1, Class<?> c2) { @@ -124,21 +129,24 @@ // read in all configuration options componentOptions = new HashMap<Class<? extends Component>, List<ConfigOption<?>>>(); componentOptionsByName = new HashMap<Class<? extends Component>, Map<String, ConfigOption<?>>>(); - +// configOptionDefaults = new HashMap<ConfigOption<?>,Object>(); + for (Class<? extends Component> component : components) { String name = (String) invokeStaticMethod(component, "getName"); componentNames.put(component, name); + // assign options to components List<ConfigOption<?>> options = (List<ConfigOption<?>>) invokeStaticMethod(component, "createConfigOptions"); componentOptions.put(component, options); + // make config options accessible by name Map<String, ConfigOption<?>> byName = new HashMap<String, ConfigOption<?>>(); for (ConfigOption<?> option : options) byName.put(option.getName(), option); componentOptionsByName.put(component, byName); - + } // System.out.println(components); @@ -186,6 +194,7 @@ * @param optionName * @param value */ + @SuppressWarnings( { "unchecked" }) public <T> void applyConfigEntry(Component component, String optionName, T value) { // first we look whether the component is registered if (components.contains(component.getClass())) { @@ -205,11 +214,13 @@ // we have checked the type, hence it should now be safe to // typecast and // create a ConfigEntry object - try { - @SuppressWarnings( { "unchecked" }) - ConfigEntry<T> entry = new ConfigEntry<T>((ConfigOption<T>) option, value); + ConfigEntry<T> entry = null; + try { + entry = new ConfigEntry<T>((ConfigOption<T>) option, value); component.applyConfigEntry(entry); + pool.addConfigEntry(component, entry, true); } catch (InvalidConfigOptionValueException e) { + pool.addConfigEntry(component, entry, false); System.out.println("Warning: value " + value + " is not valid for option " + optionName + " in component " + component); } @@ -231,9 +242,10 @@ public <T> boolean applyConfigEntry(Component component, ConfigEntry<T> entry) { try { component.applyConfigEntry(entry); + pool.addConfigEntry(component,entry,true); return true; } catch (InvalidConfigOptionValueException e) { - // TODO Auto-generated catch block + pool.addConfigEntry(component,entry,false); e.printStackTrace(); return false; } Added: trunk/src/dl-learner/org/dllearner/core/ComponentPool.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ComponentPool.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/ComponentPool.java 2007-10-16 13:24:32 UTC (rev 228) @@ -0,0 +1,72 @@ +/** + * Copyright (C) 2007, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package org.dllearner.core; + +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +/** + * Stores all live components. + * + * @author Jens Lehmann + * + */ +public class ComponentPool { + + // stores all components, which are live (components which are + // no longer used have to be deregistered) + private List<Component> components = new LinkedList<Component>(); + + // stores the last value which was set for a particular + // config option + private Map<Component,Map<ConfigOption<?>,Object>> lastValidConfigValue = new HashMap<Component,Map<ConfigOption<?>,Object>>(); + // complete history of all made config entries for a component + private Map<Component,List<ConfigEntry<?>>> configEntryHistory = new HashMap<Component,List<ConfigEntry<?>>>(); + + public Object getLastValidConfigEntry(Component component, ConfigOption<?> option) { + return lastValidConfigValue.get(component).get(option); + } + + public void registerComponent(Component component) { + components.add(component); + Map<ConfigOption<?>,Object> emptyMap = new HashMap<ConfigOption<?>,Object>(); + lastValidConfigValue.put(component, emptyMap); + configEntryHistory.put(component, new LinkedList<ConfigEntry<?>>()); + } + + public void unregisterComponent(Component component) { + configEntryHistory.remove(component); + lastValidConfigValue.remove(component); + components.remove(component); + } + + public Object getLastValidConfigValue(Component component, ConfigOption<?> option) { + return lastValidConfigValue.get(component).get(option); + } + + public void addConfigEntry(Component component, ConfigEntry<?> entry, boolean valid) { + configEntryHistory.get(component).add(entry); + if(valid) + lastValidConfigValue.get(component).put(entry.getOption(), entry.getValue()); + } + +} Added: trunk/src/dl-learner/org/dllearner/core/UnknownConfigOptionException.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/UnknownConfigOptionException.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/UnknownConfigOptionException.java 2007-10-16 13:24:32 UTC (rev 228) @@ -0,0 +1,38 @@ +/** + * Copyright (C) 2007, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package org.dllearner.core; + +/** + * @author Jens Lehmann + * + */ +public class UnknownConfigOptionException extends Exception { + + private static final long serialVersionUID = -7808637210577591687L; + + public UnknownConfigOptionException(Class<? extends Component> componentClass, String optionName) { + super("Option " + optionName + " unknown in component " + ComponentManager.getInstance().getComponentName(componentClass) + "(" + componentClass.getName() + ")"); + } + + public UnknownConfigOptionException(Class<? extends Component> componentClass, ConfigOption<?> option) { + super("Option " + option.getName() + " unknown in component " + ComponentManager.getInstance().getComponentName(componentClass) + "(" + componentClass.getName() + ")"); + } + +} Modified: trunk/src/dl-learner/org/dllearner/server/ClientState.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/ClientState.java 2007-10-16 09:32:08 UTC (rev 227) +++ trunk/src/dl-learner/org/dllearner/server/ClientState.java 2007-10-16 13:24:32 UTC (rev 228) @@ -45,7 +45,7 @@ // stores the mapping between component IDs and component // (note that this allows us to keep all references to components even - // if they are note used anymore e.g. a deleted knowledge source) + // if they are not used anymore e.g. a deleted knowledge source) private Map<Integer,Component> componentIDs = new HashMap<Integer,Component>(); private Set<KnowledgeSource> knowledgeSources = new HashSet<KnowledgeSource>(); Modified: trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2007-10-16 09:32:08 UTC (rev 227) +++ trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2007-10-16 13:24:32 UTC (rev 228) @@ -314,7 +314,7 @@ @WebMethod public String[] retrieval(int id, String conceptString) throws ClientNotKnownException { ClientState state = getState(id); - // call parser to parse atomic concept + // call parser to parse concept Concept concept = null; try { concept = KBParser.parseConcept(conceptString); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2007-10-17 16:56:07
|
Revision: 232 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=232&view=rev Author: jenslehmann Date: 2007-10-17 09:54:24 -0700 (Wed, 17 Oct 2007) Log Message: ----------- moved another couple of options to new structure involving many related changes Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/Config.java trunk/src/dl-learner/org/dllearner/ConfigurationManager.java trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java trunk/src/dl-learner/org/dllearner/core/CommonConfigMappings.java trunk/src/dl-learner/org/dllearner/core/CommonConfigOptions.java trunk/src/dl-learner/org/dllearner/core/Reasoner.java trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java trunk/src/dl-learner/org/dllearner/core/ReasoningService.java trunk/src/dl-learner/org/dllearner/reasoning/DIGReasoner.java trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java trunk/src/dl-learner/org/dllearner/reasoning/KAON2Reasoner.java trunk/src/dl-learner/org/dllearner/utilities/Helper.java trunk/src/dl-learner/org/dllearner/utilities/PaperStatistics.java Modified: trunk/src/dl-learner/org/dllearner/Config.java =================================================================== --- trunk/src/dl-learner/org/dllearner/Config.java 2007-10-17 14:28:58 UTC (rev 231) +++ trunk/src/dl-learner/org/dllearner/Config.java 2007-10-17 16:54:24 UTC (rev 232) @@ -1,12 +1,9 @@ package org.dllearner; import java.lang.reflect.Field; -import java.util.Set; import org.dllearner.algorithms.gp.GP.AlgorithmType; import org.dllearner.algorithms.gp.GP.SelectionType; -import org.dllearner.core.dl.AtomicConcept; -import org.dllearner.core.dl.AtomicRole; public class Config { // standardmäßig wird bis Tiefe 7 gesucht @@ -151,9 +148,9 @@ // Konzepte, die in der Definition vorkommen können (per Default // ("null") alle) // nicht implementiert - public static Set<AtomicConcept> allowedConcepts = null; +// public static Set<AtomicConcept> allowedConcepts = null; // ignorierte Konzepte; Default null = keine - public static Set<AtomicConcept> ignoredConcepts = null; +// public static Set<AtomicConcept> ignoredConcepts = null; // beachte: es können nur entweder die erlaubten oder die ignorierten // Konzepte // gesetzt werden @@ -161,13 +158,13 @@ // true falls die Konzepte vom Nutzer gesetzt worden (also // allowedConcepts // gleich null), ansonsten false - public static boolean allowedConceptsAutoDetect = true; +// public static boolean allowedConceptsAutoDetect = true; // Rollen, die in der Lösung vorkommen können // nicht implementiert - public static Set<AtomicRole> allowedRoles = null; - public static Set<AtomicRole> ignoredRoles = null; - public static boolean allowedRolesAutoDetect = true; +// public static Set<AtomicRole> allowedRoles = null; +// public static Set<AtomicRole> ignoredRoles = null; +// public static boolean allowedRolesAutoDetect = true; // max. Verschachtelungstiefe der Lösung // nicht implementiert Modified: trunk/src/dl-learner/org/dllearner/ConfigurationManager.java =================================================================== --- trunk/src/dl-learner/org/dllearner/ConfigurationManager.java 2007-10-17 14:28:58 UTC (rev 231) +++ trunk/src/dl-learner/org/dllearner/ConfigurationManager.java 2007-10-17 16:54:24 UTC (rev 232) @@ -7,17 +7,11 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.TreeSet; import org.dllearner.algorithms.gp.GP.AlgorithmType; import org.dllearner.algorithms.gp.GP.SelectionType; import org.dllearner.cli.ConfFileOption; -import org.dllearner.core.dl.AtomicConcept; -import org.dllearner.core.dl.AtomicRole; -import org.dllearner.parser.KBParser; -import org.dllearner.utilities.ConceptComparator; import org.dllearner.utilities.Datastructures; -import org.dllearner.utilities.RoleComparator; /** * Nach dem einlesen der Datei werden hier alle Konfigurationsoptionen @@ -542,24 +536,24 @@ // System.out.println(":" + optionString + " " + setValues); if(optionString.equals("refinement.allowedConcepts")) { - Config.Refinement.allowedConceptsAutoDetect = false; - Config.Refinement.allowedConcepts = new TreeSet<AtomicConcept>(new ConceptComparator()); - for(String s : setValues) +// Config.Refinement.allowedConceptsAutoDetect = false; + ; // Config.Refinement.allowedConcepts = new TreeSet<AtomicConcept>(new ConceptComparator()); +// for(String s : setValues) // es wird die gleiche Funktion wie im Parser genommen um Namen auf URIs zu mappen - Config.Refinement.allowedConcepts.add(new AtomicConcept(KBParser.getInternalURI(s))); +// Config.Refinement.allowedConcepts.add(new AtomicConcept(KBParser.getInternalURI(s))); } else if(optionString.equals("refinement.allowedRoles")) { - Config.Refinement.allowedRolesAutoDetect = false; - Config.Refinement.allowedRoles = new TreeSet<AtomicRole>(new RoleComparator()); - for(String s : setValues) - Config.Refinement.allowedRoles.add(new AtomicRole(KBParser.getInternalURI(s))); +// Config.Refinement.allowedRolesAutoDetect = false; +// Config.Refinement.allowedRoles = new TreeSet<AtomicRole>(new RoleComparator()); +// for(String s : setValues) +// Config.Refinement.allowedRoles.add(new AtomicRole(KBParser.getInternalURI(s))); } else if(optionString.equals("refinement.ignoredConcepts")) { - Config.Refinement.ignoredConcepts = new TreeSet<AtomicConcept>(new ConceptComparator()); - for(String s : setValues) - Config.Refinement.ignoredConcepts.add(new AtomicConcept(KBParser.getInternalURI(s))); +// Config.Refinement.ignoredConcepts = new TreeSet<AtomicConcept>(new ConceptComparator()); +// for(String s : setValues) +// Config.Refinement.ignoredConcepts.add(new AtomicConcept(KBParser.getInternalURI(s))); } else if(optionString.equals("refinement.ignoredRoles")) { - Config.Refinement.ignoredRoles = new TreeSet<AtomicRole>(new RoleComparator()); - for(String s : setValues) - Config.Refinement.ignoredRoles.add(new AtomicRole(KBParser.getInternalURI(s))); +// Config.Refinement.ignoredRoles = new TreeSet<AtomicRole>(new RoleComparator()); +// for(String s : setValues) +// Config.Refinement.ignoredRoles.add(new AtomicRole(KBParser.getInternalURI(s))); } } Modified: trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2007-10-17 14:28:58 UTC (rev 231) +++ trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2007-10-17 16:54:24 UTC (rev 232) @@ -13,6 +13,7 @@ import org.dllearner.Config; import org.dllearner.core.BooleanConfigOption; +import org.dllearner.core.CommonConfigMappings; import org.dllearner.core.CommonConfigOptions; import org.dllearner.core.ConfigEntry; import org.dllearner.core.ConfigOption; @@ -23,6 +24,8 @@ import org.dllearner.core.ReasoningService; import org.dllearner.core.Score; import org.dllearner.core.StringConfigOption; +import org.dllearner.core.dl.AtomicConcept; +import org.dllearner.core.dl.AtomicRole; import org.dllearner.core.dl.Concept; import org.dllearner.core.dl.MultiConjunction; import org.dllearner.core.dl.MultiDisjunction; @@ -43,6 +46,13 @@ private File searchTreeFile; private static String defaultSearchTreeFile = "log/searchTree.txt"; private Heuristic heuristic = Heuristic.LEXICOGRAPHIC; + Set<AtomicConcept> allowedConcepts; + Set<AtomicRole> allowedRoles; + Set<AtomicConcept> ignoredConcepts; + Set<AtomicRole> ignoredRoles; + // these are computed as the result of the previous four settings + Set<AtomicConcept> usedConcepts; + Set<AtomicRole> usedRoles; private boolean stop = false; @@ -164,6 +174,7 @@ options.add(new BooleanConfigOption("improveSubsumptionHierarchy", "simplify subsumption hierarchy to reduce search space (see publication for description)", true)); // TODO: replace by a general verbosity option for all components options.add(new BooleanConfigOption("quiet", "may be deprecated soon", false)); + // allowed/ignored concepts/roles could also be a reasoner option (?) options.add(CommonConfigOptions.allowedConcepts()); options.add(CommonConfigOptions.ignoredConcepts()); options.add(CommonConfigOptions.allowedRoles()); @@ -178,6 +189,7 @@ * @see org.dllearner.core.Component#applyConfigEntry(org.dllearner.core.ConfigEntry) */ @Override + @SuppressWarnings({"unchecked"}) public <T> void applyConfigEntry(ConfigEntry<T> entry) throws InvalidConfigOptionValueException { String name = entry.getOptionName(); if(name.equals("writeSearchTree")) @@ -190,7 +202,16 @@ heuristic = Heuristic.LEXICOGRAPHIC; else heuristic = Heuristic.FLEXIBLE; - } + } else if(name.equals("allowedConcepts")) { + allowedConcepts = CommonConfigMappings.getAtomicConceptSet((Set<String>)entry.getValue()); + } else if(name.equals("allowedRoles")) { + allowedRoles = CommonConfigMappings.getAtomicRoleSet((Set<String>)entry.getValue()); + } else if(name.equals("ignoredConcepts")) { + ignoredConcepts = CommonConfigMappings.getAtomicConceptSet((Set<String>)entry.getValue()); + } else if(name.equals("ignoredRoles")) { + ignoredRoles = CommonConfigMappings.getAtomicRoleSet((Set<String>)entry.getValue()); + } + } /* (non-Javadoc) @@ -218,13 +239,29 @@ candidates = new TreeSet<Node>(nodeComparator); // newCandidates = new TreeSet<Node>(nodeComparator); - // TODO: this needs to be changed - Helper.autoDetectConceptsAndRoles(rs); + if(allowedConcepts != null) { + // sanity check to control if no non-existing concepts are in the list + Helper.checkConcepts(rs, allowedConcepts); + usedConcepts = allowedConcepts; + } else if(ignoredConcepts != null) { + usedConcepts = Helper.computeConceptsUsingIgnoreList(rs, ignoredConcepts); + } else { + usedConcepts = Helper.computeConcepts(rs); + } + + if(allowedRoles != null) { + Helper.checkRoles(rs, allowedRoles); + usedRoles = allowedRoles; + } else if(ignoredRoles != null) { + Helper.checkRoles(rs, ignoredRoles); + usedRoles = Helper.difference(rs.getAtomicRoles(), ignoredRoles); + } + // prepare subsumption and role hierarchies, because they are needed // during the run of the algorithm - rs.prepareSubsumptionHierarchy(); + rs.prepareSubsumptionHierarchy(usedConcepts); rs.getSubsumptionHierarchy().improveSubsumptionHierarchy(); - rs.prepareRoleHierarchy(); + rs.prepareRoleHierarchy(usedRoles); } public static String getName() { Modified: trunk/src/dl-learner/org/dllearner/core/CommonConfigMappings.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/CommonConfigMappings.java 2007-10-17 14:28:58 UTC (rev 231) +++ trunk/src/dl-learner/org/dllearner/core/CommonConfigMappings.java 2007-10-17 16:54:24 UTC (rev 232) @@ -23,6 +23,8 @@ import java.util.SortedSet; import java.util.TreeSet; +import org.dllearner.core.dl.AtomicConcept; +import org.dllearner.core.dl.AtomicRole; import org.dllearner.core.dl.Individual; /** @@ -38,4 +40,17 @@ return set; } + public static SortedSet<AtomicConcept> getAtomicConceptSet(Set<String> atomicConcepts) { + SortedSet<AtomicConcept> set = new TreeSet<AtomicConcept>(); + for(String atomicConcept : atomicConcepts) + set.add(new AtomicConcept(atomicConcept)); + return set; + } + + public static SortedSet<AtomicRole> getAtomicRoleSet(Set<String> atomicRoles) { + SortedSet<AtomicRole> set = new TreeSet<AtomicRole>(); + for(String atomicRole : atomicRoles) + set.add(new AtomicRole(atomicRole)); + return set; + } } Modified: trunk/src/dl-learner/org/dllearner/core/CommonConfigOptions.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/CommonConfigOptions.java 2007-10-17 14:28:58 UTC (rev 231) +++ trunk/src/dl-learner/org/dllearner/core/CommonConfigOptions.java 2007-10-17 16:54:24 UTC (rev 232) @@ -20,14 +20,18 @@ package org.dllearner.core; /** + * Contains methods for creating common configuration options, i.e. options + * which are or may be of use for several components. + * * @author Jens Lehmann * */ public final class CommonConfigOptions { - public static final IntegerConfigOption getVerbosityOption() { - // TODO: temporary code - IntegerConfigOption verbosityOption = new IntegerConfigOption("verbosity", "control verbosity of output"); + public static StringConfigOption getVerbosityOption() { + StringConfigOption verbosityOption = new StringConfigOption("verbosity", "control verbosity of output for this component", "warning"); + String[] allowedValues = new String[] {"quiet", "error", "warning", "notice", "info", "debug"}; + verbosityOption.setAllowedValues(allowedValues); return verbosityOption; } Modified: trunk/src/dl-learner/org/dllearner/core/Reasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/Reasoner.java 2007-10-17 14:28:58 UTC (rev 231) +++ trunk/src/dl-learner/org/dllearner/core/Reasoner.java 2007-10-17 16:54:24 UTC (rev 232) @@ -47,8 +47,8 @@ // pro erstelltem ReasoningService bzw. Reasoner aufgerufen werden) // => erstellt auch vereinfachte Sichten auf Subsumptionhierarchie // (siehe einfacher Traversal in Diplomarbeit) - public void prepareSubsumptionHierarchy(); - public void prepareRoleHierarchy() throws ReasoningMethodUnsupportedException; + public void prepareSubsumptionHierarchy(Set<AtomicConcept> allowedConcepts); + public void prepareRoleHierarchy(Set<AtomicRole> allowedRoles) throws ReasoningMethodUnsupportedException; public boolean subsumes(Concept superConcept, Concept subConcept) throws ReasoningMethodUnsupportedException; Modified: trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java 2007-10-17 14:28:58 UTC (rev 231) +++ trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java 2007-10-17 16:54:24 UTC (rev 232) @@ -108,7 +108,7 @@ throw new ReasoningMethodUnsupportedException(); } - public void prepareRoleHierarchy() throws ReasoningMethodUnsupportedException { + public void prepareRoleHierarchy(Set<AtomicRole> allowedRoles) throws ReasoningMethodUnsupportedException { throw new ReasoningMethodUnsupportedException(); } Modified: trunk/src/dl-learner/org/dllearner/core/ReasoningService.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ReasoningService.java 2007-10-17 14:28:58 UTC (rev 231) +++ trunk/src/dl-learner/org/dllearner/core/ReasoningService.java 2007-10-17 16:54:24 UTC (rev 232) @@ -342,8 +342,8 @@ return getRoleHierarchy().getMostSpecialRoles(); } - public void prepareSubsumptionHierarchy() { - reasoner.prepareSubsumptionHierarchy(); + public void prepareSubsumptionHierarchy(Set<AtomicConcept> allowedConcepts) { + reasoner.prepareSubsumptionHierarchy(allowedConcepts); } public SubsumptionHierarchy getSubsumptionHierarchy() { @@ -356,9 +356,9 @@ } } - public void prepareRoleHierarchy() { + public void prepareRoleHierarchy(Set<AtomicRole> allowedRoles) { try { - reasoner.prepareRoleHierarchy(); + reasoner.prepareRoleHierarchy(allowedRoles); } catch (ReasoningMethodUnsupportedException e) { handleExceptions(e); } Modified: trunk/src/dl-learner/org/dllearner/reasoning/DIGReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/DIGReasoner.java 2007-10-17 14:28:58 UTC (rev 231) +++ trunk/src/dl-learner/org/dllearner/reasoning/DIGReasoner.java 2007-10-17 16:54:24 UTC (rev 232) @@ -36,7 +36,6 @@ import javax.xml.namespace.QName; import org.apache.xmlbeans.XmlCursor; -import org.dllearner.Config; import org.dllearner.core.BooleanConfigOption; import org.dllearner.core.ConfigEntry; import org.dllearner.core.ConfigOption; @@ -202,9 +201,9 @@ * Construct a subsumption hierarchy using DIG queries. After calling this * method one can ask for children or parents in the subsumption hierarchy. */ - public void prepareSubsumptionHierarchy() { + public void prepareSubsumptionHierarchy(Set<AtomicConcept> allowedConcepts) { allowedConceptsInSubsumptionHierarchy = new TreeSet<Concept>(conceptComparator); - allowedConceptsInSubsumptionHierarchy.addAll(Config.Refinement.allowedConcepts); + allowedConceptsInSubsumptionHierarchy.addAll(allowedConcepts); allowedConceptsInSubsumptionHierarchy.add(new Top()); allowedConceptsInSubsumptionHierarchy.add(new Bottom()); @@ -237,7 +236,7 @@ subsumptionHierarchyUp.put(atom, tmp); } - subsumptionHierarchy = new SubsumptionHierarchy(Config.Refinement.allowedConcepts, + subsumptionHierarchy = new SubsumptionHierarchy(allowedConcepts, subsumptionHierarchyUp, subsumptionHierarchyDown); } @@ -248,19 +247,19 @@ * @todo Does not yet take ignored roles into account. */ @Override - public void prepareRoleHierarchy() { + public void prepareRoleHierarchy(Set<AtomicRole> allowedRoles) { TreeMap<AtomicRole, TreeSet<AtomicRole>> roleHierarchyUp = new TreeMap<AtomicRole, TreeSet<AtomicRole>>( roleComparator); TreeMap<AtomicRole, TreeSet<AtomicRole>> roleHierarchyDown = new TreeMap<AtomicRole, TreeSet<AtomicRole>>( roleComparator); - + // Refinement atomarer Konzepte for (AtomicRole role : atomicRoles) { roleHierarchyDown.put(role, getMoreSpecialRolesDIG(role)); roleHierarchyUp.put(role, getMoreGeneralRolesDIG(role)); } - roleHierarchy = new RoleHierarchy(Config.Refinement.allowedRoles, roleHierarchyUp, + roleHierarchy = new RoleHierarchy(allowedRoles, roleHierarchyUp, roleHierarchyDown); } Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java 2007-10-17 14:28:58 UTC (rev 231) +++ trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java 2007-10-17 16:54:24 UTC (rev 232) @@ -79,7 +79,7 @@ return abox; } - public void prepareSubsumptionHierarchy() { + public void prepareSubsumptionHierarchy(Set<AtomicConcept> allowedConcepts) { // hier muss nichts getan werden } Modified: trunk/src/dl-learner/org/dllearner/reasoning/KAON2Reasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/KAON2Reasoner.java 2007-10-17 14:28:58 UTC (rev 231) +++ trunk/src/dl-learner/org/dllearner/reasoning/KAON2Reasoner.java 2007-10-17 16:54:24 UTC (rev 232) @@ -248,7 +248,7 @@ // TODO: hier werden momentan keine allowed concepts berücksichtigt // (benötigt rekursive Aufrufe, da ein erlaubtes Konzept von einem nicht // erlaubten verdeckt werden könnte) - public void prepareSubsumptionHierarchy() { + public void prepareSubsumptionHierarchy(Set<AtomicConcept> allowedConcepts) { try { kaon2SubsumptionHierarchy = kaon2Reasoner.getSubsumptionHierarchy(); } catch (KAON2Exception e) { Modified: trunk/src/dl-learner/org/dllearner/utilities/Helper.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/Helper.java 2007-10-17 14:28:58 UTC (rev 231) +++ trunk/src/dl-learner/org/dllearner/utilities/Helper.java 2007-10-17 16:54:24 UTC (rev 232) @@ -1,6 +1,5 @@ package org.dllearner.utilities; -import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; import java.util.List; @@ -11,7 +10,6 @@ import java.util.TreeSet; import java.util.Map.Entry; -import org.dllearner.Config; import org.dllearner.core.ReasoningMethodUnsupportedException; import org.dllearner.core.ReasoningService; import org.dllearner.core.dl.AssertionalAxiom; @@ -28,121 +26,130 @@ import org.dllearner.core.dl.RoleAssertion; /** - * Die Hilfsmethoden benutzen alle SortedSet, da die Operationen damit schneller sind. + * Die Hilfsmethoden benutzen alle SortedSet, da die Operationen damit schneller + * sind. + * * @author jl - * + * */ public class Helper { - + // findet alle atomaren Konzepte in einem Konzept public static List<AtomicConcept> getAtomicConcepts(Concept concept) { List<AtomicConcept> ret = new LinkedList<AtomicConcept>(); - if(concept instanceof AtomicConcept) { - ret.add((AtomicConcept)concept); + if (concept instanceof AtomicConcept) { + ret.add((AtomicConcept) concept); return ret; } else { - for(Concept child : concept.getChildren()) { + for (Concept child : concept.getChildren()) { ret.addAll(getAtomicConcepts(child)); } return ret; } } - + // findet alle atomaren Rollen in einem Konzept public static List<AtomicRole> getAtomicRoles(Concept concept) { List<AtomicRole> ret = new LinkedList<AtomicRole>(); - - if(concept instanceof Quantification) { - ret.add(new AtomicRole(((Quantification)concept).getRole().getName())); - } else if(concept instanceof NumberRestriction) { - ret.add(new AtomicRole(((NumberRestriction)concept).getRole().getName())); + + if (concept instanceof Quantification) { + ret.add(new AtomicRole(((Quantification) concept).getRole().getName())); + } else if (concept instanceof NumberRestriction) { + ret.add(new AtomicRole(((NumberRestriction) concept).getRole().getName())); } - - // auch NumberRestrictions und Quantifications können weitere Rollen enthalten, + + // auch NumberRestrictions und Quantifications können weitere Rollen + // enthalten, // deshalb hier kein else-Zweig - for(Concept child : concept.getChildren()) { + for (Concept child : concept.getChildren()) { ret.addAll(getAtomicRoles(child)); } return ret; - - } - + + } + // sucht, ob der übergebene String mit einem Prefix beginnt der // versteckt werden soll und gibt diesen zurück, ansonsten wird // null zurück gegeben -// public static String findPrefixToHide(String name) { -// for(String prefix : Config.hidePrefixes) { -// if(name.startsWith(prefix)) -// return prefix; -// } -// return null; -// } - + // public static String findPrefixToHide(String name) { + // for(String prefix : Config.hidePrefixes) { + // if(name.startsWith(prefix)) + // return prefix; + // } + // return null; + // } + /** * * Transforms an URI to an abbreviated version, e.g. if the base URI is - * "http://example.com/" and the uri is "http://example.com/test", then + * "http://example.com/" and the uri is "http://example.com/test", then * "test" is returned. If the the uri is "http://anotherexample.com/test2" * and a prefix "ns1" is given for "http://anotherexample.com", then * "ns1:test2" is returned. If there is no match, uri is returned. * - * @param uri The full uri, which should be transformed to an abbreviated version. - * @param baseURI The base uri (ignored if null). - * @param prefixes A prefix map (ignored if null), where each entry contains a short string e.g. ns1 - * as key and the corresponding uri as value. + * @param uri + * The full uri, which should be transformed to an abbreviated + * version. + * @param baseURI + * The base uri (ignored if null). + * @param prefixes + * A prefix map (ignored if null), where each entry contains a + * short string e.g. ns1 as key and the corresponding uri as + * value. * @return Abbreviated version of the parameter uri. */ - public static String getAbbreviatedString(String uri, String baseURI, Map<String,String> prefixes) { - if(baseURI != null && uri.startsWith(baseURI)) { + public static String getAbbreviatedString(String uri, String baseURI, + Map<String, String> prefixes) { + if (baseURI != null && uri.startsWith(baseURI)) { return uri.substring(baseURI.length()); } else { - if(prefixes != null) { - for(Entry<String,String> prefix : prefixes.entrySet()) { - if(uri.startsWith(prefix.getValue())) + if (prefixes != null) { + for (Entry<String, String> prefix : prefixes.entrySet()) { + if (uri.startsWith(prefix.getValue())) return prefix.getKey() + ":" + uri.substring(prefix.getValue().length()); } } return uri; } } - + public static String prettyPrintNanoSeconds(long nanoSeconds) { return prettyPrintNanoSeconds(nanoSeconds, false, false); } - + // formatiert Nano-Sekunden in einen leserlichen String - public static String prettyPrintNanoSeconds(long nanoSeconds, boolean printMicros, boolean printNanos) { + public static String prettyPrintNanoSeconds(long nanoSeconds, boolean printMicros, + boolean printNanos) { // String str = ""; // long seconds = 0; // long milliSeconds = 0; // long microseconds = 0; - - long seconds = nanoSeconds/1000000000; + + long seconds = nanoSeconds / 1000000000; nanoSeconds = nanoSeconds % 1000000000; - - long milliSeconds = nanoSeconds/1000000; + + long milliSeconds = nanoSeconds / 1000000; nanoSeconds = nanoSeconds % 1000000; // Mikrosekunden werden immer angezeigt, Sekunden nur falls größer 0 String str = ""; - if(seconds > 0) + if (seconds > 0) str = seconds + "s "; str += milliSeconds + "ms"; - - if(printMicros) { - long microSeconds = nanoSeconds/1000; - nanoSeconds = nanoSeconds % 1000; + + if (printMicros) { + long microSeconds = nanoSeconds / 1000; + nanoSeconds = nanoSeconds % 1000; str += " " + microSeconds + "usec"; } - if(printNanos) { + if (printNanos) { str += " " + nanoSeconds + "ns"; } - + return str; } - - public static<T1,T2> void addMapEntry(Map<T1, SortedSet<T2>> map, - T1 keyEntry, T2 setEntry) { + + public static <T1, T2> void addMapEntry(Map<T1, SortedSet<T2>> map, T1 keyEntry, T2 setEntry) { if (map.containsKey(keyEntry)) { map.get(keyEntry).add(setEntry); } else { @@ -150,284 +157,393 @@ newSet.add(setEntry); map.put(keyEntry, newSet); } + } + + /** + * Das ist eine "generic method", d.h. die Methode hat einen bestimmten Typ. + * Ich habe das benutzt um allen beteiligten Mengen den gleichen Typ zu + * geben, denn ansonsten ist es nicht möglich der neu zu erzeugenden Menge + * (union) den gleichen Typ wie den Argumenten zu geben. + * + * Die Methode hat gegenüber addAll den Vorteil, dass sie ein neues Objekt + * erzeugt. + * + * @param <T> + * @param set1 + * @param set2 + * @return + */ + public static <T> Set<T> union(Set<T> set1, Set<T> set2) { + // TODO: effizientere Implementierung (längere Liste klonen und Elemente + // anhängen) + Set<T> union = new TreeSet<T>(); + union.addAll(set1); + union.addAll(set2); + return union; + /* + * Set union; if(set1.size()>set2.size()) { union = set1.clone(); } else { + * } return union; + */ + } + + public static <T> SortedSet<T> union(SortedSet<T> set1, SortedSet<T> set2) { + // Set<T> union = set1.clone(); + // ((Cloneable) set1).clone(); + + // TODO: effizientere Implementierung (längere Liste klonen und Elemente + // anhängen) + + // f�r TreeSet gibt es einen Konstruktor, der eine Collection + // entgegennimmt + // und einen weiteren, der ein SortedSet entgegennimmt; vermutlich ist + // letzterer schneller + + SortedSet<T> union; + if (set1.size() > set2.size()) { + union = new TreeSet<T>(set1); + union.addAll(set2); + } else { + union = new TreeSet<T>(set2); + union.addAll(set1); + } + // SortedSet<T> union = new TreeSet<T>(set1); + // union.addAll(set1); + // union.addAll(set2); + return union; + + } + + public static <T> SortedSet<T> intersection(SortedSet<T> set1, SortedSet<T> set2) { + // TreeSet<T> intersection = (TreeSet<T>) set1.clone(); + // TODO: effizienter implementieren d.h. lange Liste klonen und dann + // retainAll + SortedSet<T> intersection = new TreeSet<T>(set1); + // intersection.addAll(set1); + intersection.retainAll(set2); + return intersection; + } + + public static <T> SortedSet<T> intersectionTuple(SortedSet<T> set, SortedSetTuple<T> tuple) { + SortedSet<T> ret = intersection(set, tuple.getPosSet()); + ret.retainAll(tuple.getNegSet()); + return ret; + } + + public static <T> SortedSet<T> difference(SortedSet<T> set1, SortedSet<T> set2) { + // TODO: effizienter implementieren + SortedSet<T> difference = new TreeSet<T>(set1); + // difference.addAll(set1); + difference.removeAll(set2); + return difference; + } + + public static <T> Set<T> difference(Set<T> set1, Set<T> set2) { + // TODO: effizienter implementieren + SortedSet<T> difference = new TreeSet<T>(set1); + // difference.addAll(set1); + difference.removeAll(set2); + return difference; } - /** - * Das ist eine "generic method", d.h. die Methode hat einen bestimmten Typ. - * Ich habe das benutzt um allen beteiligten Mengen den gleichen Typ zu geben, - * denn ansonsten ist es nicht möglich der neu zu erzeugenden Menge (union) den - * gleichen Typ wie den Argumenten zu geben. - * - * Die Methode hat gegenüber addAll den Vorteil, dass sie ein neues Objekt - * erzeugt. - * - * @param <T> - * @param set1 - * @param set2 - * @return - */ - public static<T> Set<T> union(Set<T> set1, Set<T> set2) { - // TODO: effizientere Implementierung (längere Liste klonen und Elemente - // anhängen) - Set<T> union = new TreeSet<T>(); - union.addAll(set1); - union.addAll(set2); - return union; - /* - Set union; - if(set1.size()>set2.size()) { - union = set1.clone(); - } else { - - } - return union; - */ - } - - public static<T> SortedSet<T> union(SortedSet<T> set1, SortedSet<T> set2) { - //Set<T> union = set1.clone(); - //((Cloneable) set1).clone(); - - // TODO: effizientere Implementierung (längere Liste klonen und Elemente - // anhängen) - - // f�r TreeSet gibt es einen Konstruktor, der eine Collection entgegennimmt - // und einen weiteren, der ein SortedSet entgegennimmt; vermutlich ist - // letzterer schneller - - SortedSet<T> union; - if(set1.size()>set2.size()) { - union = new TreeSet<T>(set1); - union.addAll(set2); - } else { - union = new TreeSet<T>(set2); - union.addAll(set1); - } - // SortedSet<T> union = new TreeSet<T>(set1); - // union.addAll(set1); - // union.addAll(set2); - return union; - - } - - public static<T> SortedSet<T> intersection(SortedSet<T> set1, SortedSet<T> set2) { - // TreeSet<T> intersection = (TreeSet<T>) set1.clone(); - // TODO: effizienter implementieren d.h. lange Liste klonen und dann - // retainAll - SortedSet<T> intersection = new TreeSet<T>(set1); - // intersection.addAll(set1); - intersection.retainAll(set2); - return intersection; - } - - public static<T> SortedSet<T> intersectionTuple(SortedSet<T> set, SortedSetTuple<T> tuple) { - SortedSet<T> ret = intersection(set,tuple.getPosSet()); - ret.retainAll(tuple.getNegSet()); - return ret; - } - - public static<T> SortedSet<T> difference(SortedSet<T> set1, SortedSet<T> set2) { - // TODO: effizienter implementieren - SortedSet<T> difference = new TreeSet<T>(set1); - // difference.addAll(set1); - difference.removeAll(set2); - return difference; - } - // Umwandlung von Menge von Individuals auf Menge von Strings public static SortedSet<Individual> getIndividualSet(Set<String> individuals) { SortedSet<Individual> ret = new TreeSet<Individual>(); - for(String s : individuals) { + for (String s : individuals) { ret.add(new Individual(s)); } return ret; - } - + } + public static SortedSetTuple<Individual> getIndividualTuple(SortedSetTuple<String> tuple) { - return new SortedSetTuple<Individual>(getIndividualSet(tuple.getPosSet()),getIndividualSet(tuple.getNegSet())); + return new SortedSetTuple<Individual>(getIndividualSet(tuple.getPosSet()), + getIndividualSet(tuple.getNegSet())); } - + public static SortedSetTuple<String> getStringTuple(SortedSetTuple<Individual> tuple) { - return new SortedSetTuple<String>(getStringSet(tuple.getPosSet()),getStringSet(tuple.getNegSet())); - } - + return new SortedSetTuple<String>(getStringSet(tuple.getPosSet()), getStringSet(tuple + .getNegSet())); + } + // Umwandlung von Menge von Individuals auf Menge von Strings public static SortedSet<String> getStringSet(Set<Individual> individuals) { SortedSet<String> ret = new TreeSet<String>(); - for(Individual i : individuals) { + for (Individual i : individuals) { ret.add(i.getName()); } return ret; } - - public static Map<String,SortedSet<String>> getStringMap(Map<Individual, SortedSet<Individual>> roleMembers) { - Map<String,SortedSet<String>> ret = new TreeMap<String,SortedSet<String>>(); - for(Individual i : roleMembers.keySet()) { + + public static Map<String, SortedSet<String>> getStringMap( + Map<Individual, SortedSet<Individual>> roleMembers) { + Map<String, SortedSet<String>> ret = new TreeMap<String, SortedSet<String>>(); + for (Individual i : roleMembers.keySet()) { ret.put(i.getName(), getStringSet(roleMembers.get(i))); } return ret; } /** - * TODO: - * split in two methods (one for concepts, one for roles), - * document what exactly the method is doing, - * remove dependencies from old Config class, - * incorporate the new methods in the learning algorithms when appropriate - * (common conf options for allowed concepts/roles and forbidden + * TODO: split in two methods (one for concepts, one for roles), document + * what exactly the method is doing, remove dependencies from old Config + * class, incorporate the new methods in the learning algorithms when + * appropriate (common conf options for allowed concepts/roles and forbidden * concepts/roles need to be created) * - * Computes the set of allowed concepts based on configuration settings (also - * ignores anonymous and standard RDF, RDFS, OWL concept produces by Jena). - * + * Computes the set of allowed concepts based on configuration settings + * (also ignores anonymous and standard RDF, RDFS, OWL concept produces by + * Jena). + * + * DEPRECATED METHOD (RELIED ON OLD CONFIG). + * */ - public static void autoDetectConceptsAndRoles(ReasoningService rs) { - // einige Sachen, die momentan nur vom Refinement-Algorithmus - // unterstützt werden (später ev. auch von anderen Algorithmen) - //if (Config.algorithm == Algorithm.REFINEMENT) { - - // berechnen der verwendbaren Konzepte - if (Config.Refinement.allowedConceptsAutoDetect) { - // TODO: Code aus DIG-Reasoner-Klasse einfügen - - Set<AtomicConcept> allowedConceptsTmp = new TreeSet<AtomicConcept>( - new ConceptComparator()); - allowedConceptsTmp.addAll(rs.getAtomicConcepts()); - Iterator<AtomicConcept> it = allowedConceptsTmp.iterator(); - while (it.hasNext()) { - String conceptName = it.next().getName(); - // System.out.println(conceptName); - // seltsame anon-Konzepte, die von Jena erzeugt werden - // löschen - if (conceptName.startsWith("anon")) { - System.out - .println(" Ignoring concept " - + conceptName - + " (probably an anonymous concept produced by Jena when reading in OWL file)."); - it.remove(); - } else if (conceptName - .startsWith("http://www.w3.org/1999/02/22-rdf-syntax-ns#")) { - System.out - .println(" Ignoring concept " - + conceptName - + " (RDF construct produced by Jena when reading in OWL file)."); - it.remove(); - } else if (conceptName - .startsWith("http://www.w3.org/2000/01/rdf-schema#")) { - System.out - .println(" Ignoring concept " - + conceptName - + " (RDF Schema construct produced by Jena when reading in OWL file)."); - it.remove(); - } else if (conceptName.startsWith("http://www.w3.org/2002/07/owl#")) { - System.out - .println(" Ignoring concept " - + conceptName - + " (OWL construct produced by Jena when reading in OWL file)."); - it.remove(); - } - } +// public static void autoDetectConceptsAndRoles(ReasoningService rs) { +// // einige Sachen, die momentan nur vom Refinement-Algorithmus +// // unterstützt werden (später ev. auch von anderen Algorithmen) +// // if (Config.algorithm == Algorithm.REFINEMENT) { +// +// // berechnen der verwendbaren Konzepte +// if (Config.Refinement.allowedConceptsAutoDetect) { +// // TODO: Code aus DIG-Reasoner-Klasse einfügen +// +// Set<AtomicConcept> allowedConceptsTmp = new TreeSet<AtomicConcept>( +// new ConceptComparator()); +// allowedConceptsTmp.addAll(rs.getAtomicConcepts()); +// Iterator<AtomicConcept> it = allowedConceptsTmp.iterator(); +// while (it.hasNext()) { +// String conceptName = it.next().getName(); +// // System.out.println(conceptName); +// // seltsame anon-Konzepte, die von Jena erzeugt werden +// // löschen +// if (conceptName.startsWith("anon")) { +// System.out +// .println(" Ignoring concept " +// + conceptName +// + " (probably an anonymous concept produced by Jena when reading in OWL file)."); +// it.remove(); +// } else if (conceptName.startsWith("http://www.w3.org/1999/02/22-rdf-syntax-ns#")) { +// System.out.println(" Ignoring concept " + conceptName +// + " (RDF construct produced by Jena when reading in OWL file)."); +// it.remove(); +// } else if (conceptName.startsWith("http://www.w3.org/2000/01/rdf-schema#")) { +// System.out.println(" Ignoring concept " + conceptName +// + " (RDF Schema construct produced by Jena when reading in OWL file)."); +// it.remove(); +// } else if (conceptName.startsWith("http://www.w3.org/2002/07/owl#")) { +// System.out.println(" Ignoring concept " + conceptName +// + " (OWL construct produced by Jena when reading in OWL file)."); +// it.remove(); +// } +// } +// +// // hier werden jetzt noch die zu ignorierenden Konzepte entfernt +// if (Config.Refinement.ignoredConcepts != null) { +// +// for (AtomicConcept ac : Config.Refinement.ignoredConcepts) { +// boolean success = allowedConceptsTmp.remove(ac); +// if (!success) { +// System.out.println("Ignored concept " + ac +// + " does not exist in knowledge base."); +// System.exit(0); +// } +// +// } +// } +// +// Config.Refinement.allowedConcepts = allowedConceptsTmp; +// } else { +// // prüfen, ob nur verfügbare Konzepte vom Nutzer gewählt worden +// Set<AtomicConcept> allowed = new HashSet<AtomicConcept>(); +// allowed.addAll(Config.Refinement.allowedConcepts); +// allowed.removeAll(rs.getAtomicConcepts()); +// if (allowed.size() > 0) { +// System.out +// .println("Some of the concepts you told the learner to use in the definition, " +// + "do not exist in the background knowledge: " + allowed); +// System.out.println("Please correct this problem and restart."); +// System.exit(0); +// } +// } +// +// if (Config.Refinement.allowedRolesAutoDetect) { +// Set<AtomicRole> allowedRolesTmp = rs.getAtomicRoles(); +// +// // hier werden jetzt noch die zu ignorierenden Rollen entfernt +// if (Config.Refinement.ignoredRoles != null) { +// +// for (AtomicRole ar : Config.Refinement.ignoredRoles) { +// boolean success = allowedRolesTmp.remove(ar); +// if (!success) { +// System.out.println("Ignored role " + ar +// + " does not exist in knowledge base."); +// System.exit(0); +// } +// +// } +// } +// +// Config.Refinement.allowedRoles = allowedRolesTmp; +// +// } else { +// Set<AtomicRole> allowedR = new HashSet<AtomicRole>(); +// allowedR.addAll(Config.Refinement.allowedRoles); +// +// Set<AtomicRole> existingR = new TreeSet<AtomicRole>(new RoleComparator()); +// existingR.addAll(rs.getAtomicRoles()); +// +// // allowedR.removeAll(rs.getAtomicRoles()); +// allowedR.removeAll(existingR); +// +// if (allowedR.size() > 0) { +// System.out +// .println("Some of the roles you told the learner to use in the definition, " +// + "do not exist in the background knowledge: " + allowedR); +// System.out.println("Please correct this problem and restart."); +// System.out.println(rs.getAtomicRoles()); +// System.out.println(Config.Refinement.allowedRoles); +// System.exit(0); +// } +// +// } +// } + + /** + * Removes concepts, which should be ignored by the learning algorithm. + * (The main reason to use this method is because Jena introduces such + * concepts when ontologies are converted to DIG.) Currently ignored + * concepts are those having prefix "anon" and concepts belonging to + * the RDF, RDFS, OWL standards. + * + * @param concepts + * @return + */ + public static void removeUninterestingConcepts(Set<AtomicConcept> concepts) { + Iterator<AtomicConcept> it = concepts.iterator(); + while (it.hasNext()) { + String conceptName = it.next().getName(); - // hier werden jetzt noch die zu ignorierenden Konzepte entfernt - if(Config.Refinement.ignoredConcepts != null) { - - - for(AtomicConcept ac : Config.Refinement.ignoredConcepts) { - boolean success = allowedConceptsTmp.remove(ac); - if(!success) { - System.out.println("Ignored concept " + ac + " does not exist in knowledge base."); - System.exit(0); - } - - } + // ignore some concepts (possibly produced by Jena) + if (conceptName.startsWith("anon")) { + System.out + .println(" Ignoring concept " + + conceptName + + " (probably an anonymous concept produced by Jena when reading in OWL file)."); + it.remove(); + } else if (conceptName.startsWith("http://www.w3.org/1999/02/22-rdf-syntax-ns#")) { + System.out.println(" Ignoring concept " + conceptName + + " (RDF construct produced by Jena when reading in OWL file)."); + it.remove(); + } else if (conceptName.startsWith("http://www.w3.org/2000/01/rdf-schema#")) { + System.out.println(" Ignoring concept " + conceptName + + " (RDF Schema construct produced by Jena when reading in OWL file)."); + it.remove(); + } else if (conceptName.startsWith("http://www.w3.org/2002/07/owl#")) { + System.out.println(" Ignoring concept " + conceptName + + " (OWL construct produced by Jena when reading in OWL file)."); + it.remove(); } - - Config.Refinement.allowedConcepts = allowedConceptsTmp; - } else { - // prüfen, ob nur verfügbare Konzepte vom Nutzer gewählt worden - Set<AtomicConcept> allowed = new HashSet<AtomicConcept>(); - allowed.addAll(Config.Refinement.allowedConcepts); - allowed.removeAll(rs.getAtomicConcepts()); - if (allowed.size() > 0) { - System.out - .println("Some of the concepts you told the learner to use in the definition, " - + "do not exist in the background knowledge: " - + allowed); - System.out.println("Please correct this problem and restart."); - System.exit(0); - } } + } - if (Config.Refinement.allowedRolesAutoDetect) { - Set<AtomicRole> allowedRolesTmp = rs.getAtomicRoles(); - - // hier werden jetzt noch die zu ignorierenden Rollen entfernt - if(Config.Refinement.ignoredRoles != null) { - - - for(AtomicRole ar : Config.Refinement.ignoredRoles) { - boolean success = allowedRolesTmp.remove(ar); - if(!success) { - System.out.println("Ignored role " + ar + " does not exist in knowledge base."); - System.exit(0); - } - - } - } - - Config.Refinement.allowedRoles = allowedRolesTmp; - - } else { - Set<AtomicRole> allowedR = new HashSet<AtomicRole>(); - allowedR.addAll(Config.Refinement.allowedRoles); + // concepts case 1: no ignore or allowed list + public static Set<AtomicConcept> computeConcepts(ReasoningService rs) { + // if there is no ignore or allowed list, we just ignore the concepts + // of uninteresting namespaces + Set<AtomicConcept> concepts = rs.getAtomicConcepts(); + Helper.removeUninterestingConcepts(concepts); + return concepts; + } - Set<AtomicRole> existingR = new TreeSet<AtomicRole>(new RoleComparator()); - existingR.addAll(rs.getAtomicRoles()); - - // allowedR.removeAll(rs.getAtomicRoles()); - allowedR.removeAll(existingR); - - if (allowedR.size() > 0) { - System.out - .println("Some of the roles you told the learner to use in the definition, " - + "do not exist in the background knowledge: " - + allowedR); - System.out.println("Please correct this problem and restart."); - System.out.println(rs.getAtomicRoles()); - System.out.println(Config.Refinement.allowedRoles); + // concepts case 2: ignore list + public static Set<AtomicConcept> computeConceptsUsingIgnoreList(ReasoningService rs, Set<AtomicConcept> ignoredConcepts) { + Set<AtomicConcept> concepts = rs.getAtomicConcepts(); + Helper.removeUninterestingConcepts(concepts); + for (AtomicConcept ac : ignoredConcepts) { + boolean success = concepts.remove(ac); + if (!success) { + System.out.println("Warning: Ignored concept " + ac + + " does not exist in knowledge base."); System.exit(0); } + } + return concepts; + } + // concepts case 3: allowed list + // superseeded by checkConcepts() +// public static void checkAllowedList(ReasoningService rs, Set<AtomicConcept> allowedConcepts) { +// // check whether allowed concepts exist in knowledgebase(s) +// Set<AtomicConcept> allowed = new HashSet<AtomicConcept>(); +// allowed.addAll(allowedConcepts); +// allowed.removeAll(rs.getAtomicConcepts()); +// if (allowed.size() > 0) { +// System.out +// .println("Some of the concepts you told the learner to use in the definition, " +// + "do not exist in the background knowledge: " + allowed); +// System.out.println("Please correct this problem and restart."); +// System.exit(0); +// } +// } + + /** + * Checks whether the roles exist in background knowledge + * @param roles The roles to check. + * @return The first non-existing role or null if they are all in the + * background knowledge. + */ + // + public static AtomicRole checkRoles(ReasoningService rs, Set<AtomicRole> roles) { + Set<AtomicRole> existingRoles = rs.getAtomicRoles(); + for (AtomicRole ar : roles) { + if(!existingRoles.contains(ar)) + return ar; } + return null; } + + /** + * Checks whether the roles exist in background knowledge + * @param roles The roles to check. + * @return The first non-existing role or null if they are all in the + * background knowledge. + */ + // + public static AtomicConcept checkConcepts(ReasoningService rs, Set<AtomicConcept> concepts) { + Set<AtomicConcept> existingConcepts = rs.getAtomicConcepts(); + for (AtomicConcept ar : concepts) { + if(!existingConcepts.contains(ar)) + return ar; + } + return null; + } // creates a flat ABox by querying a reasoner public static FlatABox createFlatABox(ReasoningService rs) throws ReasoningMethodUnsupportedException { long dematStartTime = System.currentTimeMillis(); - + FlatABox aBox = new FlatABox(); // FlatABox.getInstance(); for (AtomicConcept atomicConcept : rs.getAtomicConcepts()) { - aBox.atomicConceptsPos.put(atomicConcept.getName(), getStringSet(rs.retrieval(atomicConcept))); + aBox.atomicConceptsPos.put(atomicConcept.getName(), getStringSet(rs + .retrieval(atomicConcept))); Negation negatedAtomicConcept = new Negation(atomicConcept); - aBox.atomicConceptsNeg.put(atomicConcept.getName(), getStringSet(rs.retrieval(negatedAtomicConcept))); + aBox.atomicConceptsNeg.put(atomicConcept.getName(), getStringSet(rs + .retrieval(negatedAtomicConcept))); aBox.concepts.add(atomicConcept.getName()); } - + for (AtomicRole atomicRole : rs.getAtomicRoles()) { - aBox.rolesPos.put(atomicRole.getName(), getStringMap(rs - .getRoleMembers(atomicRole))); + aBox.rolesPos.put(atomicRole.getName(), getStringMap(rs.getRoleMembers(atomicRole))); aBox.roles.add(atomicRole.getName()); } - + aBox.domain = getStringSet(rs.getIndividuals()); aBox.top = aBox.domain; // ab hier keine �nderungen mehr an FlatABox aBox.prepare(); - + // System.out.println(aBox); - + long dematDuration = System.currentTimeMillis() - dematStartTime; System.out.println("OK (" + dematDuration + " ms)"); return aBox; @@ -443,7 +559,7 @@ System.out.println("connected individuals: " + connectedIndividuals); // Individual selbst auch entfernen connectedIndividuals.add(individual); - + // zweiter Schritt: entfernen von Rollen- und Konzeptzusicherungen Set<AssertionalAxiom> abox = kb.getAbox(); Iterator<AssertionalAxiom> it = abox.iterator(); @@ -464,9 +580,9 @@ } else throw new RuntimeException(); } - + Set<Individual> inds = kb.findAllIndividuals(); System.out.println("remaining individuals: " + inds); System.out.println(); - } + } } Modified: trunk/src/dl-learner/org/dllearner/utilities/PaperStatistics.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/PaperStatistics.java 2007-10-17 14:28:58 UTC (rev 231) +++ trunk/src/dl-learner/org/dllearner/utilities/PaperStatistics.java 2007-10-17 16:54:24 UTC (rev 232) @@ -35,7 +35,6 @@ import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasonerComponent; -import org.dllearner.core.ReasoningMethodUnsupportedException; import org.dllearner.core.ReasoningService; import org.dllearner.core.Score; import org.dllearner.kb.OWLFile; @@ -200,17 +199,17 @@ // uses the same reasoning object (e.g. the second algorithm may // have a small advantage if the reasoner cached reasoning requests // of the first algorithm) - Helper.autoDetectConceptsAndRoles(rs); - try { - reasoner.prepareSubsumptionHierarchy(); - reasoner.prepareRoleHierarchy(); - // improving the subsumption hierarchy makes only sense - // for the refinement based algorithm - if(algorithmNr==0) - reasoner.getSubsumptionHierarchy().improveSubsumptionHierarchy(); - } catch (ReasoningMethodUnsupportedException e) { - e.printStackTrace(); - } +// Helper.autoDetectConceptsAndRoles(rs); +// try { +// reasoner.prepareSubsumptionHierarchy(); +// reasoner.prepareRoleHierarchy(); +// // improving the subsumption hierarchy makes only sense +// // for the refinement based algorithm +// if(algorithmNr==0) +// reasoner.getSubsumptionHierarchy().improveSubsumptionHierarchy(); +// } catch (ReasoningMethodUnsupportedException e) { +// e.printStackTrace(); +// } LearningAlgorithm learningAlgorithm = null; if(algorithmNr==0) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2007-10-18 17:21:43
|
Revision: 238 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=238&view=rev Author: jenslehmann Date: 2007-10-18 10:21:38 -0700 (Thu, 18 Oct 2007) Log Message: ----------- created config package and moved appropriate classes to it Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/BruteForceLearner.java trunk/src/dl-learner/org/dllearner/algorithms/RandomGuesser.java trunk/src/dl-learner/org/dllearner/algorithms/gp/GP.java trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java trunk/src/dl-learner/org/dllearner/cli/Start.java trunk/src/dl-learner/org/dllearner/core/Component.java trunk/src/dl-learner/org/dllearner/core/ComponentManager.java trunk/src/dl-learner/org/dllearner/core/ComponentPool.java trunk/src/dl-learner/org/dllearner/kb/KBFile.java trunk/src/dl-learner/org/dllearner/kb/OWLFile.java trunk/src/dl-learner/org/dllearner/kb/SparqlEndpoint.java trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLPStrict.java trunk/src/dl-learner/org/dllearner/learningproblems/PosNegLP.java trunk/src/dl-learner/org/dllearner/learningproblems/PosOnlyDefinitionLP.java trunk/src/dl-learner/org/dllearner/learningproblems/PosOnlyInclusionLP.java trunk/src/dl-learner/org/dllearner/reasoning/DIGReasoner.java trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java trunk/src/dl-learner/org/dllearner/reasoning/KAON2Reasoner.java trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/core/config/ trunk/src/dl-learner/org/dllearner/core/config/BooleanConfigOption.java trunk/src/dl-learner/org/dllearner/core/config/CommonConfigMappings.java trunk/src/dl-learner/org/dllearner/core/config/CommonConfigOptions.java trunk/src/dl-learner/org/dllearner/core/config/ConfigDocumentationGenerator.java trunk/src/dl-learner/org/dllearner/core/config/ConfigEntry.java trunk/src/dl-learner/org/dllearner/core/config/ConfigOption.java trunk/src/dl-learner/org/dllearner/core/config/DoubleConfigOption.java trunk/src/dl-learner/org/dllearner/core/config/IntegerConfigOption.java trunk/src/dl-learner/org/dllearner/core/config/InvalidConfigOptionValueException.java trunk/src/dl-learner/org/dllearner/core/config/StringConfigOption.java trunk/src/dl-learner/org/dllearner/core/config/StringSetConfigOption.java trunk/src/dl-learner/org/dllearner/core/config/UnknownConfigOptionException.java Removed Paths: ------------- trunk/src/dl-learner/org/dllearner/core/BooleanConfigOption.java trunk/src/dl-learner/org/dllearner/core/CommonConfigMappings.java trunk/src/dl-learner/org/dllearner/core/CommonConfigOptions.java trunk/src/dl-learner/org/dllearner/core/ConfigDocumentationGenerator.java trunk/src/dl-learner/org/dllearner/core/ConfigEntry.java trunk/src/dl-learner/org/dllearner/core/ConfigOption.java trunk/src/dl-learner/org/dllearner/core/DoubleConfigOption.java trunk/src/dl-learner/org/dllearner/core/IntegerConfigOption.java trunk/src/dl-learner/org/dllearner/core/InvalidConfigOptionValueException.java trunk/src/dl-learner/org/dllearner/core/StringConfigOption.java trunk/src/dl-learner/org/dllearner/core/StringSetConfigOption.java trunk/src/dl-learner/org/dllearner/core/UnknownConfigOptionException.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/BruteForceLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/BruteForceLearner.java 2007-10-18 16:24:22 UTC (rev 237) +++ trunk/src/dl-learner/org/dllearner/algorithms/BruteForceLearner.java 2007-10-18 17:21:38 UTC (rev 238) @@ -26,15 +26,15 @@ import java.util.List; import java.util.Map; -import org.dllearner.core.CommonConfigOptions; -import org.dllearner.core.ConfigEntry; -import org.dllearner.core.ConfigOption; -import org.dllearner.core.IntegerConfigOption; -import org.dllearner.core.InvalidConfigOptionValueException; import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasoningService; import org.dllearner.core.Score; +import org.dllearner.core.config.CommonConfigOptions; +import org.dllearner.core.config.ConfigEntry; +import org.dllearner.core.config.ConfigOption; +import org.dllearner.core.config.IntegerConfigOption; +import org.dllearner.core.config.InvalidConfigOptionValueException; import org.dllearner.core.dl.All; import org.dllearner.core.dl.AtomicConcept; import org.dllearner.core.dl.AtomicRole; Modified: trunk/src/dl-learner/org/dllearner/algorithms/RandomGuesser.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/RandomGuesser.java 2007-10-18 16:24:22 UTC (rev 237) +++ trunk/src/dl-learner/org/dllearner/algorithms/RandomGuesser.java 2007-10-18 17:21:38 UTC (rev 238) @@ -24,14 +24,14 @@ import org.dllearner.algorithms.gp.Program; import org.dllearner.algorithms.gp.GPUtilities; -import org.dllearner.core.ConfigEntry; -import org.dllearner.core.ConfigOption; -import org.dllearner.core.IntegerConfigOption; -import org.dllearner.core.InvalidConfigOptionValueException; import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasoningService; import org.dllearner.core.Score; +import org.dllearner.core.config.ConfigEntry; +import org.dllearner.core.config.ConfigOption; +import org.dllearner.core.config.IntegerConfigOption; +import org.dllearner.core.config.InvalidConfigOptionValueException; import org.dllearner.core.dl.Concept; public class RandomGuesser extends LearningAlgorithm { Modified: trunk/src/dl-learner/org/dllearner/algorithms/gp/GP.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/gp/GP.java 2007-10-18 16:24:22 UTC (rev 237) +++ trunk/src/dl-learner/org/dllearner/algorithms/gp/GP.java 2007-10-18 17:21:38 UTC (rev 238) @@ -47,16 +47,16 @@ import org.dllearner.Config; import org.dllearner.algorithms.hybridgp.Psi; -import org.dllearner.core.BooleanConfigOption; -import org.dllearner.core.ConfigEntry; -import org.dllearner.core.ConfigOption; -import org.dllearner.core.DoubleConfigOption; -import org.dllearner.core.IntegerConfigOption; -import org.dllearner.core.InvalidConfigOptionValueException; import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.LearningProblem; import org.dllearner.core.Score; -import org.dllearner.core.StringConfigOption; +import org.dllearner.core.config.BooleanConfigOption; +import org.dllearner.core.config.ConfigEntry; +import org.dllearner.core.config.ConfigOption; +import org.dllearner.core.config.DoubleConfigOption; +import org.dllearner.core.config.IntegerConfigOption; +import org.dllearner.core.config.InvalidConfigOptionValueException; +import org.dllearner.core.config.StringConfigOption; import org.dllearner.core.dl.Concept; import org.dllearner.core.dl.Top; import org.dllearner.learningproblems.PosNegLP; Modified: trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2007-10-18 16:24:22 UTC (rev 237) +++ trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2007-10-18 17:21:38 UTC (rev 238) @@ -12,18 +12,18 @@ import java.util.TreeSet; import org.dllearner.Config; -import org.dllearner.core.BooleanConfigOption; -import org.dllearner.core.CommonConfigMappings; -import org.dllearner.core.CommonConfigOptions; -import org.dllearner.core.ConfigEntry; -import org.dllearner.core.ConfigOption; -import org.dllearner.core.DoubleConfigOption; -import org.dllearner.core.InvalidConfigOptionValueException; import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasoningService; import org.dllearner.core.Score; -import org.dllearner.core.StringConfigOption; +import org.dllearner.core.config.BooleanConfigOption; +import org.dllearner.core.config.CommonConfigMappings; +import org.dllearner.core.config.CommonConfigOptions; +import org.dllearner.core.config.ConfigEntry; +import org.dllearner.core.config.ConfigOption; +import org.dllearner.core.config.DoubleConfigOption; +import org.dllearner.core.config.InvalidConfigOptionValueException; +import org.dllearner.core.config.StringConfigOption; import org.dllearner.core.dl.AtomicConcept; import org.dllearner.core.dl.AtomicRole; import org.dllearner.core.dl.Concept; Modified: trunk/src/dl-learner/org/dllearner/cli/Start.java =================================================================== --- trunk/src/dl-learner/org/dllearner/cli/Start.java 2007-10-18 16:24:22 UTC (rev 237) +++ trunk/src/dl-learner/org/dllearner/cli/Start.java 2007-10-18 17:21:38 UTC (rev 238) @@ -36,22 +36,22 @@ import org.dllearner.algorithms.gp.GP; import org.dllearner.algorithms.refinement.ROLearner; -import org.dllearner.core.BooleanConfigOption; import org.dllearner.core.Component; import org.dllearner.core.ComponentManager; -import org.dllearner.core.ConfigEntry; -import org.dllearner.core.ConfigOption; -import org.dllearner.core.DoubleConfigOption; -import org.dllearner.core.IntegerConfigOption; -import org.dllearner.core.InvalidConfigOptionValueException; import org.dllearner.core.KnowledgeSource; import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasonerComponent; import org.dllearner.core.ReasoningService; import org.dllearner.core.Score; -import org.dllearner.core.StringConfigOption; -import org.dllearner.core.StringSetConfigOption; +import org.dllearner.core.config.BooleanConfigOption; +import org.dllearner.core.config.ConfigEntry; +import org.dllearner.core.config.ConfigOption; +import org.dllearner.core.config.DoubleConfigOption; +import org.dllearner.core.config.IntegerConfigOption; +import org.dllearner.core.config.InvalidConfigOptionValueException; +import org.dllearner.core.config.StringConfigOption; +import org.dllearner.core.config.StringSetConfigOption; import org.dllearner.core.dl.AtomicConcept; import org.dllearner.core.dl.AtomicRole; import org.dllearner.core.dl.Concept; Deleted: trunk/src/dl-learner/org/dllearner/core/BooleanConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/BooleanConfigOption.java 2007-10-18 16:24:22 UTC (rev 237) +++ trunk/src/dl-learner/org/dllearner/core/BooleanConfigOption.java 2007-10-18 17:21:38 UTC (rev 238) @@ -1,52 +0,0 @@ -/** - * Copyright (C) 2007, Jens Lehmann - * - * This file is part of DL-Learner. - * - * DL-Learner is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * DL-Learner is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ -package org.dllearner.core; - -/** - * @author Jens Lehmann - * - */ -public class BooleanConfigOption extends ConfigOption<Boolean> { - - public BooleanConfigOption(String name, String description) { - super(name, description); - } - - public BooleanConfigOption(String name, String description, boolean defaultValue) { - super(name, description, defaultValue); - } - - /* (non-Javadoc) - * @see org.dllearner.core.ConfigOption#checkType(java.lang.Object) - */ - @Override - public boolean checkType(Object object) { - return (object instanceof Boolean); - } - - /* (non-Javadoc) - * @see org.dllearner.core.ConfigOption#isValidValue(java.lang.Object) - */ - @Override - public boolean isValidValue(Boolean value) { - return true; - } - -} Deleted: trunk/src/dl-learner/org/dllearner/core/CommonConfigMappings.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/CommonConfigMappings.java 2007-10-18 16:24:22 UTC (rev 237) +++ trunk/src/dl-learner/org/dllearner/core/CommonConfigMappings.java 2007-10-18 17:21:38 UTC (rev 238) @@ -1,56 +0,0 @@ -/** - * Copyright (C) 2007, Jens Lehmann - * - * This file is part of DL-Learner. - * - * DL-Learner is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * DL-Learner is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ -package org.dllearner.core; - -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; - -import org.dllearner.core.dl.AtomicConcept; -import org.dllearner.core.dl.AtomicRole; -import org.dllearner.core.dl.Individual; - -/** - * @author Jens Lehmann - * - */ -public class CommonConfigMappings { - - public static SortedSet<Individual> getIndividualSet(Set<String> individuals) { - SortedSet<Individual> set = new TreeSet<Individual>(); - for(String individual : individuals) - set.add(new Individual(individual)); - return set; - } - - public static SortedSet<AtomicConcept> getAtomicConceptSet(Set<String> atomicConcepts) { - SortedSet<AtomicConcept> set = new TreeSet<AtomicConcept>(); - for(String atomicConcept : atomicConcepts) - set.add(new AtomicConcept(atomicConcept)); - return set; - } - - public static SortedSet<AtomicRole> getAtomicRoleSet(Set<String> atomicRoles) { - SortedSet<AtomicRole> set = new TreeSet<AtomicRole>(); - for(String atomicRole : atomicRoles) - set.add(new AtomicRole(atomicRole)); - return set; - } -} Deleted: trunk/src/dl-learner/org/dllearner/core/CommonConfigOptions.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/CommonConfigOptions.java 2007-10-18 16:24:22 UTC (rev 237) +++ trunk/src/dl-learner/org/dllearner/core/CommonConfigOptions.java 2007-10-18 17:21:38 UTC (rev 238) @@ -1,84 +0,0 @@ -/** - * Copyright (C) 2007, Jens Lehmann - * - * This file is part of DL-Learner. - * - * DL-Learner is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * DL-Learner is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ -package org.dllearner.core; - -/** - * Contains methods for creating common configuration options, i.e. options - * which are or may be of use for several components. - * - * @author Jens Lehmann - * - */ -public final class CommonConfigOptions { - - public static StringConfigOption getVerbosityOption() { - StringConfigOption verbosityOption = new StringConfigOption("verbosity", "control verbosity of output for this component", "warning"); - String[] allowedValues = new String[] {"quiet", "error", "warning", "notice", "info", "debug"}; - verbosityOption.setAllowedValues(allowedValues); - return verbosityOption; - } - - public static DoubleConfigOption getPercentPerLenghtUnitOption(double defaultValue) { - DoubleConfigOption option = new DoubleConfigOption("percentPerLenghtUnit", "describes the reduction in classification accuracy in percent one is willing to accept for reducing the length of the concept by one", defaultValue); - option.setLowerLimit(0.0); - option.setUpperLimit(1.0); - return option; - } - - public static StringConfigOption getReturnType() { - return new StringConfigOption("returnType", "Specifies the type which the solution has to belong to (if already) known. This means we inform the learning algorithm that the solution is a subclass of this type."); - } - - public static BooleanConfigOption getUNA() { - return new BooleanConfigOption("una", "unique names assumption", false); - } - - public static BooleanConfigOption getOWA() { - return new BooleanConfigOption("owa", "open world assumption (if set to false, we try to close the world", true); - } - - public static StringSetConfigOption allowedConcepts() { - return new StringSetConfigOption("allowedConcepts", "concepts the algorithm is allowed to use"); - } - - public static StringSetConfigOption allowedRoles() { - return new StringSetConfigOption("allowedRoles", "roles the algorithm is allowed to use"); - } - - public static StringSetConfigOption ignoredConcepts() { - return new StringSetConfigOption("ignoredConcepts", "concepts the algorithm must ignore"); - } - - public static StringSetConfigOption ignoredRoles() { - return new StringSetConfigOption("ignoredRoles", "roles the algorithm must ignore"); - } - - public static BooleanConfigOption useAllConstructor() { - return new BooleanConfigOption("useAllConstructor", "specifies whether to universal concept constructor is used in the learning algorothm"); - } - - public static BooleanConfigOption useExistsConstructor() { - return new BooleanConfigOption("useExistsConstructor", "specifies whether to existential concept constructor is used in the learning algorothm"); - } - - public static BooleanConfigOption useNegation() { - return new BooleanConfigOption("useNegation", "specifies whether negation is used in the learning algorothm"); - } -} Modified: trunk/src/dl-learner/org/dllearner/core/Component.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/Component.java 2007-10-18 16:24:22 UTC (rev 237) +++ trunk/src/dl-learner/org/dllearner/core/Component.java 2007-10-18 17:21:38 UTC (rev 238) @@ -22,6 +22,10 @@ import java.util.Collection; import java.util.LinkedList; +import org.dllearner.core.config.ConfigEntry; +import org.dllearner.core.config.ConfigOption; +import org.dllearner.core.config.InvalidConfigOptionValueException; + /** * General component base class. * Modified: trunk/src/dl-learner/org/dllearner/core/ComponentManager.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ComponentManager.java 2007-10-18 16:24:22 UTC (rev 237) +++ trunk/src/dl-learner/org/dllearner/core/ComponentManager.java 2007-10-18 17:21:38 UTC (rev 238) @@ -39,6 +39,9 @@ import java.util.TreeMap; import java.util.TreeSet; +import org.dllearner.core.config.ConfigEntry; +import org.dllearner.core.config.ConfigOption; +import org.dllearner.core.config.InvalidConfigOptionValueException; import org.dllearner.utilities.Files; /** Modified: trunk/src/dl-learner/org/dllearner/core/ComponentPool.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ComponentPool.java 2007-10-18 16:24:22 UTC (rev 237) +++ trunk/src/dl-learner/org/dllearner/core/ComponentPool.java 2007-10-18 17:21:38 UTC (rev 238) @@ -24,6 +24,9 @@ import java.util.List; import java.util.Map; +import org.dllearner.core.config.ConfigEntry; +import org.dllearner.core.config.ConfigOption; + /** * Stores all live components and the configuration options, which were * applied to them. Deleted: trunk/src/dl-learner/org/dllearner/core/ConfigDocumentationGenerator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ConfigDocumentationGenerator.java 2007-10-18 16:24:22 UTC (rev 237) +++ trunk/src/dl-learner/org/dllearner/core/ConfigDocumentationGenerator.java 2007-10-18 17:21:38 UTC (rev 238) @@ -1,43 +0,0 @@ -/** - * Copyright (C) 2007, Jens Lehmann - * - * This file is part of DL-Learner. - * - * DL-Learner is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * DL-Learner is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ -package org.dllearner.core; - -import java.io.File; - -/** - * Collects information about all used configuration options and - * writes them into a file. This way the documentation is always - * in sync with the source code. - * - * @author Jens Lehmann - * - */ -public class ConfigDocumentationGenerator { - - /** - * @param args - */ - public static void main(String[] args) { - File file = new File("doc/configOptions.txt"); - ComponentManager cm = ComponentManager.getInstance(); - cm.writeConfigDocumentation(file); - } - -} Deleted: trunk/src/dl-learner/org/dllearner/core/ConfigEntry.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ConfigEntry.java 2007-10-18 16:24:22 UTC (rev 237) +++ trunk/src/dl-learner/org/dllearner/core/ConfigEntry.java 2007-10-18 17:21:38 UTC (rev 238) @@ -1,54 +0,0 @@ -/** - * Copyright (C) 2007, Jens Lehmann - * - * This file is part of DL-Learner. - * - * DL-Learner is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * DL-Learner is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ -package org.dllearner.core; - -/** - * A config entry is a configuration option and a value for the option. - * - * @author Jens Lehmann - * - */ -public class ConfigEntry<T> { - - private ConfigOption<T> option; - private T value; - - public ConfigEntry(ConfigOption<T> option, T value) throws InvalidConfigOptionValueException { - if(!option.isValidValue(value)) { - throw new InvalidConfigOptionValueException(option, value); - } else { - this.option = option; - this.value = value; - } - } - - public ConfigOption<T> getOption() { - return option; - } - - public String getOptionName() { - return option.getName(); - } - - public T getValue() { - return value; - } - -} Deleted: trunk/src/dl-learner/org/dllearner/core/ConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ConfigOption.java 2007-10-18 16:24:22 UTC (rev 237) +++ trunk/src/dl-learner/org/dllearner/core/ConfigOption.java 2007-10-18 17:21:38 UTC (rev 238) @@ -1,88 +0,0 @@ -/** - * Copyright (C) 2007, Jens Lehmann - * - * This file is part of DL-Learner. - * - * DL-Learner is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * DL-Learner is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ -package org.dllearner.core; - -/** - * This class represents a configuration option (without a value for the - * option). - * - * Note: Currently, handling the type of a configuration option is not - * straightforward to implement, because Java Generics information is - * erased at runtime. This will be fixed in Java 7, in particular JSR 308, - * which is due at approx. the end of 2008. - * - * @author Jens Lehmann - * - */ -public abstract class ConfigOption<T> { - - protected String name; - - protected String description; - - protected T defaultValue; - - public ConfigOption(String name, String description) { - this(name, description, null); - } - - public ConfigOption(String name, String description, T defaultValue) { - this.name = name; - this.description = description; - this.defaultValue = defaultValue; - } - - public String getName() { - return name; - } - - public String getDescription() { - return description; - } - - /** - * @return the defaultValue - */ - public T getDefaultValue() { - return defaultValue; - } - - /** - * Checks whether the object has the correct type to be used as - * a value for this option (this method is necessary, because - * generic information is erased at runtime in Java). - * - * @param object The object to check. - * @return - */ - public abstract boolean checkType(Object object); - - public abstract boolean isValidValue(T value); - - public String getAllowedValuesDescription() { - return getClass().toString(); - } - - @Override - public String toString() { - return "option name: " + name + "\ndescription: " + description + "\nvalues: " + getAllowedValuesDescription() + "\ndefault value: " + defaultValue + "\n"; - } - -} Deleted: trunk/src/dl-learner/org/dllearner/core/DoubleConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/DoubleConfigOption.java 2007-10-18 16:24:22 UTC (rev 237) +++ trunk/src/dl-learner/org/dllearner/core/DoubleConfigOption.java 2007-10-18 17:21:38 UTC (rev 238) @@ -1,99 +0,0 @@ -/** - * Copyright (C) 2007, Jens Lehmann - * - * This file is part of DL-Learner. - * - * DL-Learner is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * DL-Learner is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ -package org.dllearner.core; - -/** - * Represents a configuration option with values of type value. Similar - * to the integer option a minimum and a maximum value can specified. - * - * @author Jens Lehmann - * - */ -public class DoubleConfigOption extends ConfigOption<Double> { - - private double lowerLimit = Double.MIN_VALUE; - private double upperLimit = Double.MAX_VALUE; - - public DoubleConfigOption(String name, String description) { - super(name, description); - } - - public DoubleConfigOption(String name, String description, double defaultValue) { - super(name, description, defaultValue); - } - - /* (non-Javadoc) - * @see org.dllearner.core.ConfigOption#isValidValue(java.lang.Object) - */ - @Override - public boolean isValidValue(Double value) { - if(value >= lowerLimit && value <= upperLimit) - return true; - else - return false; - } - - /** - * @return the The lowest possible value for this configuration option. - */ - public double getLowerLimit() { - return lowerLimit; - } - - /** - * @param lowerLimit The lowest possible value for this configuration option. - */ - public void setLowerLimit(double lowerLimit) { - this.lowerLimit = lowerLimit; - } - - /** - * @return the The highest possible value for this configuration option. - */ - public double getUpperLimit() { - return upperLimit; - } - - /** - * @param upperLimit The highest possible value for this configuration option. - */ - public void setUpperLimit(double upperLimit) { - this.upperLimit = upperLimit; - } - - /* (non-Javadoc) - * @see org.dllearner.core.ConfigOption#checkType(java.lang.Object) - */ - @Override - public boolean checkType(Object object) { - return (object instanceof Double); - } - - @Override - public String getAllowedValuesDescription() { - String str = getClass().toString(); - if(lowerLimit != Double.MIN_VALUE) - str += " min " + lowerLimit; - if(upperLimit != Double.MAX_VALUE) - str += " max " + upperLimit; - return str; - } - -} Deleted: trunk/src/dl-learner/org/dllearner/core/IntegerConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/IntegerConfigOption.java 2007-10-18 16:24:22 UTC (rev 237) +++ trunk/src/dl-learner/org/dllearner/core/IntegerConfigOption.java 2007-10-18 17:21:38 UTC (rev 238) @@ -1,99 +0,0 @@ -/** - * Copyright (C) 2007, Jens Lehmann - * - * This file is part of DL-Learner. - * - * DL-Learner is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * DL-Learner is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ -package org.dllearner.core; - -/** - * A configuration option, which allows values of type integer. A minimum and - * maximum value of the argument can optionally be specified. - * - * @author Jens Lehmann - * - */ -public class IntegerConfigOption extends ConfigOption<Integer> { - - private int lowerLimit = Integer.MIN_VALUE; - private int upperLimit = Integer.MAX_VALUE; - - public IntegerConfigOption(String name, String description) { - super(name, description); - } - - public IntegerConfigOption(String name, String description, int defaultValue) { - super(name, description, defaultValue); - } - - /* (non-Javadoc) - * @see org.dllearner.core.ConfigOption#isValidValue(java.lang.Object) - */ - @Override - public boolean isValidValue(Integer value) { - if(value >= lowerLimit && value <= upperLimit) - return true; - else - return false; - } - - /** - * @return the The lowest possible value for this configuration option. - */ - public int getLowerLimit() { - return lowerLimit; - } - - /** - * @param lowerLimit The lowest possible value for this configuration option. - */ - public void setLowerLimit(int lowerLimit) { - this.lowerLimit = lowerLimit; - } - - /** - * @return the The highest possible value for this configuration option. - */ - public int getUpperLimit() { - return upperLimit; - } - - /** - * @param upperLimit The highest possible value for this configuration option. - */ - public void setUpperLimit(int upperLimit) { - this.upperLimit = upperLimit; - } - - /* (non-Javadoc) - * @see org.dllearner.core.ConfigOption#checkType(java.lang.Object) - */ - @Override - public boolean checkType(Object object) { - return (object instanceof Integer); - } - - @Override - public String getAllowedValuesDescription() { - String str = getClass().toString(); - if(lowerLimit != Integer.MIN_VALUE) - str += " min " + lowerLimit; - if(upperLimit != Integer.MAX_VALUE) - str += " max " + upperLimit; - return str; - } - -} Deleted: trunk/src/dl-learner/org/dllearner/core/InvalidConfigOptionValueException.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/InvalidConfigOptionValueException.java 2007-10-18 16:24:22 UTC (rev 237) +++ trunk/src/dl-learner/org/dllearner/core/InvalidConfigOptionValueException.java 2007-10-18 17:21:38 UTC (rev 238) @@ -1,38 +0,0 @@ -/** - * Copyright (C) 2007, Jens Lehmann - * - * This file is part of DL-Learner. - * - * DL-Learner is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * DL-Learner is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ -package org.dllearner.core; - -/** - * @author Jens Lehmann - * - */ -public class InvalidConfigOptionValueException extends Exception { - - private static final long serialVersionUID = 3286110428258072698L; - - public InvalidConfigOptionValueException(ConfigOption<?> option, Object value) { - super("The value " + value + " is not valid for the configuration option " + option + "."); - } - - public InvalidConfigOptionValueException(ConfigOption<?> option, Object value, String reason) { - super("The value " + value + " is not valid for the configuration option " + option + ". Reason: " + reason + "."); - } - -} Deleted: trunk/src/dl-learner/org/dllearner/core/StringConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/StringConfigOption.java 2007-10-18 16:24:22 UTC (rev 237) +++ trunk/src/dl-learner/org/dllearner/core/StringConfigOption.java 2007-10-18 17:21:38 UTC (rev 238) @@ -1,82 +0,0 @@ -/** - * Copyright (C) 2007, Jens Lehmann - * - * This file is part of DL-Learner. - * - * DL-Learner is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * DL-Learner is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ -package org.dllearner.core; - -import java.util.Arrays; -import java.util.Set; -import java.util.TreeSet; - -/** - * A configuration option, which allows values of type String. Optionally a set - * of allowed strings can be set. By default all strings are allowed. - * - * @author Jens Lehmann - * - */ -public class StringConfigOption extends ConfigOption<String> { - - private Set<String> allowedValues = new TreeSet<String>();; - - public StringConfigOption(String name, String description) { - super(name, description); - } - - public StringConfigOption(String name, String description, String defaultValue) { - super(name, description, defaultValue); - } - - /* (non-Javadoc) - * @see org.dllearner.core.ConfigOption#isValidValue(java.lang.Object) - */ - @Override - public boolean isValidValue(String value) { - if(allowedValues.size() == 0 || allowedValues.contains(value)) - return true; - else - return false; - } - - /** - * @return the allowedValues - */ - public Set<String> getAllowedValues() { - return allowedValues; - } - - /** - * @param allowedValues the allowedValues to set - */ - public void setAllowedValues(Set<String> allowedValues) { - this.allowedValues = allowedValues; - } - - public void setAllowedValues(String[] allowedValues) { - this.allowedValues = new TreeSet<String>(Arrays.asList(allowedValues)); - } - - /* (non-Javadoc) - * @see org.dllearner.core.ConfigOption#checkType(java.lang.Object) - */ - @Override - public boolean checkType(Object object) { - return (object instanceof String); - } - -} Deleted: trunk/src/dl-learner/org/dllearner/core/StringSetConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/StringSetConfigOption.java 2007-10-18 16:24:22 UTC (rev 237) +++ trunk/src/dl-learner/org/dllearner/core/StringSetConfigOption.java 2007-10-18 17:21:38 UTC (rev 238) @@ -1,59 +0,0 @@ -/** - * Copyright (C) 2007, Jens Lehmann - * - * This file is part of DL-Learner. - * - * DL-Learner is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * DL-Learner is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ -package org.dllearner.core; - -import java.util.Set; - -/** - * @author Jens Lehmann - * - */ -public class StringSetConfigOption extends ConfigOption<Set<String>> { - - public StringSetConfigOption(String name, String description) { - super(name, description); - } - - /* (non-Javadoc) - * @see org.dllearner.core.ConfigOption#isValidValue(java.lang.Object) - */ - @Override - public boolean isValidValue(Set<String> value) { - return true; - } - - /* (non-Javadoc) - * @see org.dllearner.core.ConfigOption#checkType(java.lang.Object) - */ - @Override - public boolean checkType(Object object) { - if(!(object instanceof Set)) - return false; - - Set<?> set = (Set<?>) object; - for(Object element : set) { - if(!(element instanceof String)) - return false; - } - - return true; - } - -} Deleted: trunk/src/dl-learner/org/dllearner/core/UnknownConfigOptionException.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/UnknownConfigOptionException.java 2007-10-18 16:24:22 UTC (rev 237) +++ trunk/src/dl-learner/org/dllearner/core/UnknownConfigOptionException.java 2007-10-18 17:21:38 UTC (rev 238) @@ -1,38 +0,0 @@ -/** - * Copyright (C) 2007, Jens Lehmann - * - * This file is part of DL-Learner. - * - * DL-Learner is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * DL-Learner is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ -package org.dllearner.core; - -/** - * @author Jens Lehmann - * - */ -public class UnknownConfigOptionException extends Exception { - - private static final long serialVersionUID = -7808637210577591687L; - - public UnknownConfigOptionException(Class<? extends Component> componentClass, String optionName) { - super("Option " + optionName + " unknown in component " + ComponentManager.getInstance().getComponentName(componentClass) + "(" + componentClass.getName() + ")"); - } - - public UnknownConfigOptionException(Class<? extends Component> componentClass, ConfigOption<?> option) { - super("Option " + option.getName() + " unknown in component " + ComponentManager.getInstance().getComponentName(componentClass) + "(" + componentClass.getName() + ")"); - } - -} Copied: trunk/src/dl-learner/org/dllearner/core/config/BooleanConfigOption.java (from rev 236, trunk/src/dl-learner/org/dllearner/core/BooleanConfigOption.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/BooleanConfigOption.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/config/BooleanConfigOption.java 2007-10-18 17:21:38 UTC (rev 238) @@ -0,0 +1,53 @@ +/** + * Copyright (C) 2007, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package org.dllearner.core.config; + + +/** + * @author Jens Lehmann + * + */ +public class BooleanConfigOption extends ConfigOption<Boolean> { + + public BooleanConfigOption(String name, String description) { + super(name, description); + } + + public BooleanConfigOption(String name, String description, boolean defaultValue) { + super(name, description, defaultValue); + } + + /* (non-Javadoc) + * @see org.dllearner.core.ConfigOption#checkType(java.lang.Object) + */ + @Override + public boolean checkType(Object object) { + return (object instanceof Boolean); + } + + /* (non-Javadoc) + * @see org.dllearner.core.ConfigOption#isValidValue(java.lang.Object) + */ + @Override + public boolean isValidValue(Boolean value) { + return true; + } + +} Copied: trunk/src/dl-learner/org/dllearner/core/config/CommonConfigMappings.java (from rev 236, trunk/src/dl-learner/org/dllearner/core/CommonConfigMappings.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/CommonConfigMappings.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/config/CommonConfigMappings.java 2007-10-18 17:21:38 UTC (rev 238) @@ -0,0 +1,56 @@ +/** + * Copyright (C) 2007, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package org.dllearner.core.config; + +import java.util.Set; +import java.util.SortedSet; +import java.util.TreeSet; + +import org.dllearner.core.dl.AtomicConcept; +import org.dllearner.core.dl.AtomicRole; +import org.dllearner.core.dl.Individual; + +/** + * @author Jens Lehmann + * + */ +public class CommonConfigMappings { + + public static SortedSet<Individual> getIndividualSet(Set<String> individuals) { + SortedSet<Individual> set = new TreeSet<Individual>(); + for(String individual : individuals) + set.add(new Individual(individual)); + return set; + } + + public static SortedSet<AtomicConcept> getAtomicConceptSet(Set<String> atomicConcepts) { + SortedSet<AtomicConcept> set = new TreeSet<AtomicConcept>(); + for(String atomicConcept : atomicConcepts) + set.add(new AtomicConcept(atomicConcept)); + return set; + } + + public static SortedSet<AtomicRole> getAtomicRoleSet(Set<String> atomicRoles) { + SortedSet<AtomicRole> set = new TreeSet<AtomicRole>(); + for(String atomicRole : atomicRoles) + set.add(new AtomicRole(atomicRole)); + return set; + } +} Copied: trunk/src/dl-learner/org/dllearner/core/config/CommonConfigOptions.java (from rev 236, trunk/src/dl-learner/org/dllearner/core/CommonConfigOptions.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/CommonConfigOptions.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/config/CommonConfigOptions.java 2007-10-18 17:21:38 UTC (rev 238) @@ -0,0 +1,85 @@ +/** + * Copyright (C) 2007, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package org.dllearner.core.config; + + +/** + * Contains methods for creating common configuration options, i.e. options + * which are or may be of use for several components. + * + * @author Jens Lehmann + * + */ +public final class CommonConfigOptions { + + public static StringConfigOption getVerbosityOption() { + StringConfigOption verbosityOption = new StringConfigOption("verbosity", "control verbosity of output for this component", "warning"); + String[] allowedValues = new String[] {"quiet", "error", "warning", "notice", "info", "debug"}; + verbosityOption.setAllowedValues(allowedValues); + return verbosityOption; + } + + public static DoubleConfigOption getPercentPerLenghtUnitOption(double defaultValue) { + DoubleConfigOption option = new DoubleConfigOption("percentPerLenghtUnit", "describes the reduction in classification accuracy in percent one is willing to accept for reducing the length of the concept by one", defaultValue); + option.setLowerLimit(0.0); + option.setUpperLimit(1.0); + return option; + } + + public static StringConfigOption getReturnType() { + return new StringConfigOption("returnType", "Specifies the type which the solution has to belong to (if already) known. This means we inform the learning algorithm that the solution is a subclass of this type."); + } + + public static BooleanConfigOption getUNA() { + return new BooleanConfigOption("una", "unique names assumption", false); + } + + public static BooleanConfigOption getOWA() { + return new BooleanConfigOption("owa", "open world assumption (if set to false, we try to close the world", true); + } + + public static StringSetConfigOption allowedConcepts() { + return new StringSetConfigOption("allowedConcepts", "concepts the algorithm is allowed to use"); + } + + public static StringSetConfigOption allowedRoles() { + return new StringSetConfigOption("allowedRoles", "roles the algorithm is allowed to use"); + } + + public static StringSetConfigOption ignoredConcepts() { + return new StringSetConfigOption("ignoredConcepts", "concepts the algorithm must ignore"); + } + + public static StringSetConfigOption ignoredRoles() { + return new StringSetConfigOption("ignoredRoles", "roles the algorithm must ignore"); + } + + public static BooleanConfigOption useAllConstructor() { + return new BooleanConfigOption("useAllConstructor", "specifies whether to universal concept constructor is used in the learning algorothm"); + } + + public static BooleanConfigOption useExistsConstructor() { + return new BooleanConfigOption("useExistsConstructor", "specifies whether to existential concept constructor is used in the learning algorothm"); + } + + public static BooleanConfigOption useNegation() { + return new BooleanConfigOption("useNegation", "specifies whether negation is used in the learning algorothm"); + } +} Copied: trunk/src/dl-learner/org/dllearner/core/config/ConfigDocumentationGenerator.java (from rev 236, trunk/src/dl-learner/org/dllearner/core/ConfigDocumentationGenerator.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/ConfigDocumentationGenerator.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/config/ConfigDocumentationGenerator.java 2007-10-18 17:21:38 UTC (rev 238) @@ -0,0 +1,45 @@ +/** + * Copyright (C) 2007, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package org.dllearner.core.config; + +import java.io.File; + +import org.dllearner.core.ComponentManager; + +/** + * Collects information about all used configuration options and + * writes them into a file. This way the documentation is always + * in sync with the source code. + * + * @author Jens Lehmann + * + */ +public class ConfigDocumentationGenerator { + + /** + * @param args + */ + public static void main(String[] args) { + File file = new File("doc/configOptions.txt"); + ComponentManager cm = ComponentManager.getInstance(); + cm.writeConfigDocumentation(file); + } + +} Copied: trunk/src/dl-learner/org/dllearner/core/config/ConfigEntry.java (from rev 236, trunk/src/dl-learner/org/dllearner/core/ConfigEntry.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/ConfigEntry.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/config/ConfigEntry.java 2007-10-18 17:21:38 UTC (rev 238) @@ -0,0 +1,55 @@ +/** + * Copyright (C) 2007, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package org.dllearner.core.config; + + +/** + * A config entry is a configuration option and a value for the option. + * + * @author Jens Lehmann + * + */ +public class ConfigEntry<T> { + + private ConfigOption<T> option; + private T value; + + public ConfigEntry(ConfigOption<T> option, T value) throws InvalidConfigOptionValueException { + if(!option.isValidValue(value)) { + throw new InvalidConfigOptionValueException(option, value); + } else { + this.option = option; + this.value = value; + } + } + + public ConfigOption<T> getOption() { + return option; + } + + public String getOptionName() { + return option.getName(); + } + + public T getValue() { + return value; + } + +} Copied: trunk/src/dl-learner/org/dllearner/core/config/ConfigOption.java (from rev 236, trunk/src/dl-learner/org/dllearner/core/ConfigOption.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/ConfigOption.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/config/ConfigOption.java 2007-10-18 17:21:38 UTC (rev 238) @@ -0,0 +1,88 @@ +/** + * Copyright (C) 2007, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package org.dllearner.core.config; + +/** + * This class represents a configuration option (without a value for the + * option). + * + * Note: Currently, handling the type of a configuration option is not + * straightforward to implement, because Java Generics information is + * erased at runtime. This will be fixed in Java 7, in particular JSR 308, + * which is due at approx. the end of 2008. + * + * @author Jens Lehmann + * + */ +public abstract class ConfigOption<T> { + + protected String name; + + protected String description; + + protected T defaultValue; + + public ConfigOption(String name, String description) { + this(name, description, null); + } + + public ConfigOption(String name, String description, T defaultValue) { + this.name = name; + this.description = description; + this.defaultValue = defaultValue; + } + + public String getName() { + return name; + } + + public String getDescription() { + return description; + } + + /** + * @return the defaultValue + */ + public T getDefaultValue() { + return defaultValue; + } + + /** + * Checks whether the object has the correct type to be used as + * a value for this option (this method is necessary, because + * generic information is erased at runtime in Java). + * + * @param object The object to check. + * @return + */ + public abstract boolean checkType(Object object); + + public abstract boolean isValidValue(T value); + + public String getAllowedValuesDescription() { + return getClass().toString(); + } + + @Override + public String toString() { + return "option name: " + name + "\ndescription: " + description + "\nvalues: " + getAllowedValuesDescription() + "\ndefault value: " + defaultValue + "\n"; + } + +} Copied: trunk/src/dl-learner/org/dllearner/core/config/DoubleConfigOption.java (from rev 236, trunk/src/dl-learner/org/dllearner/core/DoubleConfigOption.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/DoubleConfigOption.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/config/DoubleConfigOption.java 2007-10-18 17:21:38 UTC (rev 238) @@ -0,0 +1,100 @@ +/** + * Copyright (C) 2007, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package org.dllearner.core.config; + + +/** + * Represents a configuration option with values of type value. Similar + * to the integer option a minimum and a maximum value can specified. + * + * @author Jens Lehmann + * + */ +public class DoubleConfigOption extends ConfigOption<Double> { + + private double lowerLimit = Double.MIN_VALUE; + private double upperLimit = Double.MAX_VALUE; + + public DoubleConfigOption(String name, String description) { + super(name, description); + } + + public DoubleConfigOption(String name, String description, double defaultValue) { + super(name, description, defaultValue); + } + + /* (non-Javadoc) + * @see org.dllearner.core.ConfigOption#isValidValue(java.lang.Object) + */ + @Override + public boolean isValidValue(Double value) { + if(value >= lowerLimit && value <= upperLimit) + return true; + else + return false; + } + + /** + * @return the The lowest possible value for this configuration option. + */ + public double getLowerLimit() { + return lowerLimit; + } + + /** + * @param lowerLimit The lowest possible value for this configuration option. + */ + public void setLowerLimit(double lowerLimit) { + this.lowerLimit = lowerLimit; + } + + /** + * @return the The highest possible value for this configuration option. + */ + public double getUpperLimit() { + return upperLimit; + } + + /** + * @param upperLimit The highest possible value for this configuration option. + */ + public void setUpperLimit(double upperLimit) { + this.upperLimit = upperLimit; + } + + /* (non-Javadoc) + * @see org.dllearner.core.ConfigOption#checkType(java.lang.Object) + */ + @Override + public boolean checkType(Object object) { + return (object instanceof Double); + } + + @Override + public String getAllowedValuesDescription() { + String str = getClass().toString(); + if(lowerLimit != Double.MIN_VALUE) + str += " min " + lowerLimit; + if(upperLimit != Double.MAX_VALUE) + str += " max " + upperLimit; + return str; + } + +} Copied: trunk/src/dl-learner/org/dllearner/core/config/IntegerConfigOption.java (from rev 236, trunk/src/dl-learner/org/dllearner/core/IntegerConfigOption.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/IntegerConfigOption.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/config/IntegerConfigOption.java 2007-10-18 17:21:38 UTC (rev 238) @@ -0,0 +1,100 @@ +/** + * Copyright (C) 2007, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package org.dllearner.core.config; + + +/** + * A configuration option, which allows values of type integer. A minimum and + * ... [truncated message content] |
From: <jen...@us...> - 2007-10-19 11:48:44
|
Revision: 251 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=251&view=rev Author: jenslehmann Date: 2007-10-19 04:48:42 -0700 (Fri, 19 Oct 2007) Log Message: ----------- implemented export function for internal KB format Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/cli/Start.java trunk/src/dl-learner/org/dllearner/kb/KBFile.java trunk/src/dl-learner/org/dllearner/reasoning/KAON2Reasoner.java Modified: trunk/src/dl-learner/org/dllearner/cli/Start.java =================================================================== --- trunk/src/dl-learner/org/dllearner/cli/Start.java 2007-10-19 09:53:14 UTC (rev 250) +++ trunk/src/dl-learner/org/dllearner/cli/Start.java 2007-10-19 11:48:42 UTC (rev 251) @@ -174,7 +174,7 @@ initComponent(cm, la); // perform file exports - performExports(parser, baseDir, rs); + performExports(parser, baseDir, sources, rs); // show examples (display each one if they do not take up much space, // otherwise just show the number of examples) @@ -375,25 +375,40 @@ return importedFiles; } - private static void performExports(ConfParser parser, String baseDir, ReasoningService rs) { + private static void performExports(ConfParser parser, String baseDir, Set<KnowledgeSource> sources, ReasoningService rs) { List<List<String>> exports = parser.getFunctionCalls().get("export"); + if (exports == null) return; + + File file = null; + OntologyFileFormat format = null; for (List<String> export : exports) { - File file = new File(baseDir, export.get(0)); + file = new File(baseDir, export.get(0)); if (export.size() == 1) // use RDF/XML by default - rs.saveOntology(file, OntologyFileFormat.RDF_XML); + format = OntologyFileFormat.RDF_XML; + // rs.saveOntology(file, OntologyFileFormat.RDF_XML); else { String formatString = export.get(1); - OntologyFileFormat format; + // OntologyFileFormat format; if (formatString.equals("RDF/XML")) format = OntologyFileFormat.RDF_XML; else format = OntologyFileFormat.N_TRIPLES; - rs.saveOntology(file, format); + // rs.saveOntology(file, format); } } + // hack: ideally we would have the possibility to export each knowledge + // source to specified files with specified formats (and maybe including + // the option to merge them all in one file) + // however implementing this requires quite some effort so for the + // moment we just stick to exporting KB files (moreover all but the last + // export statement are ignored) + for(KnowledgeSource source : sources) { + if(source instanceof KBFile) + ((KBFile)source).export(file, format); + } } private static void processCLIOptions(ComponentManager cm, ConfParser parser, Modified: trunk/src/dl-learner/org/dllearner/kb/KBFile.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/KBFile.java 2007-10-19 09:53:14 UTC (rev 250) +++ trunk/src/dl-learner/org/dllearner/kb/KBFile.java 2007-10-19 11:48:42 UTC (rev 251) @@ -36,6 +36,10 @@ import org.dllearner.parser.KBParser; import org.dllearner.parser.ParseException; import org.dllearner.reasoning.DIGConverter; +import org.dllearner.reasoning.KAON2Reasoner; +import org.semanticweb.kaon2.api.KAON2Exception; +import org.semanticweb.kaon2.api.formatting.OntologyFileFormat; +import org.semanticweb.kaon2.api.reasoner.Reasoner; /** * @author Jens Lehmann @@ -112,6 +116,28 @@ return kb.toString(); } + public void export(File file, org.dllearner.kb.OntologyFileFormat format) { + Reasoner kaon2Reasoner = KAON2Reasoner.getKAON2Reasoner(kb); + + String kaon2Format = ""; + if(format.equals(org.dllearner.kb.OntologyFileFormat.RDF_XML)) + kaon2Format = OntologyFileFormat.OWL_RDF; + else { + System.err.println("Warning: Cannot export format " + format + ". Exiting."); + System.exit(0); + } + + try { + kaon2Reasoner.getOntology().saveOntology(kaon2Format,file,"ISO-8859-1"); + } catch (KAON2Exception e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + public URL getURL() { return url; } Modified: trunk/src/dl-learner/org/dllearner/reasoning/KAON2Reasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/KAON2Reasoner.java 2007-10-19 09:53:14 UTC (rev 250) +++ trunk/src/dl-learner/org/dllearner/reasoning/KAON2Reasoner.java 2007-10-19 11:48:42 UTC (rev 251) @@ -586,7 +586,24 @@ throw new IllegalArgumentException("Unsupported concept type."); } - private org.semanticweb.kaon2.api.reasoner.Reasoner getKAON2Reasoner(KB kb, + public static org.semanticweb.kaon2.api.reasoner.Reasoner getKAON2Reasoner(KB kb) { + try { + KAON2Connection connection = KAON2Manager.newConnection(); + + DefaultOntologyResolver resolver = new DefaultOntologyResolver(); + resolver.registerReplacement("http://localhost/foo", "file:nothing.xml"); + connection.setOntologyResolver(resolver); + Ontology ontology = connection.createOntology("http://localhost/foo", + new HashMap<String, Object>()); + return getKAON2Reasoner(kb, ontology); + + } catch (KAON2Exception e) { + e.printStackTrace(); + return null; + } + } + + private static org.semanticweb.kaon2.api.reasoner.Reasoner getKAON2Reasoner(KB kb, Ontology ontology) { org.semanticweb.kaon2.api.reasoner.Reasoner reasoner = null; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2007-10-19 12:01:13
|
Revision: 252 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=252&view=rev Author: jenslehmann Date: 2007-10-19 05:01:07 -0700 (Fri, 19 Oct 2007) Log Message: ----------- added export method to abstract knowledge source class Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/cli/Start.java trunk/src/dl-learner/org/dllearner/core/KnowledgeSource.java trunk/src/dl-learner/org/dllearner/core/ReasoningService.java trunk/src/dl-learner/org/dllearner/kb/KBFile.java trunk/src/dl-learner/org/dllearner/kb/OWLFile.java trunk/src/dl-learner/org/dllearner/kb/SparqlEndpoint.java trunk/src/dl-learner/org/dllearner/kb/SparqlOntologyCollector.java trunk/src/dl-learner/org/dllearner/reasoning/DIGReasoner.java trunk/src/dl-learner/org/dllearner/reasoning/JenaOWLDIGConverter.java trunk/src/dl-learner/org/dllearner/reasoning/KAON2Reasoner.java trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIDIGConverter.java trunk/src/dl-learner/org/dllearner/utilities/PaperStatistics.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/core/OntologyFormat.java trunk/src/dl-learner/org/dllearner/core/OntologyFormatUnsupportedException.java Removed Paths: ------------- trunk/src/dl-learner/org/dllearner/kb/OntologyFileFormat.java Modified: trunk/src/dl-learner/org/dllearner/cli/Start.java =================================================================== --- trunk/src/dl-learner/org/dllearner/cli/Start.java 2007-10-19 11:48:42 UTC (rev 251) +++ trunk/src/dl-learner/org/dllearner/cli/Start.java 2007-10-19 12:01:07 UTC (rev 252) @@ -41,6 +41,7 @@ import org.dllearner.core.KnowledgeSource; import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.LearningProblem; +import org.dllearner.core.OntologyFormat; import org.dllearner.core.ReasonerComponent; import org.dllearner.core.ReasoningService; import org.dllearner.core.Score; @@ -58,7 +59,6 @@ import org.dllearner.core.dl.Individual; import org.dllearner.kb.KBFile; import org.dllearner.kb.OWLFile; -import org.dllearner.kb.OntologyFileFormat; import org.dllearner.kb.SparqlEndpoint; import org.dllearner.learningproblems.PosNegDefinitionLP; import org.dllearner.learningproblems.PosNegInclusionLP; @@ -382,20 +382,20 @@ return; File file = null; - OntologyFileFormat format = null; + OntologyFormat format = null; for (List<String> export : exports) { file = new File(baseDir, export.get(0)); if (export.size() == 1) // use RDF/XML by default - format = OntologyFileFormat.RDF_XML; + format = OntologyFormat.RDF_XML; // rs.saveOntology(file, OntologyFileFormat.RDF_XML); else { String formatString = export.get(1); // OntologyFileFormat format; if (formatString.equals("RDF/XML")) - format = OntologyFileFormat.RDF_XML; + format = OntologyFormat.RDF_XML; else - format = OntologyFileFormat.N_TRIPLES; + format = OntologyFormat.N_TRIPLES; // rs.saveOntology(file, format); } } Modified: trunk/src/dl-learner/org/dllearner/core/KnowledgeSource.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/KnowledgeSource.java 2007-10-19 11:48:42 UTC (rev 251) +++ trunk/src/dl-learner/org/dllearner/core/KnowledgeSource.java 2007-10-19 12:01:07 UTC (rev 252) @@ -19,9 +19,12 @@ */ package org.dllearner.core; +import java.io.File; import java.net.URI; /** + * Represents a knowledge source component. + * * @author Jens Lehmann * */ @@ -29,4 +32,6 @@ public abstract String toDIG(URI kbURI); + public abstract void export(File file, OntologyFormat format) throws OntologyFormatUnsupportedException; + } Added: trunk/src/dl-learner/org/dllearner/core/OntologyFormat.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/OntologyFormat.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/OntologyFormat.java 2007-10-19 12:01:07 UTC (rev 252) @@ -0,0 +1,20 @@ +package org.dllearner.core; + +public enum OntologyFormat { + + /** + * RDF-Triples in XML file + */ + RDF_XML, + + /** + * N-Triple format (subformat of N3) + */ + N_TRIPLES, + + /** + * internal KB format + */ + KB, + +} Added: trunk/src/dl-learner/org/dllearner/core/OntologyFormatUnsupportedException.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/OntologyFormatUnsupportedException.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/OntologyFormatUnsupportedException.java 2007-10-19 12:01:07 UTC (rev 252) @@ -0,0 +1,38 @@ +/** + * Copyright (C) 2007, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package org.dllearner.core; + + +/** + * Indicates that an operation is not supported/implemented for + * a specific ontology file format. + * + * @author Jens Lehmann + * + */ +public class OntologyFormatUnsupportedException extends Exception { + + private static final long serialVersionUID = 1080949376967068007L; + + public OntologyFormatUnsupportedException(String operation, OntologyFormat format) { + super("The operation " + operation + " does not support the ontology file format " + format); + } + +} Modified: trunk/src/dl-learner/org/dllearner/core/ReasoningService.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ReasoningService.java 2007-10-19 11:48:42 UTC (rev 251) +++ trunk/src/dl-learner/org/dllearner/core/ReasoningService.java 2007-10-19 12:01:07 UTC (rev 252) @@ -33,7 +33,6 @@ import org.dllearner.core.dl.Individual; import org.dllearner.core.dl.RoleHierarchy; import org.dllearner.core.dl.SubsumptionHierarchy; -import org.dllearner.kb.OntologyFileFormat; import org.dllearner.reasoning.DIGReasoner; import org.dllearner.reasoning.KAON2Reasoner; import org.dllearner.reasoning.ReasonerType; @@ -406,7 +405,7 @@ } // speichern einer Ontolgie wird speziell behandelt, da kein Reasoning - public void saveOntology(File file, OntologyFileFormat format) { + public void saveOntology(File file, OntologyFormat format) { if (getReasonerType() == ReasonerType.KAON2) { ((KAON2Reasoner) reasoner).saveOntology(file, format); } else if (getReasonerType() == ReasonerType.DIG) { Modified: trunk/src/dl-learner/org/dllearner/kb/KBFile.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/KBFile.java 2007-10-19 11:48:42 UTC (rev 251) +++ trunk/src/dl-learner/org/dllearner/kb/KBFile.java 2007-10-19 12:01:07 UTC (rev 252) @@ -116,11 +116,12 @@ return kb.toString(); } - public void export(File file, org.dllearner.kb.OntologyFileFormat format) { + @Override + public void export(File file, org.dllearner.core.OntologyFormat format){ Reasoner kaon2Reasoner = KAON2Reasoner.getKAON2Reasoner(kb); String kaon2Format = ""; - if(format.equals(org.dllearner.kb.OntologyFileFormat.RDF_XML)) + if(format.equals(org.dllearner.core.OntologyFormat.RDF_XML)) kaon2Format = OntologyFileFormat.OWL_RDF; else { System.err.println("Warning: Cannot export format " + format + ". Exiting."); Modified: trunk/src/dl-learner/org/dllearner/kb/OWLFile.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/OWLFile.java 2007-10-19 11:48:42 UTC (rev 251) +++ trunk/src/dl-learner/org/dllearner/kb/OWLFile.java 2007-10-19 12:01:07 UTC (rev 252) @@ -19,6 +19,7 @@ */ package org.dllearner.kb; +import java.io.File; import java.net.MalformedURLException; import java.net.URI; import java.net.URL; @@ -26,6 +27,8 @@ import java.util.LinkedList; import org.dllearner.core.KnowledgeSource; +import org.dllearner.core.OntologyFormat; +import org.dllearner.core.OntologyFormatUnsupportedException; import org.dllearner.core.config.ConfigEntry; import org.dllearner.core.config.ConfigOption; import org.dllearner.core.config.InvalidConfigOptionValueException; @@ -88,11 +91,20 @@ @Override public String toDIG(URI kbURI) { // TODO: need some handling for cases where the URL was not set - return OWLAPIDIGConverter.getTellsString(url, OntologyFileFormat.RDF_XML, kbURI); + return OWLAPIDIGConverter.getTellsString(url, OntologyFormat.RDF_XML, kbURI); } public URL getURL() { return url; } + /* (non-Javadoc) + * @see org.dllearner.core.KnowledgeSource#export(java.io.File, org.dllearner.core.OntologyFormat) + */ + @Override + public void export(File file, OntologyFormat format) throws OntologyFormatUnsupportedException { + // currently no export functions implemented, so we just throw an exception + throw new OntologyFormatUnsupportedException("export", format); + } + } Deleted: trunk/src/dl-learner/org/dllearner/kb/OntologyFileFormat.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/OntologyFileFormat.java 2007-10-19 11:48:42 UTC (rev 251) +++ trunk/src/dl-learner/org/dllearner/kb/OntologyFileFormat.java 2007-10-19 12:01:07 UTC (rev 252) @@ -1,20 +0,0 @@ -package org.dllearner.kb; - -public enum OntologyFileFormat { - - /** - * RDF-Triples in XML file - */ - RDF_XML, - - /** - * N-Triple format (subformat of N3) - */ - N_TRIPLES, - - /** - * internal KB format - */ - KB, - -} Modified: trunk/src/dl-learner/org/dllearner/kb/SparqlEndpoint.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/SparqlEndpoint.java 2007-10-19 11:48:42 UTC (rev 251) +++ trunk/src/dl-learner/org/dllearner/kb/SparqlEndpoint.java 2007-10-19 12:01:07 UTC (rev 252) @@ -30,6 +30,8 @@ import java.util.Set; import org.dllearner.core.KnowledgeSource; +import org.dllearner.core.OntologyFormat; +import org.dllearner.core.OntologyFormatUnsupportedException; import org.dllearner.core.config.BooleanConfigOption; import org.dllearner.core.config.ConfigEntry; import org.dllearner.core.config.ConfigOption; @@ -170,10 +172,19 @@ */ @Override public String toDIG(URI kbURI) { - if (format.equals("N-TRIPLES")) return JenaOWLDIGConverter.getTellsString(dumpFile, OntologyFileFormat.N_TRIPLES, kbURI); + if (format.equals("N-TRIPLES")) return JenaOWLDIGConverter.getTellsString(dumpFile, OntologyFormat.N_TRIPLES, kbURI); else return DIGConverter.getDIGString(kb, kbURI).toString(); } + /* (non-Javadoc) + * @see org.dllearner.core.KnowledgeSource#export(java.io.File, org.dllearner.core.OntologyFormat) + */ + @Override + public void export(File file, OntologyFormat format) throws OntologyFormatUnsupportedException { + // currently no export functions implemented, so we just throw an exception + throw new OntologyFormatUnsupportedException("export", format); + } + public URL getURL() { return url; } Modified: trunk/src/dl-learner/org/dllearner/kb/SparqlOntologyCollector.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/SparqlOntologyCollector.java 2007-10-19 11:48:42 UTC (rev 251) +++ trunk/src/dl-learner/org/dllearner/kb/SparqlOntologyCollector.java 2007-10-19 12:01:07 UTC (rev 252) @@ -31,7 +31,6 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; -import java.util.StringTokenizer; import java.util.Vector; Modified: trunk/src/dl-learner/org/dllearner/reasoning/DIGReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/DIGReasoner.java 2007-10-19 11:48:42 UTC (rev 251) +++ trunk/src/dl-learner/org/dllearner/reasoning/DIGReasoner.java 2007-10-19 12:01:07 UTC (rev 252) @@ -37,6 +37,7 @@ import org.apache.xmlbeans.XmlCursor; import org.dllearner.core.KnowledgeSource; +import org.dllearner.core.OntologyFormat; import org.dllearner.core.ReasonerComponent; import org.dllearner.core.config.BooleanConfigOption; import org.dllearner.core.config.ConfigEntry; @@ -51,7 +52,6 @@ import org.dllearner.core.dl.RoleHierarchy; import org.dllearner.core.dl.SubsumptionHierarchy; import org.dllearner.core.dl.Top; -import org.dllearner.kb.OntologyFileFormat; import org.dllearner.utilities.ConceptComparator; import org.dllearner.utilities.Files; import org.dllearner.utilities.Helper; @@ -755,7 +755,7 @@ // TODO: not working yet - it is probably better to include a method // in knowledge source to save the corresponding source to a file - public void saveOntology(File file, OntologyFileFormat format) { + public void saveOntology(File file, OntologyFormat format) { // KAON2-Reasoner erzeugen und den die Ontologie speichern lassen // (später könnte man das über Jena erledigen, allerdings funktioniert // das mit KAON2 auch gut) Modified: trunk/src/dl-learner/org/dllearner/reasoning/JenaOWLDIGConverter.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/JenaOWLDIGConverter.java 2007-10-19 11:48:42 UTC (rev 251) +++ trunk/src/dl-learner/org/dllearner/reasoning/JenaOWLDIGConverter.java 2007-10-19 12:01:07 UTC (rev 252) @@ -16,7 +16,7 @@ import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; -import org.dllearner.kb.OntologyFileFormat; +import org.dllearner.core.OntologyFormat; import org.w3c.dom.Document; import com.hp.hpl.jena.graph.Graph; @@ -35,7 +35,7 @@ String tells = ""; try { URL url = file.toURI().toURL(); - tells = getTellsString(url, OntologyFileFormat.RDF_XML, new URI("kk")); + tells = getTellsString(url, OntologyFormat.RDF_XML, new URI("kk")); } catch (URISyntaxException e) { e.printStackTrace(); } catch (MalformedURLException e) { @@ -46,7 +46,7 @@ // returns a DIG 1.1 Tells String from an ontology file // using the Jena library - public static String getTellsString(URL file, OntologyFileFormat format, URI kbURI) { + public static String getTellsString(URL file, OntologyFormat format, URI kbURI) { String tellString = ""; // Spezifikation erzeugen: OWL DL @@ -74,7 +74,7 @@ // OntModel m = ModelFactory.createOntologyModel(); Model m = spec.createBaseModel(); String lang = ""; - if(format.equals(OntologyFileFormat.RDF_XML)) + if(format.equals(OntologyFormat.RDF_XML)) lang = "RDF/XML"; else lang = "N-TRIPLES"; Modified: trunk/src/dl-learner/org/dllearner/reasoning/KAON2Reasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/KAON2Reasoner.java 2007-10-19 11:48:42 UTC (rev 251) +++ trunk/src/dl-learner/org/dllearner/reasoning/KAON2Reasoner.java 2007-10-19 12:01:07 UTC (rev 252) @@ -91,7 +91,7 @@ private org.semanticweb.kaon2.api.reasoner.Reasoner kaon2Reasoner; private KAON2Connection kaon2Connection; - public KAON2Reasoner(KB kb, Map<URL,org.dllearner.kb.OntologyFileFormat> imports) { + public KAON2Reasoner(KB kb, Map<URL,org.dllearner.core.OntologyFormat> imports) { if(imports.size()>1) System.out.println("Warning: KAON2-Reasoner currently supports only one import file. Ignoring all other imports."); @@ -472,11 +472,11 @@ return returnMap; } - public void saveOntology(File file, org.dllearner.kb.OntologyFileFormat format) { + public void saveOntology(File file, org.dllearner.core.OntologyFormat format) { // File exportFile = new File(baseDir, fileName); // String format = OntologyFileFormat.OWL_RDF; String kaon2Format = ""; - if(format.equals(org.dllearner.kb.OntologyFileFormat.RDF_XML)) + if(format.equals(org.dllearner.core.OntologyFormat.RDF_XML)) kaon2Format = OntologyFileFormat.OWL_RDF; else { System.err.println("Warning: Cannot export format " + format + ". Exiting."); @@ -520,7 +520,7 @@ return ontology; } - private static Ontology importKB(String ontologyURI, org.dllearner.kb.OntologyFileFormat format, KAON2Connection connection) { + private static Ontology importKB(String ontologyURI, org.dllearner.core.OntologyFormat format, KAON2Connection connection) { Ontology ontology = null; try { long importStartTime = System.currentTimeMillis(); Modified: trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIDIGConverter.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIDIGConverter.java 2007-10-19 11:48:42 UTC (rev 251) +++ trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIDIGConverter.java 2007-10-19 12:01:07 UTC (rev 252) @@ -14,7 +14,7 @@ import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; -import org.dllearner.kb.OntologyFileFormat; +import org.dllearner.core.OntologyFormat; import org.semanticweb.owl.apibinding.OWLManager; import org.semanticweb.owl.model.OWLOntologyCreationException; import org.semanticweb.owl.model.OWLOntologyManager; @@ -25,7 +25,7 @@ public class OWLAPIDIGConverter { - public static String getTellsString(URL file, OntologyFileFormat format, URI kbURI) { + public static String getTellsString(URL file, OntologyFormat format, URI kbURI) { // public static String getTellsString(URL file, URI kbURI){//throws OWLOntologyCreationException{ String ret=""; try{ Modified: trunk/src/dl-learner/org/dllearner/utilities/PaperStatistics.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/PaperStatistics.java 2007-10-19 11:48:42 UTC (rev 251) +++ trunk/src/dl-learner/org/dllearner/utilities/PaperStatistics.java 2007-10-19 12:01:07 UTC (rev 252) @@ -34,11 +34,11 @@ import org.dllearner.core.KnowledgeSource; import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.LearningProblem; +import org.dllearner.core.OntologyFormat; import org.dllearner.core.ReasonerComponent; import org.dllearner.core.ReasoningService; import org.dllearner.core.Score; import org.dllearner.kb.OWLFile; -import org.dllearner.kb.OntologyFileFormat; import org.dllearner.learningproblems.PosNegDefinitionLP; import org.dllearner.parser.ConfParser; import org.dllearner.reasoning.DIGReasoner; @@ -157,7 +157,7 @@ String baseDir = confFiles[exampleNr].getParent(); // read which files were imported (internal KB is ignored) and initialise reasoner - Map<URL, OntologyFileFormat> imports = getImports(learner.getFunctionCalls(), confFiles[exampleNr]); + Map<URL, OntologyFormat> imports = getImports(learner.getFunctionCalls(), confFiles[exampleNr]); //Map<URL, Class<? extends KnowledgeSource>> imports = Start.getImportedFiles(learner, baseDir); // detect specified positive and negative examples @@ -304,10 +304,10 @@ } - private static Map<URL, OntologyFileFormat> getImports(Map<String,List<List<String>>> functionCalls, File confFile) { - Map<URL, OntologyFileFormat> importedFiles = new HashMap<URL, OntologyFileFormat>(); + private static Map<URL, OntologyFormat> getImports(Map<String,List<List<String>>> functionCalls, File confFile) { + Map<URL, OntologyFormat> importedFiles = new HashMap<URL, OntologyFormat>(); - OntologyFileFormat format = null; + OntologyFormat format = null; URL url = null; List<List<String>> imports = functionCalls.get("import"); @@ -331,13 +331,13 @@ if (call.size() == 2) // falls nichts angegeben, dann wird RDF/XML gewählt - importedFiles.put(url, OntologyFileFormat.RDF_XML); + importedFiles.put(url, OntologyFormat.RDF_XML); else { String formatString = call.get(2); if (formatString.equals("RDF/XML")) - format = OntologyFileFormat.RDF_XML; + format = OntologyFormat.RDF_XML; else - format = OntologyFileFormat.N_TRIPLES; + format = OntologyFormat.N_TRIPLES; importedFiles.put(url, format); } // } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2007-10-19 13:53:32
|
Revision: 253 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=253&view=rev Author: jenslehmann Date: 2007-10-19 06:53:31 -0700 (Fri, 19 Oct 2007) Log Message: ----------- added possibility to query the n best concepts of a running learning algorithm Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java trunk/src/dl-learner/org/dllearner/cli/Start.java trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java trunk/src/dl-learner/org/dllearner/utilities/Datastructures.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2007-10-19 12:01:07 UTC (rev 252) +++ trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2007-10-19 13:53:31 UTC (rev 253) @@ -901,6 +901,19 @@ } @Override + public synchronized List<Concept> getBestSolutions(int nrOfSolutions) { + List<Concept> best = new LinkedList<Concept>(); + int i=0; + for(Node n : candidatesStable.descendingSet()) { + best.add(n.getConcept()); + if(i==nrOfSolutions) + return best; + i++; + } + return best; + } + + @Override public Score getSolutionScore() { if(posOnly) return posOnlyLearningProblem.computeScore(getBestSolution()); Modified: trunk/src/dl-learner/org/dllearner/cli/Start.java =================================================================== --- trunk/src/dl-learner/org/dllearner/cli/Start.java 2007-10-19 12:01:07 UTC (rev 252) +++ trunk/src/dl-learner/org/dllearner/cli/Start.java 2007-10-19 13:53:31 UTC (rev 253) @@ -208,7 +208,7 @@ printConclusions(rs, algDuration); } - + } // creates a mapping from components to option prefix strings Modified: trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java 2007-10-19 12:01:07 UTC (rev 252) +++ trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java 2007-10-19 13:53:31 UTC (rev 253) @@ -21,6 +21,7 @@ import java.util.Collection; import java.util.LinkedList; +import java.util.List; import org.dllearner.core.dl.Concept; @@ -56,6 +57,12 @@ */ public abstract Concept getBestSolution(); + public synchronized List<Concept> getBestSolutions(int nrOfSolutions) { + List<Concept> single = new LinkedList<Concept>(); + single.add(getBestSolution()); + return single; + } + /** * Returns all learning problems supported by this component. */ Modified: trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2007-10-19 12:01:07 UTC (rev 252) +++ trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2007-10-19 13:53:31 UTC (rev 253) @@ -48,6 +48,7 @@ import org.dllearner.kb.SparqlEndpoint; import org.dllearner.learningproblems.PosNegDefinitionLP; import org.dllearner.learningproblems.PosNegInclusionLP; +import org.dllearner.learningproblems.PosOnlyDefinitionLP; import org.dllearner.parser.KBParser; import org.dllearner.parser.ParseException; import org.dllearner.reasoning.DIGReasoner; @@ -82,6 +83,7 @@ reasonerMapping.put("dig", DIGReasoner.class); learningProblemMapping.put("posNegDefinition", PosNegDefinitionLP.class); learningProblemMapping.put("posNegInclusion", PosNegInclusionLP.class); + learningProblemMapping.put("posOnlyDefinition", PosOnlyDefinitionLP.class); learningAlgorithmMapping.put("refinement", ROLearner.class); components = Helper.union(knowledgeSourceMapping.keySet(),reasonerMapping.keySet()); components = Helper.union(components, learningProblemMapping.keySet()); @@ -289,6 +291,13 @@ } @WebMethod + public String[] getCurrentlyBestConcepts(int id, int nrOfConcepts) throws ClientNotKnownException { + ClientState state = getState(id); + List<Concept> bestConcepts = state.getLearningAlgorithm().getBestSolutions(nrOfConcepts); + return bestConcepts.toArray(new String[bestConcepts.size()]); + } + + @WebMethod public boolean isAlgorithmRunning(int id) throws ClientNotKnownException { return getState(id).isAlgorithmRunning(); } Modified: trunk/src/dl-learner/org/dllearner/utilities/Datastructures.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/Datastructures.java 2007-10-19 12:01:07 UTC (rev 252) +++ trunk/src/dl-learner/org/dllearner/utilities/Datastructures.java 2007-10-19 13:53:31 UTC (rev 253) @@ -63,7 +63,7 @@ return ret; } - + public static String[] sortedSet2StringListIndividuals(Set<Individual> individuals){ String[] ret=new String[individuals.size()]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2007-10-29 12:26:53
|
Revision: 270 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=270&view=rev Author: sknappe Date: 2007-10-29 05:26:51 -0700 (Mon, 29 Oct 2007) Log Message: ----------- added function to show subjects according to the last learned concept Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/kb/SparqlEndpoint.java trunk/src/dl-learner/org/dllearner/kb/SparqlOntologyCollector.java trunk/src/dl-learner/org/dllearner/kb/SparqlQueryMaker.java trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java Modified: trunk/src/dl-learner/org/dllearner/kb/SparqlEndpoint.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/SparqlEndpoint.java 2007-10-29 12:26:01 UTC (rev 269) +++ trunk/src/dl-learner/org/dllearner/kb/SparqlEndpoint.java 2007-10-29 12:26:51 UTC (rev 270) @@ -213,4 +213,13 @@ System.out.println("SparqlModul: ****Finished"); return ret; } + + public String[] getSubjectsFromConcept(String concept) + { + System.out.println("SparqlModul: Collecting Subjects"); + SparqlOntologyCollector oc=new SparqlOntologyCollector(url); + String[] ret=oc.getSubjectsFromConcept(concept); + System.out.println("SparqlModul: ****Finished"); + return ret; + } } Modified: trunk/src/dl-learner/org/dllearner/kb/SparqlOntologyCollector.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/SparqlOntologyCollector.java 2007-10-29 12:26:01 UTC (rev 269) +++ trunk/src/dl-learner/org/dllearner/kb/SparqlOntologyCollector.java 2007-10-29 12:26:51 UTC (rev 270) @@ -154,6 +154,26 @@ return processSubjects(xml); } + public String[] getSubjectsFromConcept(String concept) + { + System.out.println("Searching for Subjects of type: "+concept); + String sparql=q.makeConceptQuery(concept); + String FromCache=c.get(concept, sparql); + String xml; + // if not in cache get it from dbpedia + if(FromCache==null){ + xml=sendAndReceive(sparql); + c.put(concept, xml, sparql); + System.out.print("\n"); + } + else{ + xml=FromCache; + System.out.println("FROM CACHE"); + } + + return processSubjects(xml); + } + /** * calls getRecursive for each subject in list * @param subjects Modified: trunk/src/dl-learner/org/dllearner/kb/SparqlQueryMaker.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/SparqlQueryMaker.java 2007-10-29 12:26:01 UTC (rev 269) +++ trunk/src/dl-learner/org/dllearner/kb/SparqlQueryMaker.java 2007-10-29 12:26:51 UTC (rev 270) @@ -84,4 +84,9 @@ "WHERE { ?subject rdfs:label ?object.FILTER regex(?object,\""+label+"\"@en)}\n"+ "LIMIT "+limit; } + + public String makeConceptQuery(String concept){ + return "SELECT DISTINCT ?subject\n"+ + "WHERE { ?subject a <"+concept+">}\n"; + } } Modified: trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2007-10-29 12:26:01 UTC (rev 269) +++ trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2007-10-29 12:26:51 UTC (rev 270) @@ -464,4 +464,12 @@ Component component = state.getComponent(componentID); return ((SparqlEndpoint)component).getSubjects(label,limit); } + + @WebMethod + public String[] getSubjectsFromConcept(int id, int componentID, String concept) throws ClientNotKnownException + { + ClientState state=getState(id); + Component component = state.getComponent(componentID); + return ((SparqlEndpoint)component).getSubjectsFromConcept(concept); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2007-11-05 13:03:22
|
Revision: 276 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=276&view=rev Author: sknappe Date: 2007-11-05 05:03:14 -0800 (Mon, 05 Nov 2007) Log Message: ----------- added some comments and changed behaviour of some functions Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/kb/SparqlCache.java trunk/src/dl-learner/org/dllearner/kb/SparqlEndpoint.java trunk/src/dl-learner/org/dllearner/kb/SparqlFilter.java trunk/src/dl-learner/org/dllearner/kb/SparqlOntologyCollector.java trunk/src/dl-learner/org/dllearner/kb/SparqlQueryMaker.java trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java Modified: trunk/src/dl-learner/org/dllearner/kb/SparqlCache.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/SparqlCache.java 2007-11-01 14:49:08 UTC (rev 275) +++ trunk/src/dl-learner/org/dllearner/kb/SparqlCache.java 2007-11-05 13:03:14 UTC (rev 276) @@ -90,12 +90,12 @@ public String get(String key, String sparql){ String ret=null; try{ - SparqlCache c =readFromFile(makeFilename(key)) ; - if(c==null)return null; - if(!c.checkFreshness())return null; - if(!c.validate(sparql))return null; - - ret=c.content; + SparqlCache c =readFromFile(makeFilename(key)); + if(c==null)return null; + if(!c.checkFreshness())return null; + if(!c.validate(sparql))return null; + + ret=c.content; }catch (Exception e) {e.printStackTrace();} return ret; } Modified: trunk/src/dl-learner/org/dllearner/kb/SparqlEndpoint.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/SparqlEndpoint.java 2007-11-01 14:49:08 UTC (rev 275) +++ trunk/src/dl-learner/org/dllearner/kb/SparqlEndpoint.java 2007-11-05 13:03:14 UTC (rev 276) @@ -21,6 +21,7 @@ import java.io.File; import java.io.FileWriter; +import java.io.IOException; import java.io.StringReader; import java.net.MalformedURLException; import java.net.URI; @@ -47,8 +48,6 @@ /** * Represents a SPARQL Endpoint. - * TODO: move org.dllearner.modules.sparql to this package and - * integrate its classes * TODO: Is it necessary to create a class DBpediaSparqlEndpoint? * * @author Jens Lehmann @@ -175,29 +174,34 @@ System.out.println("SparqlModul: Collecting Ontology"); SparqlOntologyCollector oc=new SparqlOntologyCollector(Datastructures.setToArray(instances), numberOfRecursions, filterMode, Datastructures.setToArray(predList),Datastructures.setToArray( objList),Datastructures.setToArray(classList),format,url,useLits); - String ont=oc.collectOntology(); - - if (dumpToFile){ - String filename=System.currentTimeMillis()+".nt"; - String basedir="cache"+File.separator; - try{ - if(!new File(basedir).exists()) - new File(basedir).mkdir(); - FileWriter fw=new FileWriter(new File(basedir+filename),true); - fw.write(ont); - fw.flush(); - fw.close(); - - dumpFile=(new File(basedir+filename)).toURI().toURL(); - }catch (Exception e) {e.printStackTrace();} + try + { + String ont=oc.collectOntology(); + + if (dumpToFile){ + String filename=System.currentTimeMillis()+".nt"; + String basedir="cache"+File.separator; + try{ + if(!new File(basedir).exists()) + new File(basedir).mkdir(); + + FileWriter fw=new FileWriter(new File(basedir+filename),true); + fw.write(ont); + fw.flush(); + fw.close(); + + dumpFile=(new File(basedir+filename)).toURI().toURL(); + }catch (Exception e) {e.printStackTrace();} + } + if (format.equals("KB")) { + try{ + kb=KBParser.parseKBFile(new StringReader(ont)); + } catch(Exception e) {e.printStackTrace();} + } + }catch(IOException e) { + e.printStackTrace(); } - if (format.equals("KB")) { - try{ - kb=KBParser.parseKBFile(new StringReader(ont)); - } catch(Exception e) {e.printStackTrace();} - } - System.out.println("SparqlModul: ****Finished"); } @@ -233,15 +237,24 @@ { System.out.println("SparqlModul: Collecting Subjects"); SparqlOntologyCollector oc=new SparqlOntologyCollector(url); - subjects=oc.getSubjectsFromLabel(label,limit); + try{ + subjects=oc.getSubjectsFromLabel(label,limit); + }catch (IOException e){ + subjects=new String[1]; + subjects[0]="[Error]Sparql Endpoint could not be reached."; + } System.out.println("SparqlModul: ****Finished"); } - public void calculateTriples(){ + public void calculateTriples(String subject) { System.out.println("SparqlModul: Collecting Triples"); - SparqlOntologyCollector oc=new SparqlOntologyCollector(Datastructures.setToArray(instances), numberOfRecursions, filterMode, - Datastructures.setToArray(predList),Datastructures.setToArray( objList),Datastructures.setToArray(classList),format,url,useLits); - triples=oc.collectTriples(); + SparqlOntologyCollector oc=new SparqlOntologyCollector(url); + try{ + triples=oc.collectTriples(subject); + }catch (IOException e){ + triples=new String[1]; + triples[0]="[Error]Sparql Endpoint could not be reached."; + } System.out.println("SparqlModul: ****Finished"); } @@ -249,7 +262,12 @@ { System.out.println("SparqlModul: Collecting Subjects"); SparqlOntologyCollector oc=new SparqlOntologyCollector(url); - conceptSubjects=oc.getSubjectsFromConcept(concept); + try{ + conceptSubjects=oc.getSubjectsFromConcept(concept); + }catch (IOException e){ + conceptSubjects=new String[1]; + conceptSubjects[0]="[Error]Sparql Endpoint could not be reached."; + } System.out.println("SparqlModul: ****Finished"); } Modified: trunk/src/dl-learner/org/dllearner/kb/SparqlFilter.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/SparqlFilter.java 2007-11-01 14:49:08 UTC (rev 275) +++ trunk/src/dl-learner/org/dllearner/kb/SparqlFilter.java 2007-11-05 13:03:14 UTC (rev 276) @@ -26,6 +26,7 @@ * see the documentation for more help * * @author Sebastian Hellmann + * @author Sebastian Knappe * */ public class SparqlFilter { @@ -104,7 +105,7 @@ } public SparqlFilter(int mode, String[] pred, String[] obj,boolean uselits) throws Exception{ - this(mode, pred,obj); + this(mode,pred,obj); this.useLiterals=uselits; } Modified: trunk/src/dl-learner/org/dllearner/kb/SparqlOntologyCollector.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/SparqlOntologyCollector.java 2007-11-01 14:49:08 UTC (rev 275) +++ trunk/src/dl-learner/org/dllearner/kb/SparqlOntologyCollector.java 2007-11-05 13:03:14 UTC (rev 276) @@ -120,7 +120,7 @@ * * @return all triples in n-triple format */ - public String collectOntology(){ + public String collectOntology() throws IOException{ getRecursiveList(subjectList, numberOfRecursions); finalize(); String ret=""; @@ -130,12 +130,57 @@ return ret; } - public String[] collectTriples(){ - getRecursive(subjectList[0], 1); - return Datastructures.setToArray(triples); + public String[] collectTriples(String subject) throws IOException{ + System.out.println("Searching for Article: "+subject); + String sparql=q.makeArticleQuery(subject); + String FromCache=c.get(subject, sparql); + String xml; + // if not in cache get it from dbpedia + if(FromCache==null){ + xml=sendAndReceive(sparql); + c.put(subject, xml, sparql); + System.out.print("\n"); + } + else{ + xml=FromCache; + System.out.println("FROM CACHE"); + } + + return processArticle(xml); } - public String[] getSubjectsFromLabel(String label, int limit){ + public String[] processArticle(String xml) + { + Vector<String> vec=new Vector<String>(); + String one="<binding name=\"predicate\"><uri>"; + String two="<binding name=\"object\">"; + String end="</uri></binding>"; + String predtmp=""; + String objtmp=""; + ArrayList<String> al=new ArrayList<String>(); + while(xml.indexOf(one)!=-1){ + //get pred + xml=xml.substring(xml.indexOf(one)+one.length()); + predtmp=xml.substring(0,xml.indexOf(end)); + //getobj + xml=xml.substring(xml.indexOf(two)+two.length()); + if (xml.startsWith("<literal xml:lang=\"en\">")){ + xml=xml.substring(xml.indexOf(">")+1); + objtmp=xml.substring(0,xml.indexOf("</literal>")); + } + else if (xml.startsWith("<uri>")) objtmp=xml.substring(5,xml.indexOf(end)); + else continue; + + System.out.println("Pred: "+predtmp+" Obj: "+objtmp); + + vec.add(predtmp+"<"+objtmp); + } + + String[] ret=new String[vec.size()]; + return vec.toArray(ret); + } + + public String[] getSubjectsFromLabel(String label, int limit) throws IOException{ System.out.println("Searching for Label: "+label); String sparql=q.makeLabelQuery(label,limit); String FromCache=c.get(label, sparql); @@ -154,7 +199,7 @@ return processSubjects(xml); } - public String[] getSubjectsFromConcept(String concept) + public String[] getSubjectsFromConcept(String concept) throws IOException { System.out.println("Searching for Subjects of type: "+concept); String sparql=q.makeConceptQuery(concept); @@ -179,7 +224,7 @@ * @param subjects * @param NumberofRecursions */ - public void getRecursiveList(String[] subjects,int NumberofRecursions){ + public void getRecursiveList(String[] subjects,int NumberofRecursions) throws IOException{ for (int i = 0; i < subjects.length; i++) { getRecursive(subjects[i], NumberofRecursions); } @@ -191,36 +236,33 @@ * @param StartingSubject * @param NumberofRecursions */ - public void getRecursive(String StartingSubject,int NumberofRecursions){ + public void getRecursive(String StartingSubject,int NumberofRecursions) throws IOException{ System.out.print("SparqlModul: Depth: "+NumberofRecursions+" @ "+StartingSubject+" "); if(NumberofRecursions<=0) return; else {NumberofRecursions--;} - try{ - String sparql=q.makeQueryFilter(StartingSubject,this.sf); - // checks cache - String FromCache=c.get(StartingSubject, sparql); - String xml; - // if not in cache get it from dbpedia - if(FromCache==null){ - xml=sendAndReceive(sparql); - c.put(StartingSubject, xml, sparql); - System.out.print("\n"); - } - else{ - xml=FromCache; - System.out.println("FROM CACHE"); - } - // get new Subjects - String[] newSubjects=processResult(StartingSubject,xml); + String sparql=q.makeQueryFilter(StartingSubject,this.sf); + // checks cache + String FromCache=c.get(StartingSubject, sparql); + String xml; + // if not in cache get it from dbpedia + if(FromCache==null){ + xml=sendAndReceive(sparql); + c.put(StartingSubject, xml, sparql); + System.out.print("\n"); + } + else{ + xml=FromCache; + System.out.println("FROM CACHE"); + } + + // get new Subjects + String[] newSubjects=processResult(StartingSubject,xml); - for (int i = 0; (i < newSubjects.length)&& NumberofRecursions!=0; i++) { - getRecursive(newSubjects[i], NumberofRecursions); - } - - }catch (Exception e) {e.printStackTrace();} - + for (int i = 0; (i < newSubjects.length)&& NumberofRecursions!=0; i++) { + getRecursive(newSubjects[i], NumberofRecursions); + } } /** @@ -427,49 +469,43 @@ } } //TODO alles dbpedia-spezifische rausbekommen - private String sendAndReceive(String sparql) { + private String sendAndReceive(String sparql) throws IOException{ StringBuilder answer = new StringBuilder(); // String an Sparql-Endpoint schicken HttpURLConnection connection; - try { - connection = (HttpURLConnection) url.openConnection(); - connection.setDoOutput(true); + connection = (HttpURLConnection) url.openConnection(); + connection.setDoOutput(true); - connection.addRequestProperty("Host", "dbpedia.openlinksw.com"); - connection.addRequestProperty("Connection","close"); - connection.addRequestProperty("Accept","text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"); - connection.addRequestProperty("Accept-Language","de-de,de;q=0.8,en-us;q=0.5,en;q=0.3"); - connection.addRequestProperty("Accept-Charset","ISO-8859-1,utf-8;q=0.7,*;q=0.7"); - connection.addRequestProperty("User-Agent","Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4 Web-Sniffer/1.0.24"); + connection.addRequestProperty("Host", "dbpedia.openlinksw.com"); + connection.addRequestProperty("Connection","close"); + connection.addRequestProperty("Accept","text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"); + connection.addRequestProperty("Accept-Language","de-de,de;q=0.8,en-us;q=0.5,en;q=0.3"); + connection.addRequestProperty("Accept-Charset","utf-8;q=1.0"); + connection.addRequestProperty("User-Agent","Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4 Web-Sniffer/1.0.24"); - OutputStream os = connection.getOutputStream(); - OutputStreamWriter osw = new OutputStreamWriter(os); - osw.write("default-graph-uri=http%3A%2F%2Fdbpedia.org&query=" + - URLEncoder.encode(sparql, "UTF-8")+ - "&format=application%2Fsparql-results%2Bxml"); - osw.close(); + OutputStream os = connection.getOutputStream(); + OutputStreamWriter osw = new OutputStreamWriter(os); + osw.write("default-graph-uri=http%3A%2F%2Fdbpedia.org&query=" + + URLEncoder.encode(sparql, "UTF-8")+ + "&format=application%2Fsparql-results%2Bxml"); + osw.close(); - // receive answer - InputStream is = connection.getInputStream(); - InputStreamReader isr = new InputStreamReader(is); - BufferedReader br = new BufferedReader(isr); + // receive answer + InputStream is = connection.getInputStream(); + InputStreamReader isr = new InputStreamReader(is,"UTF-8"); + BufferedReader br = new BufferedReader(isr); - String line; - do { - line = br.readLine(); - if(line!=null) - answer.append(line); - } while (line != null); + String line; + do { + line = br.readLine(); + if(line!=null) + answer.append(line); + } while (line != null); + + br.close(); - br.close(); - - } catch (IOException e) { - System.out.println("Communication problem with Sparql Server."); - System.exit(0); - } - return answer.toString(); } } \ No newline at end of file Modified: trunk/src/dl-learner/org/dllearner/kb/SparqlQueryMaker.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/SparqlQueryMaker.java 2007-11-01 14:49:08 UTC (rev 275) +++ trunk/src/dl-learner/org/dllearner/kb/SparqlQueryMaker.java 2007-11-05 13:03:14 UTC (rev 276) @@ -24,13 +24,14 @@ * This class produces sparql queries * * @author Sebastian Hellmann + * @author Sebastian Knappe * */ public class SparqlQueryMaker { /** - * reads all the options and makes the sparql query accordingly - * @param subject + * creates a query with the specified filters for alls triples with subject + * @param subject the searched subject * @param sf special object encapsulating all options * @return sparql query */ @@ -78,15 +79,31 @@ return "&&( !regex(str(?predicate), '"+ns+"') )"; } + /** + * creates a query for subjects with the specified label + * @param label a phrase that is part of the label of a subject + * @param limit this limits the amount of results + * @return + */ public String makeLabelQuery(String label,int limit){ - return "PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>\n"+ - "SELECT DISTINCT ?subject\n"+ - "WHERE { ?subject rdfs:label ?object.FILTER regex(?object,\""+label+"\"@en)}\n"+ + //TODO maybe use http://xmlns:com/foaf/0.1/page + return "SELECT DISTINCT ?subject\n"+ + "WHERE { ?subject <http://xmlns.com/foaf/0.1/page> ?object.FILTER regex(?object,\""+label+"\"@en)}\n"+ "LIMIT "+limit; } + /** + * creates a query for all subjects that are of the type concept + * @param concept the type that subjects are searched for + * @return + */ public String makeConceptQuery(String concept){ return "SELECT DISTINCT ?subject\n"+ "WHERE { ?subject a <"+concept+">}\n"; } + + public String makeArticleQuery(String subject){ + return "SELECT ?predicate,?object\n"+ + "WHERE { <"+subject+"> ?predicate ?object}\n"; + } } Modified: trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2007-11-01 14:49:08 UTC (rev 275) +++ trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2007-11-05 13:03:14 UTC (rev 276) @@ -20,6 +20,8 @@ package org.dllearner.server; import java.util.Arrays; +import java.util.Calendar; +import java.util.Date; import java.util.List; import java.util.Map; import java.util.Random; @@ -474,12 +476,13 @@ } }; } else if (method.equals("triples")){ + final String subject=options[1]; thread = new Thread() { @Override public void run() { ((SparqlEndpoint)component).setTriplesThread(this); ((SparqlEndpoint)component).setTriplesThreadRunning(true); - ((SparqlEndpoint)component).calculateTriples(); + ((SparqlEndpoint)component).calculateTriples(subject); ((SparqlEndpoint)component).setTriplesThreadRunning(false); } }; @@ -540,8 +543,8 @@ } @WebMethod - public void debug(String deb) + public String debug(String deb) { - System.out.println(deb); + return "Test"; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2007-11-12 14:11:23
|
Revision: 280 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=280&view=rev Author: jenslehmann Date: 2007-11-12 06:11:18 -0800 (Mon, 12 Nov 2007) Log Message: ----------- made some more options thread safe Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/Config.java trunk/src/dl-learner/org/dllearner/ConfigurationManager.java trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java trunk/src/dl-learner/org/dllearner/algorithms/refinement/RhoDown.java trunk/src/dl-learner/org/dllearner/cli/Start.java Modified: trunk/src/dl-learner/org/dllearner/Config.java =================================================================== --- trunk/src/dl-learner/org/dllearner/Config.java 2007-11-11 09:41:14 UTC (rev 279) +++ trunk/src/dl-learner/org/dllearner/Config.java 2007-11-12 14:11:18 UTC (rev 280) @@ -112,16 +112,16 @@ public static class Refinement { // Nutzung der Äquivalenz ALL R.C AND ALL R.D = ALL R.(C AND D) - public static boolean applyAllFilter = true; +// public static boolean applyAllFilter = true; // Nutzung der Äquivalenz EXISTS R.C OR EXISTS R.D = EXISTS R.(C OR D) - public static boolean applyExistsFilter = true; +// public static boolean applyExistsFilter = true; - public static boolean useTooWeakList = true; +// public static boolean useTooWeakList = true; - public static boolean useOverlyGeneralList = true; +// public static boolean useOverlyGeneralList = true; - public static boolean useShortConceptConstruction = true; +// public static boolean useShortConceptConstruction = true; public static double horizontalExpansionFactor = 0.6; Modified: trunk/src/dl-learner/org/dllearner/ConfigurationManager.java =================================================================== --- trunk/src/dl-learner/org/dllearner/ConfigurationManager.java 2007-11-11 09:41:14 UTC (rev 279) +++ trunk/src/dl-learner/org/dllearner/ConfigurationManager.java 2007-11-12 14:11:18 UTC (rev 280) @@ -488,17 +488,17 @@ ; //Config.Refinement.writeSearchTree = Datastructures.strToBool(value); else if (option.equals("refinement.searchTreeFile")) { ; // Config.Refinement.searchTreeFile = new File(value); - } else if (option.equals("refinement.applyAllFilter")) - Config.Refinement.applyAllFilter = Datastructures.strToBool(value); - else if (option.equals("refinement.applyExistsFilter")) - Config.Refinement.applyExistsFilter = Datastructures.strToBool(value); - else if (option.equals("refinement.useTooWeakList")) - Config.Refinement.useTooWeakList = Datastructures.strToBool(value); - else if (option.equals("refinement.useOverlyGeneralList")) - Config.Refinement.useOverlyGeneralList = Datastructures.strToBool(value); - else if (option.equals("refinement.useShortConceptConstruction")) - Config.Refinement.useShortConceptConstruction = Datastructures.strToBool(value); - else if (option.equals("refinement.useAllConstructor")) +// } else if (option.equals("refinement.applyAllFilter")) +// Config.Refinement.applyAllFilter = Datastructures.strToBool(value); + } else if (option.equals("refinement.applyExistsFilter")) { +// Config.Refinement.applyExistsFilter = Datastructures.strToBool(value); +// } else if (option.equals("refinement.useTooWeakList")) +// Config.Refinement.useTooWeakList = Datastructures.strToBool(value); +// else if (option.equals("refinement.useOverlyGeneralList")) +// Config.Refinement.useOverlyGeneralList = Datastructures.strToBool(value); +// else if (option.equals("refinement.useShortConceptConstruction")) +// Config.Refinement.useShortConceptConstruction = Datastructures.strToBool(value); + } else if (option.equals("refinement.useAllConstructor")) Config.Refinement.useAllConstructor = Datastructures.strToBool(value); else if (option.equals("refinement.useExistsConstructor")) Config.Refinement.useExistsConstructor = Datastructures.strToBool(value); Modified: trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2007-11-11 09:41:14 UTC (rev 279) +++ trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2007-11-12 14:11:18 UTC (rev 280) @@ -54,6 +54,11 @@ // these are computed as the result of the previous four settings Set<AtomicConcept> usedConcepts; Set<AtomicRole> usedRoles; + private boolean applyAllFilter = true; + private boolean applyExistsFilter = true; + private boolean useTooWeakList = true; + private boolean useOverlyGeneralList = true; + private boolean useShortConceptConstruction = true; private boolean stop = false; @@ -214,6 +219,16 @@ ignoredConcepts = CommonConfigMappings.getAtomicConceptSet((Set<String>)entry.getValue()); } else if(name.equals("ignoredRoles")) { ignoredRoles = CommonConfigMappings.getAtomicRoleSet((Set<String>)entry.getValue()); + } else if(name.equals("applyAllFilter")) { + applyAllFilter = (Boolean) entry.getValue(); + } else if(name.equals("applyExistsFilter")) { + applyExistsFilter = (Boolean) entry.getValue(); + } else if(name.equals("useTooWeakList")) { + useTooWeakList = (Boolean) entry.getValue(); + } else if(name.equals("useOverlyGeneralList")) { + useOverlyGeneralList = (Boolean) entry.getValue(); + } else if(name.equals("useShortConceptConstruction")) { + useShortConceptConstruction = (Boolean) entry.getValue(); } } @@ -240,7 +255,7 @@ } // this.learningProblem2 = learningProblem2; - operator = new RhoDown(rs); + operator = new RhoDown(rs, applyAllFilter, applyExistsFilter); // candidate sets entsprechend der gewählten Heuristik initialisieren candidates = new TreeSet<Node>(nodeComparator); @@ -574,7 +589,7 @@ boolean propernessDetected = false; // 1. short concept construction - if(Config.Refinement.useShortConceptConstruction) { + if(useShortConceptConstruction) { // kurzes Konzept konstruieren Concept shortConcept = ConceptTransformation.getShortConcept(refinement, conceptComparator); int n = conceptComparator.compare(shortConcept, concept); @@ -587,7 +602,7 @@ } // 2. too weak test - if(!propernessDetected && Config.Refinement.useTooWeakList) { + if(!propernessDetected && useTooWeakList) { if(refinement instanceof MultiConjunction) { boolean tooWeakElement = containsTooWeakElement((MultiConjunction)refinement); if(tooWeakElement) { @@ -695,7 +710,7 @@ int quality = -2; // overly general list verwenden - if(Config.Refinement.useOverlyGeneralList && refinement instanceof MultiDisjunction) { + if(useOverlyGeneralList && refinement instanceof MultiDisjunction) { if(containsOverlyGeneralElement((MultiDisjunction)refinement)) { conceptTestsOverlyGeneralList++; quality = getNumberOfNegatives(); Modified: trunk/src/dl-learner/org/dllearner/algorithms/refinement/RhoDown.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refinement/RhoDown.java 2007-11-11 09:41:14 UTC (rev 279) +++ trunk/src/dl-learner/org/dllearner/algorithms/refinement/RhoDown.java 2007-11-12 14:11:18 UTC (rev 280) @@ -88,10 +88,15 @@ public long mComputationTimeNs = 0; public long topComputationTimeNs = 0; + private boolean applyAllFilter = true; + private boolean applyExistsFilter = true; + // braucht man wirklich das learningProblem oder reicht der Reasoning-Service? // TODO: conceptComparator könnte auch noch Parameter sein - public RhoDown(ReasoningService reasoningService) { + public RhoDown(ReasoningService reasoningService, boolean applyAllFilter, boolean applyExistsFilter) { this.rs = reasoningService; + this.applyAllFilter = applyAllFilter; + this.applyExistsFilter = applyExistsFilter; // this.learningProblem = learningProblem; // rs = learningProblem.getReasoningService(); } @@ -318,7 +323,7 @@ // falls Refinement von der Form ALL r ist, dann prüfen, ob // ALL r nicht bereits vorkommt - if(Config.Refinement.applyAllFilter) { + if(applyAllFilter) { if(c instanceof All) { for(Concept child : concept.getChildren()) { if(child instanceof All) { @@ -444,7 +449,7 @@ ConceptTransformation.transformToOrderedNegationNormalForm(concept, conceptComparator); } - if(Config.Refinement.applyExistsFilter) { + if(applyExistsFilter) { Iterator<MultiDisjunction> it = baseSet.iterator(); while(it.hasNext()) { MultiDisjunction md = it.next(); Modified: trunk/src/dl-learner/org/dllearner/cli/Start.java =================================================================== --- trunk/src/dl-learner/org/dllearner/cli/Start.java 2007-11-11 09:41:14 UTC (rev 279) +++ trunk/src/dl-learner/org/dllearner/cli/Start.java 2007-11-12 14:11:18 UTC (rev 280) @@ -120,6 +120,7 @@ sources.add(ks); configureComponent(cm, ks, componentPrefixMapping, parser); + initComponent(cm, ks); } // step 2: detect used reasoner @@ -134,6 +135,7 @@ } ReasonerComponent reasoner = cm.reasoner(reasonerClass, sources); configureComponent(cm, reasoner, componentPrefixMapping, parser); + initComponent(cm, reasoner); ReasoningService rs = cm.reasoningService(reasoner); // step 3: detect learning problem @@ -155,7 +157,8 @@ cm.applyConfigEntry(lp, "positiveExamples", posExamples); if(lpClass != PosOnlyDefinitionLP.class) cm.applyConfigEntry(lp, "negativeExamples", negExamples); - + initComponent(cm, lp); + // step 4: detect learning algorithm ConfFileOption algorithmOption = parser.getConfOptionsByName("algorithm"); LearningAlgorithm la = null; @@ -165,13 +168,14 @@ la = cm.learningAlgorithm(laClass, lp, rs); configureComponent(cm, la, componentPrefixMapping, parser); - + initComponent(cm, la); + // initialise all structures - for (KnowledgeSource source : sources) - initComponent(cm, source); - initComponent(cm, reasoner); - initComponent(cm, lp); - initComponent(cm, la); +// for (KnowledgeSource source : sources) +// initComponent(cm, source); +// initComponent(cm, reasoner); +// initComponent(cm, lp); +// initComponent(cm, la); // perform file exports performExports(parser, baseDir, sources, rs); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2007-11-12 14:26:11
|
Revision: 281 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=281&view=rev Author: jenslehmann Date: 2007-11-12 06:26:03 -0800 (Mon, 12 Nov 2007) Log Message: ----------- - now all options for the refinement operator based learning algorithm are thread safe - fixed some warnings Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/Config.java trunk/src/dl-learner/org/dllearner/ConfigurationManager.java trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java trunk/src/dl-learner/org/dllearner/algorithms/refinement/RhoDown.java trunk/src/dl-learner/org/dllearner/kb/SparqlOntologyCollector.java trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java trunk/src/dl-learner/org/dllearner/utilities/PaperStatistics.java Modified: trunk/src/dl-learner/org/dllearner/Config.java =================================================================== --- trunk/src/dl-learner/org/dllearner/Config.java 2007-11-12 14:11:18 UTC (rev 280) +++ trunk/src/dl-learner/org/dllearner/Config.java 2007-11-12 14:26:03 UTC (rev 281) @@ -123,11 +123,11 @@ // public static boolean useShortConceptConstruction = true; - public static double horizontalExpansionFactor = 0.6; +// public static double horizontalExpansionFactor = 0.6; - public static boolean improveSubsumptionHierarchy = true; +// public static boolean improveSubsumptionHierarchy = true; - public static boolean quiet = false; +// public static boolean quiet = false; // public static boolean writeSearchTree = false; @@ -168,13 +168,13 @@ // max. Verschachtelungstiefe der Lösung // nicht implementiert - public static int maxDepth = 0; +// public static int maxDepth = 0; // Konstruktoren an- und abschalten // nicht implementiert - public static boolean useAllConstructor = true; - public static boolean useExistsConstructor = true; - public static boolean useNegation = true; +// public static boolean useAllConstructor = true; +// public static boolean useExistsConstructor = true; +// public static boolean useNegation = true; // public static boolean useDisjunction = true; // public static boolean useConjunction = true; Modified: trunk/src/dl-learner/org/dllearner/ConfigurationManager.java =================================================================== --- trunk/src/dl-learner/org/dllearner/ConfigurationManager.java 2007-11-12 14:11:18 UTC (rev 280) +++ trunk/src/dl-learner/org/dllearner/ConfigurationManager.java 2007-11-12 14:26:03 UTC (rev 281) @@ -402,8 +402,8 @@ Config.GP.hillClimbingProbability = value / (double) 100; else if (option.equals("gp.refinementPercent")) Config.GP.refinementProbability = value / (double) 100; - else if (option.equals("refinement.horizontalExpansionFactor")) - Config.Refinement.horizontalExpansionFactor = value; +// else if (option.equals("refinement.horizontalExpansionFactor")) +// Config.Refinement.horizontalExpansionFactor = value; else if (option.equals("percentPerLengthUnit")) ; // Config.percentPerLengthUnit = value; } @@ -482,9 +482,9 @@ // Config.Refinement.heuristic = Config.Refinement.Heuristic.LEXICOGRAPHIC; // else // Config.Refinement.heuristic = Config.Refinement.Heuristic.FLEXIBLE; - } else if (option.equals("refinement.quiet")) - Config.Refinement.quiet = Datastructures.strToBool(value); - else if (option.equals("refinement.writeSearchTree")) + } else if (option.equals("refinement.quiet")) { +// Config.Refinement.quiet = Datastructures.strToBool(value); + } else if (option.equals("refinement.writeSearchTree")) ; //Config.Refinement.writeSearchTree = Datastructures.strToBool(value); else if (option.equals("refinement.searchTreeFile")) { ; // Config.Refinement.searchTreeFile = new File(value); @@ -498,12 +498,12 @@ // Config.Refinement.useOverlyGeneralList = Datastructures.strToBool(value); // else if (option.equals("refinement.useShortConceptConstruction")) // Config.Refinement.useShortConceptConstruction = Datastructures.strToBool(value); - } else if (option.equals("refinement.useAllConstructor")) - Config.Refinement.useAllConstructor = Datastructures.strToBool(value); - else if (option.equals("refinement.useExistsConstructor")) - Config.Refinement.useExistsConstructor = Datastructures.strToBool(value); - else if (option.equals("refinement.useNegation")) - Config.Refinement.useNegation = Datastructures.strToBool(value); +// } else if (option.equals("refinement.useAllConstructor")) +// Config.Refinement.useAllConstructor = Datastructures.strToBool(value); +// else if (option.equals("refinement.useExistsConstructor")) +// Config.Refinement.useExistsConstructor = Datastructures.strToBool(value); +// else if (option.equals("refinement.useNegation")) +// Config.Refinement.useNegation = Datastructures.strToBool(value); // else if (option.equals("reasoner")) { // if(value.equals("dig")) // Config.reasonerType = ReasonerType.DIG; @@ -511,7 +511,7 @@ // Config.reasonerType = ReasonerType.KAON2; // else if(value.equals("fastRetrieval")) // Config.reasonerType = ReasonerType.FAST_RETRIEVAL; - else if (option.equals("digReasonerURL")) { +// else if (option.equals("digReasonerURL")) { // try { // Config.digReasonerURL = new URL(value); // } catch (MalformedURLException e) { Modified: trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2007-11-12 14:11:18 UTC (rev 280) +++ trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2007-11-12 14:26:03 UTC (rev 281) @@ -11,7 +11,6 @@ import java.util.SortedSet; import java.util.TreeSet; -import org.dllearner.Config; import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasoningService; @@ -58,8 +57,14 @@ private boolean applyExistsFilter = true; private boolean useTooWeakList = true; private boolean useOverlyGeneralList = true; - private boolean useShortConceptConstruction = true; + private boolean useShortConceptConstruction = true; + private double horizontalExpansionFactor = 0.6; + private boolean useAllConstructor = true; + private boolean useExistsConstructor = true; + private boolean useNegation = true; + private boolean quiet = false; + private boolean stop = false; private ReasoningService rs; @@ -229,6 +234,14 @@ useOverlyGeneralList = (Boolean) entry.getValue(); } else if(name.equals("useShortConceptConstruction")) { useShortConceptConstruction = (Boolean) entry.getValue(); + } else if(name.equals("horzontalExpansionFactor")) { + horizontalExpansionFactor = (Double) entry.getValue(); + } else if(name.equals("useAllConstructor")) { + useAllConstructor = (Boolean) entry.getValue(); + } else if(name.equals("useExistsConstructor")) { + useExistsConstructor = (Boolean) entry.getValue(); + } else if(name.equals("useNegation")) { + useNegation = (Boolean) entry.getValue(); } } @@ -255,7 +268,7 @@ } // this.learningProblem2 = learningProblem2; - operator = new RhoDown(rs, applyAllFilter, applyExistsFilter); + operator = new RhoDown(rs, applyAllFilter, applyExistsFilter, useAllConstructor, useExistsConstructor, useNegation); // candidate sets entsprechend der gewählten Heuristik initialisieren candidates = new TreeSet<Node>(nodeComparator); @@ -343,7 +356,7 @@ // proper refinements mehr gefunden werden, aber wie stelle man das fest? while(!solutionFound && !stop) { - if(!Config.Refinement.quiet) + if(!quiet) printStatistics(false); // besten Knoten nach Heuristik auswählen @@ -360,7 +373,7 @@ // minimum horizontal expansion berechnen if(bestNode.getHorizontalExpansion()>maximumHorizontalExpansion) maximumHorizontalExpansion = bestNode.getHorizontalExpansion(); - minimumHorizontalExpansion = (int) Math.floor(Config.Refinement.horizontalExpansionFactor*maximumHorizontalExpansion); + minimumHorizontalExpansion = (int) Math.floor(horizontalExpansionFactor*maximumHorizontalExpansion); // neu: es werden solange Knoten erweitert bis wirklich jeder Knoten die // notwendige minimum horizontal expansion hat @@ -443,7 +456,7 @@ // Anzahl Schleifendurchläufe loop++; - if(!Config.Refinement.quiet) + if(!quiet) System.out.println("--- loop " + loop + " finished ---"); } Modified: trunk/src/dl-learner/org/dllearner/algorithms/refinement/RhoDown.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refinement/RhoDown.java 2007-11-12 14:11:18 UTC (rev 280) +++ trunk/src/dl-learner/org/dllearner/algorithms/refinement/RhoDown.java 2007-11-12 14:26:03 UTC (rev 281) @@ -29,7 +29,6 @@ import java.util.SortedSet; import java.util.TreeSet; -import org.dllearner.Config; import org.dllearner.core.ReasoningService; import org.dllearner.core.dl.All; import org.dllearner.core.dl.AtomicConcept; @@ -90,13 +89,21 @@ private boolean applyAllFilter = true; private boolean applyExistsFilter = true; + private boolean useAllConstructor = true; + private boolean useExistsConstructor = true; + private boolean useNegation = true; // braucht man wirklich das learningProblem oder reicht der Reasoning-Service? // TODO: conceptComparator könnte auch noch Parameter sein - public RhoDown(ReasoningService reasoningService, boolean applyAllFilter, boolean applyExistsFilter) { + public RhoDown(ReasoningService reasoningService, boolean applyAllFilter, boolean applyExistsFilter, boolean useAllConstructor, + boolean useExistsConstructor, boolean useNegation) { this.rs = reasoningService; this.applyAllFilter = applyAllFilter; this.applyExistsFilter = applyExistsFilter; + this.useAllConstructor = useAllConstructor; + this.useExistsConstructor = useExistsConstructor; + this.useNegation = useNegation; + // this.learningProblem = learningProblem; // rs = learningProblem.getReasoningService(); } @@ -517,7 +524,7 @@ if(topRefinementsLength<2 && maxLength>1) { // Konzepte der Länge 2 = Negation aller Konzepte, die über Bottom liegen - if(Config.Refinement.useNegation) { + if(useNegation) { Set<Concept> m2tmp = rs.getMoreGeneralConcepts(new Bottom()); Set<Concept> m2 = new TreeSet<Concept>(conceptComparator); for(Concept c : m2tmp) { @@ -529,7 +536,7 @@ if(topRefinementsLength<3 && maxLength>2) { // Konzepte der Länge 3: EXISTS r.TOP - if(Config.Refinement.useExistsConstructor) { + if(useExistsConstructor) { Set<Concept> m3 = new TreeSet<Concept>(conceptComparator); // previous operator: uses all roles // for(AtomicRole r : Config.Refinement.allowedRoles) { @@ -544,7 +551,7 @@ } if(maxLength>2) { - if(Config.Refinement.useAllConstructor) { + if(useAllConstructor) { // Konzepte, die mit ALL r starten // alle existierenden Konzepte durchgehen, die maximal 2 k�rzer als // die maximale L�nge sind Modified: trunk/src/dl-learner/org/dllearner/kb/SparqlOntologyCollector.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/SparqlOntologyCollector.java 2007-11-12 14:11:18 UTC (rev 280) +++ trunk/src/dl-learner/org/dllearner/kb/SparqlOntologyCollector.java 2007-11-12 14:26:03 UTC (rev 281) @@ -33,9 +33,7 @@ import java.util.Iterator; import java.util.Vector; -import org.dllearner.utilities.Datastructures; - /** * This class collects the ontology from dbpedia, * everything is saved in hashsets, so the doublettes are taken care of @@ -157,7 +155,7 @@ String end="</uri></binding>"; String predtmp=""; String objtmp=""; - ArrayList<String> al=new ArrayList<String>(); + // ArrayList<String> al=new ArrayList<String>(); while(xml.indexOf(one)!=-1){ //get pred xml=xml.substring(xml.indexOf(one)+one.length()); Modified: trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2007-11-12 14:11:18 UTC (rev 280) +++ trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2007-11-12 14:26:03 UTC (rev 281) @@ -20,8 +20,6 @@ package org.dllearner.server; import java.util.Arrays; -import java.util.Calendar; -import java.util.Date; import java.util.List; import java.util.Map; import java.util.Random; Modified: trunk/src/dl-learner/org/dllearner/utilities/PaperStatistics.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/PaperStatistics.java 2007-11-12 14:11:18 UTC (rev 280) +++ trunk/src/dl-learner/org/dllearner/utilities/PaperStatistics.java 2007-11-12 14:26:03 UTC (rev 281) @@ -215,8 +215,8 @@ if(algorithmNr==0) { // Config.algorithm = Algorithm.REFINEMENT; // Config.Refinement.heuristic = Config.Refinement.Heuristic.FLEXIBLE; - Config.Refinement.horizontalExpansionFactor = 0.6; - Config.Refinement.quiet = true; +// Config.Refinement.horizontalExpansionFactor = 0.6; +// Config.Refinement.quiet = true; // Config.percentPerLengthUnit = 0.05; // learningAlgorithm = new ROLearner(learningProblem); // learningAlgorithm = cm.learningAlgorithm(ROLearner.class, learningProblem); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2007-11-12 15:13:54
|
Revision: 282 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=282&view=rev Author: jenslehmann Date: 2007-11-12 07:13:50 -0800 (Mon, 12 Nov 2007) Log Message: ----------- - adapted genetic programming algorithm to work with new DL-Learner core - all configuration options of GP are now thread safe (removed option useMultiStructures) Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/Config.java trunk/src/dl-learner/org/dllearner/ConfigurationManager.java trunk/src/dl-learner/org/dllearner/algorithms/RandomGuesser.java trunk/src/dl-learner/org/dllearner/algorithms/gp/GP.java trunk/src/dl-learner/org/dllearner/algorithms/gp/GPUtilities.java trunk/src/dl-learner/org/dllearner/cli/Start.java trunk/src/dl-learner/org/dllearner/core/ReasoningService.java trunk/src/dl-learner/org/dllearner/utilities/PaperStatistics.java Modified: trunk/src/dl-learner/org/dllearner/Config.java =================================================================== --- trunk/src/dl-learner/org/dllearner/Config.java 2007-11-12 14:26:03 UTC (rev 281) +++ trunk/src/dl-learner/org/dllearner/Config.java 2007-11-12 15:13:50 UTC (rev 282) @@ -2,9 +2,6 @@ import java.lang.reflect.Field; -import org.dllearner.algorithms.gp.GP.AlgorithmType; -import org.dllearner.algorithms.gp.GP.SelectionType; - public class Config { // standardmäßig wird bis Tiefe 7 gesucht // public static int maxLength = 7; @@ -195,46 +192,46 @@ // FPS funktioniert momentan noch nicht, es muss sichergestellt werden, // dass die Fitness positiv ist (momentan ist sie nie gr��er 0) - public static SelectionType selectionType = SelectionType.RANK_SELECTION; - - public static int tournamentSize = 3; - - public static boolean elitism = true; - - public static AlgorithmType algorithmType = AlgorithmType.STEADY_STATE; - - public static double mutationProbability = 0.03d; - - public static double crossoverProbability = 0.95d; - - public static double hillClimbingProbability = 0.0d; - - public static double refinementProbability = 0.0; - - public static int numberOfIndividuals = 100; - - public static int numberOfSelectedIndividuals = 96; - - public static boolean useFixedNumberOfGenerations = false; - - public static int generations = 20; - - public static int postConvergenceGenerations = 50; - - public static boolean adc = false; - - public static int initMinDepth = 4; - - public static int initMaxDepth = 6; - - public static int maxConceptLength = 75; - - // bei true werden statt Disjunction MultiDisjunction und statt - // Conjunction - // MultiConjunction im GP benutzt (es gibt derzeit keinen Grund es auf - // false - // zu setzen) - public static boolean useMultiStructures = true; +// public static SelectionType selectionType = SelectionType.RANK_SELECTION; +// +// public static int tournamentSize = 3; +// +// public static boolean elitism = true; +// +// public static AlgorithmType algorithmType = AlgorithmType.STEADY_STATE; +// +// public static double mutationProbability = 0.03d; +// +// public static double crossoverProbability = 0.95d; +// +// public static double hillClimbingProbability = 0.0d; +// +// public static double refinementProbability = 0.0; +// +// public static int numberOfIndividuals = 100; +// +// public static int numberOfSelectedIndividuals = 96; +// +// public static boolean useFixedNumberOfGenerations = false; +// +// public static int generations = 20; +// +// public static int postConvergenceGenerations = 50; +// +// public static boolean adc = false; +// +// public static int initMinDepth = 4; +// +// public static int initMaxDepth = 6; +// +// public static int maxConceptLength = 75; +// +// // bei true werden statt Disjunction MultiDisjunction und statt +// // Conjunction +// // MultiConjunction im GP benutzt (es gibt derzeit keinen Grund es auf +// // false +// // zu setzen) +// public static boolean useMultiStructures = true; } Modified: trunk/src/dl-learner/org/dllearner/ConfigurationManager.java =================================================================== --- trunk/src/dl-learner/org/dllearner/ConfigurationManager.java 2007-11-12 14:26:03 UTC (rev 281) +++ trunk/src/dl-learner/org/dllearner/ConfigurationManager.java 2007-11-12 15:13:50 UTC (rev 282) @@ -8,10 +8,7 @@ import java.util.Map; import java.util.Set; -import org.dllearner.algorithms.gp.GP.AlgorithmType; -import org.dllearner.algorithms.gp.GP.SelectionType; import org.dllearner.cli.ConfFileOption; -import org.dllearner.utilities.Datastructures; /** * Nach dem einlesen der Datei werden hier alle Konfigurationsoptionen @@ -372,20 +369,20 @@ private void applyIntOptions(String option, int value) { if (option.equals("maxLength")) ;//Config.maxLength = value; - else if (option.equals("gp.numberOfIndividuals")) - Config.GP.numberOfIndividuals = value; - else if (option.equals("gp.numberOfSelectedIndividuals")) - Config.GP.numberOfSelectedIndividuals = value; - else if (option.equals("gp.postConvergenceGenerations")) - Config.GP.postConvergenceGenerations = value; - else if (option.equals("gp.generations")) - Config.GP.generations = value; - else if (option.equals("gp.tournamentSize")) - Config.GP.tournamentSize = value; - else if (option.equals("gp.initMinDepth")) - Config.GP.initMinDepth = value; - else if (option.equals("gp.initMaxDepth")) - Config.GP.initMaxDepth = value; +// else if (option.equals("gp.numberOfIndividuals")) +// Config.GP.numberOfIndividuals = value; +// else if (option.equals("gp.numberOfSelectedIndividuals")) +// Config.GP.numberOfSelectedIndividuals = value; +// else if (option.equals("gp.postConvergenceGenerations")) +// Config.GP.postConvergenceGenerations = value; +// else if (option.equals("gp.generations")) +// Config.GP.generations = value; +// else if (option.equals("gp.tournamentSize")) +// Config.GP.tournamentSize = value; +// else if (option.equals("gp.initMinDepth")) +// Config.GP.initMinDepth = value; +// else if (option.equals("gp.initMaxDepth")) +// Config.GP.initMaxDepth = value; } private void applyDoubleOptions(String option, double value) { @@ -394,14 +391,14 @@ ; //Config.accuracyPenalty = value; else if (option.equals("errorPenalty")) ; //Config.errorPenalty = value; - else if (option.equals("gp.crossoverPercent")) - Config.GP.crossoverProbability = value / (double) 100; - else if (option.equals("gp.mutationPercent")) - Config.GP.mutationProbability = value / (double) 100; - else if (option.equals("gp.hillClimbingPercent")) - Config.GP.hillClimbingProbability = value / (double) 100; - else if (option.equals("gp.refinementPercent")) - Config.GP.refinementProbability = value / (double) 100; +// else if (option.equals("gp.crossoverPercent")) +// Config.GP.crossoverProbability = value / (double) 100; +// else if (option.equals("gp.mutationPercent")) +// Config.GP.mutationProbability = value / (double) 100; +// else if (option.equals("gp.hillClimbingPercent")) +// Config.GP.hillClimbingProbability = value / (double) 100; +// else if (option.equals("gp.refinementPercent")) +// Config.GP.refinementProbability = value / (double) 100; // else if (option.equals("refinement.horizontalExpansionFactor")) // Config.Refinement.horizontalExpansionFactor = value; else if (option.equals("percentPerLengthUnit")) @@ -419,8 +416,8 @@ ; // Config.una = Datastructures.strToBool(value); else if (option.equals("owa")) ; // Config.owa = Datastructures.strToBool(value); - else if (option.equals("gp.useFixedNumberOfGenerations")) - Config.GP.useFixedNumberOfGenerations = Datastructures.strToBool(value); +// else if (option.equals("gp.useFixedNumberOfGenerations")) +// Config.GP.useFixedNumberOfGenerations = Datastructures.strToBool(value); // else if (option.equals("scoreMethod")) { // if (value.equals("full")) // Config.scoreMethod = ScoreMethod.FULL; @@ -462,21 +459,21 @@ } else if (option.equals("digProtocolFile")) { // Config.digProtocolFile = new File(value); // } else if (option.equals("preprocessingModule")) { - // Config.preprocessingModule = value; - } else if (option.equals("gp.selectionType")) { - if (value.equals("fps")) - Config.GP.selectionType = SelectionType.FPS; - else if (value.equals("rankSelection")) - Config.GP.selectionType = SelectionType.RANK_SELECTION; - else - Config.GP.selectionType = SelectionType.TOURNAMENT_SELECTION; - } else if (option.equals("gp.algorithmType")) { - if (value.equals("steadyState")) - Config.GP.algorithmType = AlgorithmType.STEADY_STATE; - else - Config.GP.algorithmType = AlgorithmType.GENERATIONAL; - } else if (option.equals("gp.adc")) { - Config.GP.adc = Datastructures.strToBool(value); +// // Config.preprocessingModule = value; +// } else if (option.equals("gp.selectionType")) { +// if (value.equals("fps")) +// Config.GP.selectionType = SelectionType.FPS; +// else if (value.equals("rankSelection")) +// Config.GP.selectionType = SelectionType.RANK_SELECTION; +// else +// Config.GP.selectionType = SelectionType.TOURNAMENT_SELECTION; +// } else if (option.equals("gp.algorithmType")) { +// if (value.equals("steadyState")) +// Config.GP.algorithmType = AlgorithmType.STEADY_STATE; +// else +// Config.GP.algorithmType = AlgorithmType.GENERATIONAL; +// } else if (option.equals("gp.adc")) { +//// Config.GP.adc = Datastructures.strToBool(value); } else if (option.equals("refinement.heuristic")) { // if(value.equals("lexicographic")) // Config.Refinement.heuristic = Config.Refinement.Heuristic.LEXICOGRAPHIC; Modified: trunk/src/dl-learner/org/dllearner/algorithms/RandomGuesser.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/RandomGuesser.java 2007-11-12 14:26:03 UTC (rev 281) +++ trunk/src/dl-learner/org/dllearner/algorithms/RandomGuesser.java 2007-11-12 15:13:50 UTC (rev 282) @@ -91,7 +91,7 @@ for(int i=0; i<numberOfTrees; i++) { // p = GPUtilities.createGrowRandomProgram(learningProblem, maxDepth); - p = GPUtilities.createGrowRandomProgram(learningProblem, maxDepth); + p = GPUtilities.createGrowRandomProgram(learningProblem, maxDepth, false); if(p.getFitness()>bestFitness) { bestFitness = p.getFitness(); bestScore = p.getScore(); Modified: trunk/src/dl-learner/org/dllearner/algorithms/gp/GP.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/gp/GP.java 2007-11-12 14:26:03 UTC (rev 281) +++ trunk/src/dl-learner/org/dllearner/algorithms/gp/GP.java 2007-11-12 15:13:50 UTC (rev 282) @@ -20,22 +20,6 @@ package org.dllearner.algorithms.gp; -import static org.dllearner.Config.GP.algorithmType; -import static org.dllearner.Config.GP.crossoverProbability; -import static org.dllearner.Config.GP.elitism; -import static org.dllearner.Config.GP.generations; -import static org.dllearner.Config.GP.hillClimbingProbability; -import static org.dllearner.Config.GP.initMaxDepth; -import static org.dllearner.Config.GP.initMinDepth; -import static org.dllearner.Config.GP.mutationProbability; -import static org.dllearner.Config.GP.numberOfIndividuals; -import static org.dllearner.Config.GP.numberOfSelectedIndividuals; -import static org.dllearner.Config.GP.postConvergenceGenerations; -import static org.dllearner.Config.GP.refinementProbability; -import static org.dllearner.Config.GP.selectionType; -import static org.dllearner.Config.GP.tournamentSize; -import static org.dllearner.Config.GP.useFixedNumberOfGenerations; - import java.text.DecimalFormat; import java.util.Arrays; import java.util.Collection; @@ -45,10 +29,10 @@ import java.util.Set; import java.util.Map.Entry; -import org.dllearner.Config; import org.dllearner.algorithms.hybridgp.Psi; import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.LearningProblem; +import org.dllearner.core.ReasoningService; import org.dllearner.core.Score; import org.dllearner.core.config.BooleanConfigOption; import org.dllearner.core.config.ConfigEntry; @@ -70,7 +54,7 @@ * */ public class GP extends LearningAlgorithm { - + // NumberFormat f; DecimalFormat df = new DecimalFormat("0.00"); @@ -103,6 +87,26 @@ FPS, TOURNAMENT_SELECTION}; + // configuration options + private SelectionType selectionType = SelectionType.RANK_SELECTION; + private int tournamentSize = 3; + private boolean elitism = true; + private AlgorithmType algorithmType = AlgorithmType.STEADY_STATE; + private double mutationProbability = 0.03d; + private double crossoverProbability = 0.95d; + private double hillClimbingProbability = 0.0d; + private double refinementProbability = 0.0; + private int numberOfIndividuals = 100; + private int numberOfSelectedIndividuals = 96; + private boolean useFixedNumberOfGenerations = false; + private int generations = 20; + private int postConvergenceGenerations = 50; + private boolean adc = false; + private int initMinDepth = 4; + private int initMaxDepth = 6; + private int maxConceptLength = 75; +// private boolean useMultiStructures = true; + private Program[] individuals; private Program fittestIndividual; @@ -123,6 +127,8 @@ // private GeneticRefinementOperator psi; private Psi psi; + private ReasoningService rs; + /** * Creates an algorithm object. By default a steady state algorithm with * rank selection is used. This operates @@ -130,16 +136,17 @@ * 1.0 and a probability of mutation of 0.01. * */ - public GP(PosNegLP learningProblem) { + public GP(PosNegLP learningProblem, ReasoningService rs) { this.learningProblem = learningProblem; + this.rs = rs; } - - public static Collection<Class<? extends LearningProblem>> supportedLearningAlgorithms() { + + public static Collection<Class<? extends LearningProblem>> supportedLearningProblems() { Collection<Class<? extends LearningProblem>> problems = new LinkedList<Class<? extends LearningProblem>>(); problems.add(PosNegLP.class); return problems; - } - + } + public static Collection<ConfigOption<?>> createConfigOptions() { Collection<ConfigOption<?>> options = new LinkedList<ConfigOption<?>>(); StringConfigOption selectionType = new StringConfigOption("selectionType", "selection type", "rankSelection"); @@ -191,7 +198,7 @@ IntegerConfigOption max = new IntegerConfigOption("maxConceptLength", "maximum concept length (higher length means lowest possible fitness)", 75); max.setLowerLimit(1); options.add(max); - options.add(new BooleanConfigOption("useMultiStructures", "specifies whether to use e.g. (a AND b AND c) instead of ((A and b) and c) - there is no apparent reason to set this to false", true)); +// options.add(new BooleanConfigOption("useMultiStructures", "specifies whether to use e.g. (a AND b AND c) instead of ((A and b) and c) - there is no apparent reason to set this to false", true)); return options; } @@ -200,7 +207,53 @@ */ @Override public <T> void applyConfigEntry(ConfigEntry<T> entry) throws InvalidConfigOptionValueException { - // String name = entry.getOptionName(); + String name = entry.getOptionName(); + if(name.equals("selectionType")) { + String value = (String) entry.getValue(); + if(value.equals("fps")) + selectionType = SelectionType.FPS; + else if(value.equals("tournament")) + selectionType = SelectionType.TOURNAMENT_SELECTION; + else + selectionType = SelectionType.RANK_SELECTION; + } else if(name.equals("tournamentSize")) { + tournamentSize = (Integer) entry.getValue(); + } else if(name.equals("elitism")) { + elitism = (Boolean) entry.getValue(); + } else if(name.equals("algorithmType")) { + String value = (String) entry.getValue(); + if(value.equals("generational")) + algorithmType = AlgorithmType.GENERATIONAL; + else + algorithmType = AlgorithmType.STEADY_STATE; + } else if(name.equals("mutationProbability")) { + mutationProbability = (Double) entry.getValue(); + } else if(name.equals("crossoverProbability")) { + crossoverProbability = (Double) entry.getValue(); + } else if(name.equals("refinementProbability")) { + refinementProbability = (Double) entry.getValue(); + } else if(name.equals("hillClimbingProbability")) { + hillClimbingProbability = (Double) entry.getValue(); + } else if(name.equals("numberOfIndividuals")) { + numberOfIndividuals = (Integer) entry.getValue(); + } else if(name.equals("numberOfSelectedIndividuals")) { + numberOfSelectedIndividuals = (Integer) entry.getValue(); + } else if(name.equals("useFixedNumberOfGenerations")) { + useFixedNumberOfGenerations = (Boolean) entry.getValue(); + } else if(name.equals("generations")) { + generations = (Integer) entry.getValue(); + } else if(name.equals("postConvergenceGenerations")) { + postConvergenceGenerations = (Integer) entry.getValue(); + } else if(name.equals("adc")) { + adc = (Boolean) entry.getValue(); + } else if(name.equals("initMinDepth")) { + initMinDepth = (Integer) entry.getValue(); + } else if(name.equals("initMaxDepth")) { + initMaxDepth = (Integer) entry.getValue(); + } else if(name.equals("maxConceptLength")) { + maxConceptLength = (Integer) entry.getValue(); + } + } /* (non-Javadoc) @@ -208,6 +261,8 @@ */ @Override public void init() { + rs.prepareSubsumptionHierarchy(); + rs.prepareRoleHierarchy(); } @Override @@ -449,8 +504,8 @@ // alle Individuen auf maximale Konzeptlänge überprüfen um mögliche // Speicherprobleme zu verhindern for(int i=0; i<numberOfIndividuals; i++) { - if(individuals[i].getTree().getLength()>Config.GP.maxConceptLength) { - System.out.println("Warning: GP produced concept longer then " + Config.GP.maxConceptLength + ". Replacing it with TOP."); + if(individuals[i].getTree().getLength()>maxConceptLength) { + System.out.println("Warning: GP produced concept longer then " + maxConceptLength + ". Replacing it with TOP."); individuals[i] = GPUtilities.createProgram(learningProblem, new Top()); } } @@ -470,7 +525,7 @@ boolean betterValueFoundInPsiCache = false; double bestValue = bestScore.getScore(); - if(Config.GP.refinementProbability > 0) { + if(refinementProbability > 0) { // das Problem ist hier, dass die gecachte Score nicht unbedingt // der echten Score entsprechen muss, d.h. hier muss die // Konzeptlänge mit einberechnet werden => deswegen werden @@ -554,9 +609,9 @@ // int depth = rand.nextInt(initMaxDepth-initMinDepth)+initMinDepth; if(grow) - individuals[i] = GPUtilities.createGrowRandomProgram(learningProblem,depth); + individuals[i] = GPUtilities.createGrowRandomProgram(learningProblem,depth, adc); else - individuals[i] = GPUtilities.createFullRandomProgram(learningProblem, depth); + individuals[i] = GPUtilities.createFullRandomProgram(learningProblem, depth, adc); } /* @@ -809,7 +864,7 @@ System.out.println("Psi application time percentage: " + df.format(psiTimePercent) + "%; " + df.format(psiWOReasoningTimePercent) + "% excluding reasoning"); } - if(Config.GP.adc) + if(adc) System.out.println("ADC: " + fittestIndividual.getAdc()); // TODO: hier muss noch eine Zusammenfassung rein, die sowohl f�r zweiwertiges als auch // dreiwertiges Lernproblem funktioniert Modified: trunk/src/dl-learner/org/dllearner/algorithms/gp/GPUtilities.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/gp/GPUtilities.java 2007-11-12 14:26:03 UTC (rev 281) +++ trunk/src/dl-learner/org/dllearner/algorithms/gp/GPUtilities.java 2007-11-12 15:13:50 UTC (rev 282) @@ -7,7 +7,6 @@ import java.util.SortedSet; import java.util.TreeMap; -import org.dllearner.Config; import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasoningMethodUnsupportedException; import org.dllearner.core.Score; @@ -16,8 +15,6 @@ import org.dllearner.core.dl.AtomicRole; import org.dllearner.core.dl.Bottom; import org.dllearner.core.dl.Concept; -import org.dllearner.core.dl.Conjunction; -import org.dllearner.core.dl.Disjunction; import org.dllearner.core.dl.Exists; import org.dllearner.core.dl.FlatABox; import org.dllearner.core.dl.Individual; @@ -90,7 +87,7 @@ extendedHypothesis = hypothesis; Score score; - if(Config.GP.adc) + if(adc != null) // TODO: ADC-Support // score = learningProblem.computeScore(extendedHypothesis, adc); throw new RuntimeException("ADC not supported"); @@ -139,7 +136,7 @@ */ public static Program mutation(LearningProblem learningProblem, Program p) { mutation++; - if(Config.GP.adc) { + if(p.getAdc() != null) { // TODO: hier kann man noch mehr Feinabstimmung machen, d.h. // Mutation abh�ngig von Knotenanzahl if(Math.random()<0.5) { @@ -232,7 +229,7 @@ */ public static Program[] crossover(LearningProblem learningProblem, Program p1, Program p2) { crossover++; - if(Config.GP.adc) { + if(p1.getAdc() != null) { Concept[] pt; Program result[] = new Program[2]; @@ -318,7 +315,7 @@ // Knoten kopieren, damit er sich nicht ver�ndert (es wird sonst der // parent-Link ver�ndert) Concept treecloned = (Concept) p.getTree().clone(); - if(Config.GP.adc) + if(p.getAdc() != null) return createProgram(learningProblem,hillClimbing(learningProblem,treecloned,(ScoreThreeValued)p.getScore()),p.getAdc()); else return createProgram(learningProblem,hillClimbing(learningProblem,treecloned,(ScoreThreeValued)p.getScore())); @@ -424,20 +421,20 @@ // returnNode = new Disjunction(); // returnNode.addChild(new AtomicConcept(name)); // returnNode.addChild(node); - if(Config.GP.useMultiStructures) +// if(useMultiStructures) returnNode = new MultiDisjunction(new AtomicConcept(name),node); - else - returnNode = new Disjunction(new AtomicConcept(name),node); +// else +// returnNode = new Disjunction(new AtomicConcept(name),node); // wegen else if schlie�en sich die F�lle gegenseitig aus } else if(nr<sizeSum2) { name = bestNeighbours.get(2).get(nr-sizeSum1); // returnNode = new Conjunction(); // returnNode.addChild(new AtomicConcept(name)); // returnNode.addChild(node); - if(Config.GP.useMultiStructures) +// if(useMultiStructures) returnNode = new MultiConjunction(new AtomicConcept(name),node); - else - returnNode = new Conjunction(new AtomicConcept(name),node); +// else +// returnNode = new Conjunction(new AtomicConcept(name),node); } else if(nr<sizeSum3) { name = bestNeighbours.get(3).get(nr-sizeSum2); // returnNode = new Exists(new AtomicRole(name)); @@ -621,8 +618,8 @@ * @param depth Depth of the tree. * @return The created program. */ - public static Program createFullRandomProgram(LearningProblem learningProblem, int depth) { - if(Config.GP.adc) { + public static Program createFullRandomProgram(LearningProblem learningProblem, int depth, boolean adc) { + if(adc) { // erster Baum Hauptbaum, zweiter Baum ADC return createProgram(learningProblem, createFullRandomTree(learningProblem, depth, true), createFullRandomTree(learningProblem, depth, false)); @@ -644,15 +641,15 @@ if(nr == 0 || nr == 1) { Concept child2 = createFullRandomTree(learningProblem, depth-1, useADC); if(nr == 0) { - if(Config.GP.useMultiStructures) +// if(useMultiStructures) return new MultiDisjunction(child1,child2); - else - return new Disjunction(child1,child2); +// else +// return new Disjunction(child1,child2); } else { - if(Config.GP.useMultiStructures) +// if(useMultiStructures) return new MultiConjunction(child1, child2); - else - return new Conjunction(child1, child2); +// else +// return new Conjunction(child1, child2); } } else if(nr==2) { return new Negation(child1); @@ -682,8 +679,8 @@ * @param depth The maximum depth of the program tree. * @return The created program. */ - public static Program createGrowRandomProgram(LearningProblem learningProblem, int depth) { - if(Config.GP.adc) { + public static Program createGrowRandomProgram(LearningProblem learningProblem, int depth, boolean adc) { + if(adc) { // erster Baum Hauptbaum, zweiter Baum ADC return createProgram(learningProblem, createGrowRandomTree(learningProblem,depth,true), createGrowRandomTree(learningProblem,depth,false)); @@ -773,15 +770,15 @@ else if(nr>=2 && nr < numberOfConcepts+2) return (AtomicConcept)learningProblem.getReasoningService().getAtomicConceptsList().get(nr-2).clone(); else if(nr==numberOfConcepts+2) { - if(Config.GP.useMultiStructures) +// if(useMultiStructures) return new MultiConjunction(createGrowRandomTree(learningProblem, depth-1, useADC),createGrowRandomTree(learningProblem, depth-1, useADC)); - else - return new Conjunction(createGrowRandomTree(learningProblem, depth-1, useADC),createGrowRandomTree(learningProblem, depth-1, useADC)); +// else +// return new Conjunction(createGrowRandomTree(learningProblem, depth-1, useADC),createGrowRandomTree(learningProblem, depth-1, useADC)); } else if(nr==numberOfConcepts+3) { - if(Config.GP.useMultiStructures) +// if(useMultiStructures) return new MultiDisjunction(createGrowRandomTree(learningProblem, depth-1, useADC),createGrowRandomTree(learningProblem, depth-1, useADC)); - else - return new Disjunction(createGrowRandomTree(learningProblem, depth-1, useADC),createGrowRandomTree(learningProblem, depth-1, useADC)); +// else +// return new Disjunction(createGrowRandomTree(learningProblem, depth-1, useADC),createGrowRandomTree(learningProblem, depth-1, useADC)); } else if(nr==numberOfConcepts+4) return new Negation(createGrowRandomTree(learningProblem, depth-1, useADC)); else if(nr>=numberOfConcepts+5 && nr<numberOfConcepts+5+numberOfRoles) Modified: trunk/src/dl-learner/org/dllearner/cli/Start.java =================================================================== --- trunk/src/dl-learner/org/dllearner/cli/Start.java 2007-11-12 14:26:03 UTC (rev 281) +++ trunk/src/dl-learner/org/dllearner/cli/Start.java 2007-11-12 15:13:50 UTC (rev 282) @@ -165,6 +165,10 @@ Class<? extends LearningAlgorithm> laClass = null; if (algorithmOption == null || algorithmOption.getStringValue().equals("refinement")) laClass = ROLearner.class; + else if(algorithmOption.getStringValue().equals("gp")) + laClass = GP.class; + else + handleError("Unknown value in " + algorithmOption); la = cm.learningAlgorithm(laClass, lp, rs); configureComponent(cm, la, componentPrefixMapping, parser); Modified: trunk/src/dl-learner/org/dllearner/core/ReasoningService.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ReasoningService.java 2007-11-12 14:26:03 UTC (rev 281) +++ trunk/src/dl-learner/org/dllearner/core/ReasoningService.java 2007-11-12 15:13:50 UTC (rev 282) @@ -329,6 +329,10 @@ return getRoleHierarchy().getMostSpecialRoles(); } + public void prepareSubsumptionHierarchy() { + reasoner.prepareSubsumptionHierarchy(getAtomicConcepts()); + } + public void prepareSubsumptionHierarchy(Set<AtomicConcept> allowedConcepts) { reasoner.prepareSubsumptionHierarchy(allowedConcepts); } @@ -343,6 +347,10 @@ } } + public void prepareRoleHierarchy() { + prepareRoleHierarchy(getAtomicRoles()); + } + public void prepareRoleHierarchy(Set<AtomicRole> allowedRoles) { try { reasoner.prepareRoleHierarchy(allowedRoles); Modified: trunk/src/dl-learner/org/dllearner/utilities/PaperStatistics.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/PaperStatistics.java 2007-11-12 14:26:03 UTC (rev 281) +++ trunk/src/dl-learner/org/dllearner/utilities/PaperStatistics.java 2007-11-12 15:13:50 UTC (rev 282) @@ -27,7 +27,6 @@ import java.util.Map; import java.util.SortedSet; -import org.dllearner.Config; import org.dllearner.ConfigurationManager; import org.dllearner.algorithms.gp.GP; import org.dllearner.core.ComponentManager; @@ -222,17 +221,17 @@ // learningAlgorithm = cm.learningAlgorithm(ROLearner.class, learningProblem); } else if(algorithmNr==1) { // Config.algorithm = Algorithm.GP; - Config.GP.algorithmType = GP.AlgorithmType.GENERATIONAL; - Config.GP.selectionType = GP.SelectionType.RANK_SELECTION; - Config.GP.generations = 50; - Config.GP.useFixedNumberOfGenerations = true; - Config.GP.numberOfIndividuals = 201; +// Config.GP.algorithmType = GP.AlgorithmType.GENERATIONAL; +//// Config.GP.selectionType = GP.SelectionType.RANK_SELECTION; +// Config.GP.generations = 50; +// Config.GP.useFixedNumberOfGenerations = true; +// Config.GP.numberOfIndividuals = 201; // if(exampleNr == 3 || exampleNr == 4) // Config.GP.numberOfIndividuals = 51; - Config.GP.refinementProbability = 0; - Config.GP.mutationProbability = 0.02; - Config.GP.crossoverProbability = 0.8; - Config.GP.hillClimbingProbability = 0; +// Config.GP.refinementProbability = 0; +// Config.GP.mutationProbability = 0.02; +// Config.GP.crossoverProbability = 0.8; +// Config.GP.hillClimbingProbability = 0; // Config.percentPerLengthUnit = 0.005; // give GP a chance to find the long solution of the // uncle problem @@ -242,17 +241,17 @@ learningAlgorithm = cm.learningAlgorithm(GP.class, learningProblem, rs); } else if(algorithmNr==2) { // Config.algorithm = Algorithm.HYBRID_GP; - Config.GP.algorithmType = GP.AlgorithmType.GENERATIONAL; - Config.GP.selectionType = GP.SelectionType.RANK_SELECTION; - Config.GP.generations = 50; - Config.GP.useFixedNumberOfGenerations = true; - Config.GP.numberOfIndividuals = 201; +// Config.GP.algorithmType = GP.AlgorithmType.GENERATIONAL; +// Config.GP.selectionType = GP.SelectionType.RANK_SELECTION; +// Config.GP.generations = 50; +// Config.GP.useFixedNumberOfGenerations = true; +// Config.GP.numberOfIndividuals = 201; //if(exampleNr == 3 || exampleNr == 4) // Config.GP.numberOfIndividuals = 51; - Config.GP.refinementProbability = 0.65; - Config.GP.mutationProbability = 0.02; - Config.GP.crossoverProbability = 0.2; - Config.GP.hillClimbingProbability = 0; +// Config.GP.refinementProbability = 0.65; +// Config.GP.mutationProbability = 0.02; +// Config.GP.crossoverProbability = 0.2; +// Config.GP.hillClimbingProbability = 0; // Config.percentPerLengthUnit = 0.005; // if(exampleNr == 3 || exampleNr==5 || exampleNr==6) // Config.percentPerLengthUnit = 0.002; @@ -438,36 +437,36 @@ if (j == 0) { // Config.algorithm = Algorithm.HYBRID_GP; - Config.GP.numberOfIndividuals = i + 1; - Config.GP.refinementProbability = 0.85; - Config.GP.mutationProbability = 0.02; - Config.GP.crossoverProbability = 0.05; - Config.GP.hillClimbingProbability = 0; +// Config.GP.numberOfIndividuals = i + 1; +// Config.GP.refinementProbability = 0.85; +// Config.GP.mutationProbability = 0.02; +// Config.GP.crossoverProbability = 0.05; +// Config.GP.hillClimbingProbability = 0; } else if (j == 1) { // Config.algorithm = Algorithm.HYBRID_GP; - Config.GP.numberOfIndividuals = i + 1; - Config.GP.refinementProbability = 0.4; - Config.GP.mutationProbability = 0.02; - Config.GP.crossoverProbability = 0.4; - Config.GP.hillClimbingProbability = 0; +// Config.GP.numberOfIndividuals = i + 1; +// Config.GP.refinementProbability = 0.4; +// Config.GP.mutationProbability = 0.02; +// Config.GP.crossoverProbability = 0.4; +// Config.GP.hillClimbingProbability = 0; } else if (j == 2) { // Config.algorithm = Algorithm.GP; - Config.GP.numberOfIndividuals = i + 1; - Config.GP.refinementProbability = 0; - Config.GP.mutationProbability = 0.02; - Config.GP.crossoverProbability = 0.8; - Config.GP.hillClimbingProbability = 0; +// Config.GP.numberOfIndividuals = i + 1; +// Config.GP.refinementProbability = 0; +// Config.GP.mutationProbability = 0.02; +// Config.GP.crossoverProbability = 0.8; +// Config.GP.hillClimbingProbability = 0; } else if (j == 3) { // Config.algorithm = Algorithm.HYBRID_GP; - Config.GP.numberOfIndividuals = i + 1; - Config.GP.refinementProbability = 0.7; - Config.GP.mutationProbability = 0.02; - Config.GP.crossoverProbability = 0.1; - Config.GP.hillClimbingProbability = 0; +// Config.GP.numberOfIndividuals = i + 1; +// Config.GP.refinementProbability = 0.7; +// Config.GP.mutationProbability = 0.02; +// Config.GP.crossoverProbability = 0.1; +// Config.GP.hillClimbingProbability = 0; } algorithmStartTime = System.nanoTime(); - gp = new GP(learningProblem); +// gp = new GP(learningProblem); long algorithmTime = System.nanoTime() - algorithmStartTime; long algorithmTimeSeconds = algorithmTime / 1000000000; @@ -475,16 +474,16 @@ // freigibt ((DIGReasoner) reasoner).releaseKB(); - int conceptLength = gp.getBestSolution().getLength(); - Score bestScore = gp.getSolutionScore(); - int misClassifications = bestScore.getCoveredNegatives().size() - + bestScore.getNotCoveredPositives().size(); - double classificationRatePercent = 100 * ((nrOfExamples - misClassifications) / (double) nrOfExamples); +// int conceptLength = gp.getBestSolution().getLength(); +// Score bestScore = gp.getSolutionScore(); +// int misClassifications = bestScore.getCoveredNegatives().size() +// + bestScore.getNotCoveredPositives().size(); +// double classificationRatePercent = 100 * ((nrOfExamples - misClassifications) / (double) nrOfExamples); +// +// statAr[j][0].addNumber(classificationRatePercent); +// statAr[j][1].addNumber(conceptLength); +// statAr[j][2].addNumber(algorithmTimeSeconds); - statAr[j][0].addNumber(classificationRatePercent); - statAr[j][1].addNumber(conceptLength); - statAr[j][2].addNumber(algorithmTimeSeconds); - } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2007-11-12 15:19:31
|
Revision: 283 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=283&view=rev Author: jenslehmann Date: 2007-11-12 07:19:23 -0800 (Mon, 12 Nov 2007) Log Message: ----------- removed deprecated classes Config and ConfigurationManager (finally) Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/utilities/PaperStatistics.java Removed Paths: ------------- trunk/src/dl-learner/org/dllearner/Config.java trunk/src/dl-learner/org/dllearner/ConfigurationManager.java Deleted: trunk/src/dl-learner/org/dllearner/Config.java =================================================================== --- trunk/src/dl-learner/org/dllearner/Config.java 2007-11-12 15:13:50 UTC (rev 282) +++ trunk/src/dl-learner/org/dllearner/Config.java 2007-11-12 15:19:23 UTC (rev 283) @@ -1,261 +0,0 @@ -package org.dllearner; - -import java.lang.reflect.Field; - -public class Config { - // standardmäßig wird bis Tiefe 7 gesucht - // public static int maxLength = 7; - - // public static int maxDepth; - - // Punktabzug für "ungenaue" Klassifizierungen, also positiv als neutral, - // neutral als negativ und negativ als neutral - // public static double accuracyPenalty = 1; - - // Punktabzug für fehlerhafte Klassifizierungen, also positiv als negativ - // und negativ als positiv - // public static double errorPenalty = 3; - - // public static ScoreMethod scoreMethod = ScoreMethod.POSITIVE; - - // public static LearningProblemType learningProblemType = LearningProblemType.TWO_VALUED; - - // public static boolean penalizeNeutralExamples = false; - - // public static boolean showCorrectClassifications = false; - - // wieviel Prozent darf ein um eine Einheit längeres Konzept schlechter - // sein (aktuell: 5% sind eine Verlängerung um 1 wert) - // Problem: dieser Parameter hat für GP und Refinement zwar die gleiche - // Bedeutung, - // aber es sind unterschiedliche Werte angebracht; - // bei GP sollte der Wert so sein, dass am Ende das gewünschte Konzept - // tatsächlich die beste Fitness hat, also eher niedrig (<0.005); - // bei Refinement in flexible heuristic soll es so sein, dass schlechtere - // Konzepte - // probiert werden sollen, sobald horizontal expansion eines gut - // klassifizierenden - // Knotens steigt => da ist also gewünscht das kürzere aber schlechtere - // Knoten - // ev. einen Vorsprung haben => demzufolge ist dort ein hoher Wert (ca. - // 0.05) - // angebracht - // public static double percentPerLengthUnit = 0.0025; - // public static double percentPerLengthUnit = 0.05; - -// public enum Algorithm { -// GP, BRUTE_FORCE, RANDOM_GUESSER, REFINEMENT, HYBRID_GP -// }; -// -// public static Algorithm algorithm = Algorithm.REFINEMENT; - - // Rückgabetyp des gelernten Konzepts - // public static String returnType = ""; - - // public static boolean statisticMode = false; - - // if set to true a retrieval algorithm is used for classification - // instead of single instance checks (default is now false, because - // we can send all instance checks in a single request), for KAON2 - // as reasoner it should in many cases be set to true - // public static boolean useRetrievalForClassification = false; - - // welche Art von Reasoning wird benutzt (eigener Algorithmus, - // KAON2-API, DIG-Interface) - // public static ReasonerType reasonerType = ReasonerType.DIG; - - // bei fast retrieval muss trotzdem irgendein Reasoner gesetzt - // werden um die flat ABox zu erzeugen - // public static ReasonerType startUpReasoningType = ReasonerType.KAON2; - - // public static URL digReasonerURL = null; - - // unique names assumption - // public static boolean una = false; - - // open world assumption; momentan wird closed world assumption nur - // fuer Rollen unterstuetzt - // public static boolean owa = true; - - // an-/abschalten von System.nanoTime()-Aufrufen außerhalb des - // Reasoningservice - // public static boolean useNonReasonerBenchmarks = false; - - // erlaubt das abschalten von Benchmarks bei der Subsumptionhierarchie, - // da diese ohnehin gecacht wird, also die System.nanoTime()-Aufrufe nur - // Zeit kosten - // public static boolean useHierarchyReasonerBenchmarks = false; - - // public static List<String> hidePrefixes = new LinkedList<String>(); - - // Informationen (Rollen, Konzepte, Individuen, Anzahl Axiome) über - // Wissensbasis anzeigen => alles konfigurierbar um Output in Grenzen - // zu halten -// public static boolean showRoles = false; -// public static boolean showConcepts = false; -// public static boolean showIndividuals = false; -// public static boolean showSubsumptionHierarchy = false; - // zeigt die interne Wissensbasis an (d.h. keine externen OWL-Dateien) -// public static boolean showInternalKB = false; -// public static int maxLineLength = 100; - - // public static boolean writeDIGProtocol = false; - // public static File digProtocolFile = new File("log/digProtocol.txt"); - - // public static String preprocessingModule = ""; - - // TODO: noch nicht implementiert, dass man diese per Config-Datei setzen - // kann - public static class Refinement { - - // Nutzung der Äquivalenz ALL R.C AND ALL R.D = ALL R.(C AND D) -// public static boolean applyAllFilter = true; - - // Nutzung der Äquivalenz EXISTS R.C OR EXISTS R.D = EXISTS R.(C OR D) -// public static boolean applyExistsFilter = true; - -// public static boolean useTooWeakList = true; - -// public static boolean useOverlyGeneralList = true; - -// public static boolean useShortConceptConstruction = true; - -// public static double horizontalExpansionFactor = 0.6; - -// public static boolean improveSubsumptionHierarchy = true; - -// public static boolean quiet = false; - - // public static boolean writeSearchTree = false; - - // public static File searchTreeFile = new File("searchTree.txt"); - - // public static Heuristic heuristic = Heuristic.LEXICOGRAPHIC; - - // multi instance check => es wird versucht mehrere instance checks pro - // Anfrage auf einmal an den Reasoner zu schicken; Vorteil bei DIG: - // weniger Kommunikation; Nachteil: es müssen alle instanceChecks - // ausgeführt - // werden, bevor too weak festgestellt werden kann - // TODO: not implemented -// public static UseMultiInstanceChecks useDIGMultiInstanceChecks = UseMultiInstanceChecks.TWOCHECKS; - - // geplante Optionen um den Suchraum einzuschränken - - // Konzepte, die in der Definition vorkommen können (per Default - // ("null") alle) - // nicht implementiert -// public static Set<AtomicConcept> allowedConcepts = null; - // ignorierte Konzepte; Default null = keine -// public static Set<AtomicConcept> ignoredConcepts = null; - // beachte: es können nur entweder die erlaubten oder die ignorierten - // Konzepte - // gesetzt werden - - // true falls die Konzepte vom Nutzer gesetzt worden (also - // allowedConcepts - // gleich null), ansonsten false -// public static boolean allowedConceptsAutoDetect = true; - - // Rollen, die in der Lösung vorkommen können - // nicht implementiert -// public static Set<AtomicRole> allowedRoles = null; -// public static Set<AtomicRole> ignoredRoles = null; -// public static boolean allowedRolesAutoDetect = true; - - // max. Verschachtelungstiefe der Lösung - // nicht implementiert -// public static int maxDepth = 0; - - // Konstruktoren an- und abschalten - // nicht implementiert -// public static boolean useAllConstructor = true; -// public static boolean useExistsConstructor = true; -// public static boolean useNegation = true; - // public static boolean useDisjunction = true; - // public static boolean useConjunction = true; - - // Domain und Range beim Verschachteln von Rollen beachten - // nicht implementiert - // TODO: Wie soll man das in DIG machen? -// public static boolean useDomainRange = false; - - // bereits vorher allgemeinere Konzepte festlegen (Default: keine) - // nicht implementiert - // => ist eigentlich unnötig, da dieses Wissen zur Ontologie hinzugefügt - // und dann gelernt werden kann - // public static List<AtomicConcept> fixedUpperConcepts; - - } - - public static class GP { - - // FPS funktioniert momentan noch nicht, es muss sichergestellt werden, - // dass die Fitness positiv ist (momentan ist sie nie gr��er 0) -// public static SelectionType selectionType = SelectionType.RANK_SELECTION; -// -// public static int tournamentSize = 3; -// -// public static boolean elitism = true; -// -// public static AlgorithmType algorithmType = AlgorithmType.STEADY_STATE; -// -// public static double mutationProbability = 0.03d; -// -// public static double crossoverProbability = 0.95d; -// -// public static double hillClimbingProbability = 0.0d; -// -// public static double refinementProbability = 0.0; -// -// public static int numberOfIndividuals = 100; -// -// public static int numberOfSelectedIndividuals = 96; -// -// public static boolean useFixedNumberOfGenerations = false; -// -// public static int generations = 20; -// -// public static int postConvergenceGenerations = 50; -// -// public static boolean adc = false; -// -// public static int initMinDepth = 4; -// -// public static int initMaxDepth = 6; -// -// public static int maxConceptLength = 75; -// -// // bei true werden statt Disjunction MultiDisjunction und statt -// // Conjunction -// // MultiConjunction im GP benutzt (es gibt derzeit keinen Grund es auf -// // false -// // zu setzen) -// public static boolean useMultiStructures = true; - - } - - public static String print() { - StringBuffer buff = new StringBuffer(); - buff.append("** overview of all set config values**\n\n"); - - Field[] fields = Config.class.getDeclaredFields(); - // Field[] fields = this.getClass().getDeclaredFields(); - for (int i = 0; i < fields.length; i++) { - try { - buff.append(fields[i].getName()).append("\t=>\t").append(fields[i].get(Config.class)) - .append("\n"); - - // System.out.println(fields[i].getName() + " : values: " + - // fields[i].get(this)); - } catch (IllegalAccessException ex) { - ex.printStackTrace(System.out); - } catch (IllegalArgumentException ex) { - ex.printStackTrace(System.out); - } - - } - return buff.toString(); - - } -} Deleted: trunk/src/dl-learner/org/dllearner/ConfigurationManager.java =================================================================== --- trunk/src/dl-learner/org/dllearner/ConfigurationManager.java 2007-11-12 15:13:50 UTC (rev 282) +++ trunk/src/dl-learner/org/dllearner/ConfigurationManager.java 2007-11-12 15:19:23 UTC (rev 283) @@ -1,574 +0,0 @@ -package org.dllearner; - -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.dllearner.cli.ConfFileOption; - -/** - * Nach dem einlesen der Datei werden hier alle Konfigurationsoptionen - * abgespeichert. Diese werden hier erst verwaltet und dann - * angewandt, indem die Werte der Variablen in Config umgeschrieben - * werden (bzw. es werden Fehlermeldungen bei nicht existierenden, - * inkorrekten oder inkompatiblen Einstellungen ausgegeben). - * - * TODO: Eventuell kann man damit Config.java ersetzen? Das w�re etwas - * sauberer, wenn man den DL-Learner als API sieht, der z.B. von - * OntoWiki aus genutzt wird. Dann k�nnte man sicherstellen, dass - * Konfigurationsoptionen nicht direkt ge�ndert werden, sondern - * �ber Anmeldung von �nderungen beim Konfigurationsmanager. - * - * TODO: noch checken, ob man die �berpr�fung der G�ltigkeit von - * Konfigurationsoptionen nicht schon bei deren Erstellung machen sollte - * - * @author jl - * - */ -public class ConfigurationManager { - - private Collection<ConfFileOption> options; - - // verfuegbare Optionen - // Problemfall: double-Optionen, die auch int-Optionen sein können; - // diese sind in beiden Mengen vertreten => man kann vereinbaren, dass - // jede double-Option auch eine int-Option sein kann - private Map<String, Integer[]> intOptions; - private Map<String, Double[]> doubleOptions; - private Map<String, String[]> strOptions; - private List<String> setOptions; - - public ConfigurationManager() { - this(new LinkedList<ConfFileOption>()); - } - - public ConfigurationManager(Collection<ConfFileOption> confOptions) { - // options = new HashSet<ConfigurationOption>(); - options = confOptions; - strOptions = new HashMap<String, String[]>(); - intOptions = new HashMap<String, Integer[]>(); - doubleOptions = new HashMap<String, Double[]>(); - setOptions = new LinkedList<String>(); - createIntOptions(); - createDoubleOptions(); - createStringOptions(); - createSetOptions(); - } - - public void applyOptions() { - for(ConfFileOption option : options) { - // System.out.println(option); - applyConfigurationOption(option); - } - - // DIG-Reasoner-URL setzen, falls nicht schon geschehen (kann wegen Exception - // nicht in Config gesetzt werden) -// if(Config.digReasonerURL == null) { -// try { -// Config.digReasonerURL = new URL("http://localhost:8081"); -// } catch (MalformedURLException e) { -// // Exception tritt nie auf, da URL korrekt -// e.printStackTrace(); -// } -// } - - // der parserinterne Namespace wird immer ausgeblendet - ; // Config.hidePrefixes.add(KBParser.internalNamespace); - - } - - // ueberprueft, ob es Konflikte zwischen derzeit gesetzten Konfigurationsoptionen gibt - public boolean checkConsistency() { - return true; - } - - // TODO: bei Fehlerbehandlungen müsste man jetzt noch berücksichtigen, dass - // Mengen als 4. Optionstyp (neben int, double, string) dazugekommen sind - public void applyConfigurationOption(ConfFileOption option) { - String optionString; - if(option.containsSubOption()) - optionString = option.getOption() + "." + option.getSubOption(); - else - optionString = option.getOption(); - - if(option.isNumeric()) { - - boolean isInIntOptions = intOptions.containsKey(optionString); - boolean isInDoubleOptions = doubleOptions.containsKey(optionString); - - // numerische Option existiert - if(isInIntOptions || isInDoubleOptions) { - - // es ist eine Option, die nur int-Werte haben darf - if(isInIntOptions) { - if(!option.isIntegerOption()) - throw new Error("The argument of configuration option \"" - + optionString + "\" has to be an integer."); - - // ueberpruefen, ob Wert innerhalb der vorgegebenen Schranken liegt - int minValue = intOptions.get(optionString)[0]; - int maxValue = intOptions.get(optionString)[1]; - if (option.getIntValue() < minValue || option.getIntValue() > maxValue) { - System.out.println("Error: The argument of configuration option \"" - + optionString + "\" is out of range. It has to be between " - + minValue + " and " + maxValue + "."); - System.exit(0); - } - - // alles OK, Option kann angewandt werden - applyIntOptions(optionString,option.getIntValue()); - // es ist eine Option, die int- oder double-Werte haben darf - } else { - // ueberpruefen, ob Wert innerhalb der vorgegebenen Schranken liegt - double minValue = doubleOptions.get(optionString)[0]; - double maxValue = doubleOptions.get(optionString)[1]; - - // Wert der Option bestimmen - double val; - if(option.isIntegerOption()) - val = option.getIntValue(); - else - val = option.getDoubleValue(); - - if (val < minValue || val > maxValue) { - System.out.println("Error: The argument of configuration option \"" - + optionString + "\" is out of range. It has to be between " - + minValue + " and " + maxValue + "."); - System.exit(0); - } - - // alles OK, Option kann angewandt werden - applyDoubleOptions(optionString,val); - } - - // numerische Option existiert nicht => Fehlerbehandlung - } else { - if(strOptions.containsKey(optionString)) - throw new RuntimeException("The argument of configuration option \"" - + optionString + "\" has to be a string."); - else - throw new RuntimeException("Configuration option \"" - + optionString + "\" does not exist."); - } - } else if (option.isSetOption()) { - if(setOptions.contains(optionString)) { - applySetOptions(optionString,option.getSetValues()); - } else { - throw new Error("Configuration option \"" - + optionString + "\" does not exist or its argument is not a list."); - } - - } else { - // Option existiert - if(strOptions.containsKey(optionString)) { - // ueberpruefen, ob Optionswert numerisch ist - if(option.isIntegerOption()) - throw new Error("The argument of configuration option \"" - + optionString + "\" has to be a string."); - - // moegliche Werte pruefen (wenn keine moeglichen Werte angegeben sind, dann sind - // alle Strings erlaubt) - String[] possibleValuesArray = strOptions.get(optionString); - List<String> possibleValues = Arrays.asList(possibleValuesArray); - if (!possibleValues.contains(option.getStringValue()) && possibleValues.size() != 0) { - System.out.println("Error: The configuration option \"" + optionString - + "\" must not have value \"" + option.getStringValue() - + "\". The value must be one of " + possibleValues + "."); - System.exit(0); - } - - // alles OK, Option kann angewandt werden - applyStringOptions(optionString,option.getStringValue()); - - // Option existiert nicht => Fehlerbehandlung - } else { - if(intOptions.containsKey(optionString)) - throw new Error("The argument of configuration option \"" - + optionString + "\" has to be a number."); - else - throw new Error("Configuration option \"" - + optionString + "\" does not exist."); - } - } - // options.add(option); - } - - // Code aus Main zur Behandlung von Optionen - /* - if (node instanceof ASTConfOption) { - // allgemeine Variablenzuweisungen, damit die Implementierung - // f�r jede einzelne Option dann einfach wird - String option = ((ASTId) node.jjtGetChild(0)).getId(); - String optionIndex = option; - // etwas vorsichtig sein, da Werte initialisiert werden, auch - // wenn es z.B. keinen Integer in der Option gibt - String subOption = ""; - boolean valueIsInt = false; - int intValue = 0; - String strValue = ""; - // zwei Optionen mit Punkt getrennt - if (node.jjtGetNumChildren() == 3) { - subOption = ((ASTId) node.jjtGetChild(1)).getId(); - optionIndex += "." + subOption; - if (node.jjtGetChild(2) instanceof ASTNumber) { - intValue = ((ASTNumber) node.jjtGetChild(2)).getId(); - valueIsInt = true; - } else - strValue = ((ASTId) node.jjtGetChild(2)).getId(); - // eine Option - } else { - if (node.jjtGetChild(1) instanceof ASTNumber) { - intValue = ((ASTNumber) node.jjtGetChild(1)).getId(); - valueIsInt = true; - } else - strValue = ((ASTId) node.jjtGetChild(1)).getId(); - } - - if (intOptions.containsKey(optionIndex)) { - if (!valueIsInt) { - System.out.println("Error: The argument of configuration option \"" - + optionIndex + "\" has to be a number."); - System.exit(0); - } - int minValue = intOptions.get(optionIndex)[0]; - int maxValue = intOptions.get(optionIndex)[1]; - if (intValue < minValue || intValue > maxValue) { - System.out.println("Error: The argument of configuration option \"" - + optionIndex + "\" is out of range. It has to be between " - + minValue + " and " + maxValue + "."); - System.exit(0); - } - - applyIntOptions(optionIndex, intValue); - - } else if (strOptions.containsKey(optionIndex)) { - if (valueIsInt) { - System.out.println("The argument of configuration option \"" + optionIndex - + "\" must not be a number."); - System.exit(0); - } - - String[] possibleValuesArray = strOptions.get(optionIndex); - List<String> possibleValues = Arrays.asList(possibleValuesArray); - if (!possibleValues.contains(strValue) && possibleValues.size() != 0) { - System.out.println("Error: The configuration option \"" + optionIndex - + "\" must not have value \"" + strValue - + "\". The value must be one of " + possibleValues + "."); - System.exit(0); - } - - applyStringOptions(optionIndex, strValue); - - } else { - System.out.println("Error: " + optionIndex - + " is not a valid configuration option"); - System.exit(0); - } - - } - - */ - - - - //private Map<String, Integer[]> createIntOptions() { - // Map<String, Integer[]> intOptions = new HashMap<String, Integer[]>(); - private void createIntOptions() { - - intOptions.put("maxLength", new Integer[] { 1, 20 }); - // intOptions.put("accuracyPenalty", new Integer[] { 1, 1000 }); - // intOptions.put("errorPenalty", new Integer[] { 1, 1000 }); - intOptions.put("gp.numberOfIndividuals", new Integer[] { 10, 1000000 }); - intOptions.put("gp.numberOfSelectedIndividuals", new Integer[] { 10, 1000000 }); - // intOptions.put("gp.crossoverPercent", new Integer[] { 0, 100 }); - // intOptions.put("gp.mutationPercent", new Integer[] { 0, 100 }); - // intOptions.put("gp.hillClimbingPercent", new Integer[] { 0, 100 }); - intOptions.put("gp.postConvergenceGenerations", new Integer[] { 10, 1000 }); - intOptions.put("gp.generations", new Integer[] { 10, 1000 }); - intOptions.put("gp.tournamentSize", new Integer[] { 1, 10 }); - intOptions.put("gp.initMinDepth", new Integer[] { 1, 10 }); - intOptions.put("gp.initMaxDepth", new Integer[] { 1, 20 }); - - // return intOptions; - } - - private void createDoubleOptions() { - - // double-Optionen, die auch int sein können - doubleOptions.put("accuracyPenalty", new Double[] { 1d, 1000d }); - doubleOptions.put("errorPenalty", new Double[] { 1d, 1000d }); - doubleOptions.put("gp.crossoverPercent", new Double[] { 0d, 100d }); - doubleOptions.put("gp.mutationPercent", new Double[] { 0d, 100d }); - doubleOptions.put("gp.hillClimbingPercent", new Double[] { 0d, 100d }); - doubleOptions.put("gp.refinementPercent", new Double[] { 0d, 100d }); - doubleOptions.put("refinement.horizontalExpansionFactor", new Double[] { 0d, 1d }); - doubleOptions.put("percentPerLengthUnit", new Double[] { 0d, 1d }); - - } - - //private Map<String, String[]> createStringOptions() { - // Map<String, String[]> strOptions = new HashMap<String, String[]>(); - private void createStringOptions() { - final String[] booleanArray = new String[] { "true", "false" }; - // leerer Array = keine Einschraenkung - - strOptions.put("penalizeNeutralExamples", booleanArray); - strOptions.put("scoreMethod", new String[] { "full", "positive" }); - strOptions.put("showCorrectClassifications", booleanArray); - // etwas eleganter waere hier, wenn man erst die Wissensbasis und dann - // die Optionen parst, dann koennte man implementieren, dass der Rueckgabetyp - // einem Konzeptname entsprechen muss - strOptions.put("returnType", new String[] {}); - strOptions.put("statMode", booleanArray); - strOptions.put("una", booleanArray); - strOptions.put("owa", booleanArray); - strOptions.put("algorithm", new String[] { "gp", "bruteForce", "random", "refinement", "hybridGP" }); - strOptions.put("reasoner", new String[] { "dig", "kaon2", "fastRetrieval" }); - strOptions.put("digReasonerURL", new String[] {}); - strOptions.put("useRetrievalForClassification", booleanArray); - strOptions.put("hidePrefix", new String[] {}); - strOptions.put("showIndividuals", booleanArray); - strOptions.put("showConcepts", booleanArray); - strOptions.put("showRoles", booleanArray); - strOptions.put("showInternalKB", booleanArray); - strOptions.put("showSubsumptionHierarchy", booleanArray); - strOptions.put("writeDIGProtocol", booleanArray); - strOptions.put("digProtocolFile", new String[] {}); - // strOptions.put("preprocessingModule", new String[] {}); - strOptions.put("gp.selectionType", new String[] { "rankSelection", "fps", "tournament" }); - strOptions.put("gp.elitism", booleanArray); - strOptions.put("gp.algorithmType", new String[] { "steadyState", "generational" }); - strOptions.put("gp.adc", booleanArray); - strOptions.put("gp.useFixedNumberOfGenerations", booleanArray); - strOptions.put("refinement.heuristic", new String[] { "lexicographic", "flexible" }); - strOptions.put("refinement.quiet", booleanArray); - strOptions.put("refinement.writeSearchTree", new String[] {}); - strOptions.put("refinement.searchTreeFile", new String[] {}); - strOptions.put("refinement.applyAllFilter", booleanArray); - strOptions.put("refinement.applyExistsFilter", booleanArray); - strOptions.put("refinement.useTooWeakList", booleanArray); - strOptions.put("refinement.useOverlyGeneralList", booleanArray); - strOptions.put("refinement.useShortConceptConstruction", booleanArray); - strOptions.put("refinement.useDIGMultiInstanceChecks", new String[] { "never", "twoChecks", "oneCheck"}); - strOptions.put("refinement.useAllConstructor", booleanArray); - strOptions.put("refinement.useExistsConstructor", booleanArray); - strOptions.put("refinement.useNegation", booleanArray); - } - - private void createSetOptions() { - setOptions.add("refinement.allowedConcepts"); - setOptions.add("refinement.allowedRoles"); - setOptions.add("refinement.ignoredConcepts"); - setOptions.add("refinement.ignoredRoles"); - } - - private void applyIntOptions(String option, int value) { - if (option.equals("maxLength")) - ;//Config.maxLength = value; -// else if (option.equals("gp.numberOfIndividuals")) -// Config.GP.numberOfIndividuals = value; -// else if (option.equals("gp.numberOfSelectedIndividuals")) -// Config.GP.numberOfSelectedIndividuals = value; -// else if (option.equals("gp.postConvergenceGenerations")) -// Config.GP.postConvergenceGenerations = value; -// else if (option.equals("gp.generations")) -// Config.GP.generations = value; -// else if (option.equals("gp.tournamentSize")) -// Config.GP.tournamentSize = value; -// else if (option.equals("gp.initMinDepth")) -// Config.GP.initMinDepth = value; -// else if (option.equals("gp.initMaxDepth")) -// Config.GP.initMaxDepth = value; - } - - private void applyDoubleOptions(String option, double value) { - // System.out.println(option + " " + value); - if (option.equals("accuracyPenalty")) - ; //Config.accuracyPenalty = value; - else if (option.equals("errorPenalty")) - ; //Config.errorPenalty = value; -// else if (option.equals("gp.crossoverPercent")) -// Config.GP.crossoverProbability = value / (double) 100; -// else if (option.equals("gp.mutationPercent")) -// Config.GP.mutationProbability = value / (double) 100; -// else if (option.equals("gp.hillClimbingPercent")) -// Config.GP.hillClimbingProbability = value / (double) 100; -// else if (option.equals("gp.refinementPercent")) -// Config.GP.refinementProbability = value / (double) 100; -// else if (option.equals("refinement.horizontalExpansionFactor")) -// Config.Refinement.horizontalExpansionFactor = value; - else if (option.equals("percentPerLengthUnit")) - ; // Config.percentPerLengthUnit = value; - } - - private void applyStringOptions(String option, String value) { - if (option.equals("penalizeNeutralExamples")) - ; // Config.penalizeNeutralExamples = Datastructures.strToBool(value); - else if (option.equals("showCorrectClassifications")) - ; // Config.showCorrectClassifications = Datastructures.strToBool(value); - else if (option.equals("statMode")) - ; // Config.statisticMode = Datastructures.strToBool(value); - else if (option.equals("una")) - ; // Config.una = Datastructures.strToBool(value); - else if (option.equals("owa")) - ; // Config.owa = Datastructures.strToBool(value); -// else if (option.equals("gp.useFixedNumberOfGenerations")) -// Config.GP.useFixedNumberOfGenerations = Datastructures.strToBool(value); -// else if (option.equals("scoreMethod")) { -// if (value.equals("full")) -// Config.scoreMethod = ScoreMethod.FULL; -// else -// Config.scoreMethod = ScoreMethod.POSITIVE; -// } else if (option.equals("returnType")) -// Config.returnType = value; -// else if (option.equals("algorithm")) { -// if (value.equals("gp")) -// Config.algorithm = Algorithm.GP; -// else if (value.equals("random")) -// Config.algorithm = Algorithm.RANDOM_GUESSER; -// else if(value.equals("bruteForce")) -// Config.algorithm = Algorithm.BRUTE_FORCE; -// else if(value.equals("refinement")) -// Config.algorithm = Algorithm.REFINEMENT; -// // hybrid GP = Menge von Konfigurationsoptionen -// else { -// Config.algorithm = Algorithm.HYBRID_GP; -// Config.GP.refinementProbability = 1.0d; -// Config.GP.crossoverProbability = 0.0d; -// Config.GP.hillClimbingProbability = 0.0d; -// Config.GP.mutationProbability = 0.0d; -// } - else if(option.equals("hidePrefix")) { -// Config.hidePrefixes.add(value); - } else if (option.equals("showIndividuals")) { -// Config.showIndividuals = Datastructures.strToBool(value); - } else if (option.equals("showConcepts")) { -// Config.showConcepts = Datastructures.strToBool(value); - } else if (option.equals("showRoles")) { -// Config.showRoles = Datastructures.strToBool(value); - } else if (option.equals("showInternalKB")) { -// Config.showInternalKB = Datastructures.strToBool(value); - } else if (option.equals("showSubsumptionHierarchy")) { -// Config.showSubsumptionHierarchy = Datastructures.strToBool(value); - } else if (option.equals("writeDIGProtocol")) { - // Config.writeDIGProtocol = Datastructures.strToBool(value); - } else if (option.equals("digProtocolFile")) { - // Config.digProtocolFile = new File(value); - // } else if (option.equals("preprocessingModule")) { -// // Config.preprocessingModule = value; -// } else if (option.equals("gp.selectionType")) { -// if (value.equals("fps")) -// Config.GP.selectionType = SelectionType.FPS; -// else if (value.equals("rankSelection")) -// Config.GP.selectionType = SelectionType.RANK_SELECTION; -// else -// Config.GP.selectionType = SelectionType.TOURNAMENT_SELECTION; -// } else if (option.equals("gp.algorithmType")) { -// if (value.equals("steadyState")) -// Config.GP.algorithmType = AlgorithmType.STEADY_STATE; -// else -// Config.GP.algorithmType = AlgorithmType.GENERATIONAL; -// } else if (option.equals("gp.adc")) { -//// Config.GP.adc = Datastructures.strToBool(value); - } else if (option.equals("refinement.heuristic")) { -// if(value.equals("lexicographic")) -// Config.Refinement.heuristic = Config.Refinement.Heuristic.LEXICOGRAPHIC; -// else -// Config.Refinement.heuristic = Config.Refinement.Heuristic.FLEXIBLE; - } else if (option.equals("refinement.quiet")) { -// Config.Refinement.quiet = Datastructures.strToBool(value); - } else if (option.equals("refinement.writeSearchTree")) - ; //Config.Refinement.writeSearchTree = Datastructures.strToBool(value); - else if (option.equals("refinement.searchTreeFile")) { - ; // Config.Refinement.searchTreeFile = new File(value); -// } else if (option.equals("refinement.applyAllFilter")) -// Config.Refinement.applyAllFilter = Datastructures.strToBool(value); - } else if (option.equals("refinement.applyExistsFilter")) { -// Config.Refinement.applyExistsFilter = Datastructures.strToBool(value); -// } else if (option.equals("refinement.useTooWeakList")) -// Config.Refinement.useTooWeakList = Datastructures.strToBool(value); -// else if (option.equals("refinement.useOverlyGeneralList")) -// Config.Refinement.useOverlyGeneralList = Datastructures.strToBool(value); -// else if (option.equals("refinement.useShortConceptConstruction")) -// Config.Refinement.useShortConceptConstruction = Datastructures.strToBool(value); -// } else if (option.equals("refinement.useAllConstructor")) -// Config.Refinement.useAllConstructor = Datastructures.strToBool(value); -// else if (option.equals("refinement.useExistsConstructor")) -// Config.Refinement.useExistsConstructor = Datastructures.strToBool(value); -// else if (option.equals("refinement.useNegation")) -// Config.Refinement.useNegation = Datastructures.strToBool(value); -// else if (option.equals("reasoner")) { -// if(value.equals("dig")) -// Config.reasonerType = ReasonerType.DIG; -// else if(value.equals("kaon2")) -// Config.reasonerType = ReasonerType.KAON2; -// else if(value.equals("fastRetrieval")) -// Config.reasonerType = ReasonerType.FAST_RETRIEVAL; -// else if (option.equals("digReasonerURL")) { -// try { -// Config.digReasonerURL = new URL(value); -// } catch (MalformedURLException e) { -// e.printStackTrace(); -// System.err.println("Malformed URL for DIG reasoner was given."); -// System.exit(0); -// } - } -// } else if (option.equals("useRetrievalForClassification")) -// Config.useRetrievalForClassification = Datastructures.strToBool(value); -// else if (option.equals("refinement.useDIGMultiInstanceChecks")) { -// if(value.equals("never")) -// Config.Refinement.useDIGMultiInstanceChecks = Config.Refinement.UseDIGMultiInstanceChecks.NEVER; -// else if(value.equals("twoChecks")) -// Config.Refinement.useDIGMultiInstanceChecks = Config.Refinement.UseDIGMultiInstanceChecks.TWOCHECKS; -// else if(value.equals("oneCheck")) -// Config.Refinement.useDIGMultiInstanceChecks = Config.Refinement.UseDIGMultiInstanceChecks.ONECHECK; -// } - } - - private void applySetOptions(String optionString, Set<String> setValues) { - // System.out.println(":" + optionString + " " + setValues); - - if(optionString.equals("refinement.allowedConcepts")) { -// Config.Refinement.allowedConceptsAutoDetect = false; - ; // Config.Refinement.allowedConcepts = new TreeSet<AtomicConcept>(new ConceptComparator()); -// for(String s : setValues) - // es wird die gleiche Funktion wie im Parser genommen um Namen auf URIs zu mappen -// Config.Refinement.allowedConcepts.add(new AtomicConcept(KBParser.getInternalURI(s))); - } else if(optionString.equals("refinement.allowedRoles")) { -// Config.Refinement.allowedRolesAutoDetect = false; -// Config.Refinement.allowedRoles = new TreeSet<AtomicRole>(new RoleComparator()); -// for(String s : setValues) -// Config.Refinement.allowedRoles.add(new AtomicRole(KBParser.getInternalURI(s))); - } else if(optionString.equals("refinement.ignoredConcepts")) { -// Config.Refinement.ignoredConcepts = new TreeSet<AtomicConcept>(new ConceptComparator()); -// for(String s : setValues) -// Config.Refinement.ignoredConcepts.add(new AtomicConcept(KBParser.getInternalURI(s))); - } else if(optionString.equals("refinement.ignoredRoles")) { -// Config.Refinement.ignoredRoles = new TreeSet<AtomicRole>(new RoleComparator()); -// for(String s : setValues) -// Config.Refinement.ignoredRoles.add(new AtomicRole(KBParser.getInternalURI(s))); - } - } - - public void addDoubleOption(String option, Double[] range) { - doubleOptions.put(option, range); - } - - public Integer[] addIntegerOption(String option, Integer[] value) { - return intOptions.put(option, value); - } - - public boolean addSetOption(String option) { - return setOptions.add(option); - } - - public String[] addStringOption(String option, String[] value) { - return strOptions.put(option, value); - } - -} - Modified: trunk/src/dl-learner/org/dllearner/utilities/PaperStatistics.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/PaperStatistics.java 2007-11-12 15:13:50 UTC (rev 282) +++ trunk/src/dl-learner/org/dllearner/utilities/PaperStatistics.java 2007-11-12 15:19:23 UTC (rev 283) @@ -27,7 +27,6 @@ import java.util.Map; import java.util.SortedSet; -import org.dllearner.ConfigurationManager; import org.dllearner.algorithms.gp.GP; import org.dllearner.core.ComponentManager; import org.dllearner.core.KnowledgeSource; @@ -145,8 +144,8 @@ ComponentManager cm = ComponentManager.getInstance(); // just set default options - ConfigurationManager confMgr = new ConfigurationManager(); - confMgr.applyOptions(); +// ConfigurationManager confMgr = new ConfigurationManager(); +// confMgr.applyOptions(); for(int exampleNr=startExampleNr; exampleNr < examples.length; exampleNr++) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2007-11-23 12:09:20
|
Revision: 287 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=287&view=rev Author: tonytacker Date: 2007-11-23 04:09:14 -0800 (Fri, 23 Nov 2007) Log Message: ----------- It is a first version and does'nt work yet. Added Paths: ----------- trunk/src/dl-learner/org/dllearner/gui/ trunk/src/dl-learner/org/dllearner/gui/StartGUI_v4.java Added: trunk/src/dl-learner/org/dllearner/gui/StartGUI_v4.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/StartGUI_v4.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/gui/StartGUI_v4.java 2007-11-23 12:09:14 UTC (rev 287) @@ -0,0 +1,214 @@ +package org.dllearner.gui; + +//File : gui/containers/dialogs/filechooser/CountWords.java +//Purpose: Counts words in file. +// Illustrates menus, JFileChooser, Scanner.. +//Author : Fred Swartz - 2006-10-10 - Placed in public domain. + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; + +//import org.dllearner.algorithms.RandomGuesser; +//import org.dllearner.core.Component; +import org.dllearner.core.ComponentManager; +import org.dllearner.core.KnowledgeSource; +//import org.dllearner.core.LearningAlgorithm; +//import org.dllearner.core.LearningProblem; +//import org.dllearner.core.ReasonerComponent; +//import org.dllearner.core.ReasoningService; +import org.dllearner.kb.OWLFile; +//import org.dllearner.learningproblems.PosNegDefinitionLP; +//import org.dllearner.reasoning.DIGReasoner; + +import java.io.*; +import java.util.*; + +////////////////////////////////////////////////////////CountWords +public class StartGUI_v4 extends JFrame { + + + /** + * + */ + private static final long serialVersionUID = 9151367563590748364L; + +//====================================================== fields + JTextField _fileNameTF = new JTextField(15); + JTextField _wordCountTF = new JTextField(4); + JFileChooser _fileChooser = new JFileChooser(); + JTextArea _textField = new JTextArea(); + ComponentManager cm = ComponentManager.getInstance(); // create singleton instance + + //================================================= constructor + StartGUI_v4() { + //... Create / set component characteristics. + _fileNameTF.setEditable(false); + _wordCountTF.setEditable(false); + + //... Add listeners <-- extra classes + + //... Create content pane, layout components + JPanel content = new JPanel(); + content.setLayout(new FlowLayout()); + content.add(new JLabel("File:")); // name of opend file + content.add(_fileNameTF); + content.add(new JLabel("Word Count:")); // test + content.add(_wordCountTF); // test + content.add(_textField); // test_output + + //... Create menu elements (menubar, menu, menu item) + JMenuBar menubar = new JMenuBar(); + JMenu fileMenu = new JMenu("File"); + JMenuItem openItem = new JMenuItem("Open"); + openItem.addActionListener(new OpenAction()); + JMenuItem saveItem = new JMenuItem("Save"); + saveItem.addActionListener(new SaveAction()); + JMenuItem exitItem = new JMenuItem("Exit"); + exitItem.addActionListener(new ExitAction()); + + + //... Assemble the menu + menubar.add(fileMenu); + fileMenu.add(openItem); + //fileMenu.add(saveItem); + fileMenu.add(exitItem); + + //... _textField (TextArea) into a JScrollPane + JScrollPane scrollPane = new JScrollPane(_textField); + scrollPane.setPreferredSize(new Dimension(320, 240)); + + //... Set window characteristics + this.setJMenuBar(menubar); + this.setContentPane(content); + this.setTitle("DL-Learner"); + this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + this.add(scrollPane); + this.pack(); // Layout components. + this.setLocationRelativeTo(null); // Center window. + + // RUN + + + //System.out.println("components"); + //System.out.println(cm.getComponents()); // show components + //System.out.println("knowledgeSources"); + //System.out.println(cm.getKnowledgeSources()); // possible sources + + + +/* + // create DIG reasoning service with standard settings + ReasonerComponent reasoner = cm.reasoner(DIGReasoner.class, source); + // ReasoningService rs = cm.reasoningService(DIGReasonerNew.class, source); + reasoner.init(); + ReasoningService rs = cm.reasoningService(reasoner); + + // create a learning problem and set positive and negative examples + LearningProblem lp = cm.learningProblem(PosNegDefinitionLP.class, rs); + Set<String> positiveExamples = new TreeSet<String>(); + positiveExamples.add("http://example.com/father#stefan"); + positiveExamples.add("http://example.com/father#markus"); + positiveExamples.add("http://example.com/father#martin"); + Set<String> negativeExamples = new TreeSet<String>(); + negativeExamples.add("http://example.com/father#heinz"); + negativeExamples.add("http://example.com/father#anna"); + negativeExamples.add("http://example.com/father#michelle"); + cm.applyConfigEntry(lp, "positiveExamples", positiveExamples); + cm.applyConfigEntry(lp, "negativeExamples", negativeExamples); + lp.init(); + + // create the learning algorithm + LearningAlgorithm la = cm.learningAlgorithm(RandomGuesser.class, lp, rs); + cm.applyConfigEntry(la, "numberOfTrees", 100); + cm.applyConfigEntry(la, "maxDepth", 5); + la.init(); + + // start the algorithm and print the best concept found + //la.start(); + //System.out.println(la.getBestSolution()); +*/ + + } + + // a test method + //============================================= countWordsInFile + private int countWordsInFile(File f) { + + int numberOfWords = 0; // Count of words. + + try { + Scanner in = new Scanner(f); + + while (in.hasNext()) { + String word = in.next(); // Read a "token". + numberOfWords++; + } + in.close(); // Close Scanner's file. + + } catch (FileNotFoundException fnfex) { + // ... We just got the file from the JFileChooser, + // so it's hard to believe there's problem, but... + JOptionPane.showMessageDialog(StartGUI_v4.this, + fnfex.getMessage()); + } + return numberOfWords; + } + + + ///////////////////////////////////////////////////// OpenAction + class OpenAction implements ActionListener { + public void actionPerformed(ActionEvent ae) { + //... Open a file dialog. + int retval = _fileChooser.showOpenDialog(StartGUI_v4.this); + if (retval == JFileChooser.APPROVE_OPTION) { + //... The user selected a file, get it, use it. + File file = _fileChooser.getSelectedFile(); + + //... Update user interface. + _fileNameTF.setText(file.getName()); + _wordCountTF.setText("" + countWordsInFile(file)); + //show file in _textField + try { + _textField.read(new FileReader(file), ""); + } catch (Exception e) { + e.printStackTrace(); + } + // create knowledge source + KnowledgeSource source = cm.knowledgeSource(OWLFile.class); + //String example = "examples/father.owl"; + cm.applyConfigEntry(source, "url", file.toURI().toString()); + source.init(); + } + } + } + + ///////////////////////////////////////////////////// OpenAction + class SaveAction implements ActionListener { + public void actionPerformed(ActionEvent ae) { + //... Open a file dialog. + int retval = _fileChooser.showOpenDialog(StartGUI_v4.this); + if (retval == JFileChooser.APPROVE_OPTION) { + //... The user selected a file, get it, use it. + File file = _fileChooser.getSelectedFile(); + + //... Update user interface. + _fileNameTF.setText(file.getName()); + _wordCountTF.setText("" + countWordsInFile(file)); + } + } + } + + ///////////////////////////////////////////////////// ExitAction + class ExitAction implements ActionListener { + public void actionPerformed(ActionEvent ae) { + System.exit(0); + } + } + + //========================================================= main + public static void main(String[] args) { + JFrame window = new StartGUI_v4(); + window.setVisible(true); + } +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2007-11-25 11:37:57
|
Revision: 289 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=289&view=rev Author: jenslehmann Date: 2007-11-25 03:37:52 -0800 (Sun, 25 Nov 2007) Log Message: ----------- small example for Tilo Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/core/ComponentManager.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/gui/ComponentRetrievalTest.java Modified: trunk/src/dl-learner/org/dllearner/core/ComponentManager.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ComponentManager.java 2007-11-24 09:04:49 UTC (rev 288) +++ trunk/src/dl-learner/org/dllearner/core/ComponentManager.java 2007-11-25 11:37:52 UTC (rev 289) @@ -64,11 +64,11 @@ // these variables are valid for the complete lifetime of DL-Learner private static String componentsFile = "lib/components.ini"; private static ComponentManager cm = new ComponentManager(); - private static Set<Class<? extends Component>> components; - private static Set<Class<? extends KnowledgeSource>> knowledgeSources; - private static Set<Class<? extends ReasonerComponent>> reasonerComponents; - private static Set<Class<? extends LearningProblem>> learningProblems; - private static Set<Class<? extends LearningAlgorithm>> learningAlgorithms; + private static Collection<Class<? extends Component>> components; + private static Collection<Class<? extends KnowledgeSource>> knowledgeSources; + private static Collection<Class<? extends ReasonerComponent>> reasonerComponents; + private static Collection<Class<? extends LearningProblem>> learningProblems; + private static Collection<Class<? extends LearningAlgorithm>> learningAlgorithms; // list of all configuration options of all components private static Map<Class<? extends Component>, String> componentNames; @@ -486,38 +486,36 @@ /** * @return the components */ - public static Set<Class<? extends Component>> getComponents() { - return components; + public List<Class<? extends Component>> getComponents() { + return new LinkedList<Class<? extends Component>>(components); } /** * @return the knowledgeSources */ - public static Set<Class<? extends KnowledgeSource>> getKnowledgeSources() { - return knowledgeSources; + public List<Class<? extends KnowledgeSource>> getKnowledgeSources() { + return new LinkedList<Class<? extends KnowledgeSource>>(knowledgeSources); } /** * @return the reasonerComponents */ - public static Set<Class<? extends ReasonerComponent>> getReasonerComponents() { - return reasonerComponents; + public List<Class<? extends ReasonerComponent>> getReasonerComponents() { + return new LinkedList<Class<? extends ReasonerComponent>>(reasonerComponents); } /** * @return the learningProblems */ - public static Set<Class<? extends LearningProblem>> getLearningProblems() { - return learningProblems; + public List<Class<? extends LearningProblem>> getLearningProblems() { + return new LinkedList<Class<? extends LearningProblem>>(learningProblems); } /** * @return the learningAlgorithms */ - public static Set<Class<? extends LearningAlgorithm>> getLearningAlgorithms() { - return learningAlgorithms; + public List<Class<? extends LearningAlgorithm>> getLearningAlgorithms() { + return new LinkedList<Class<? extends LearningAlgorithm>>(learningAlgorithms); } - - } Added: trunk/src/dl-learner/org/dllearner/gui/ComponentRetrievalTest.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ComponentRetrievalTest.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/gui/ComponentRetrievalTest.java 2007-11-25 11:37:52 UTC (rev 289) @@ -0,0 +1,42 @@ +/** + * Copyright (C) 2007, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package org.dllearner.gui; + +import java.util.List; + +import org.dllearner.core.ComponentManager; +import org.dllearner.core.KnowledgeSource; + +/** + * @author Jens Lehmann + * + */ +public class ComponentRetrievalTest { + + /** + * @param args + */ + public static void main(String[] args) { + ComponentManager cm = ComponentManager.getInstance(); + List<Class<? extends KnowledgeSource>> sources = cm.getKnowledgeSources(); + cm.knowledgeSource(sources.get(0)); + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2007-12-02 17:40:57
|
Revision: 307 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=307&view=rev Author: jenslehmann Date: 2007-12-02 09:40:55 -0800 (Sun, 02 Dec 2007) Log Message: ----------- adapted DL-Learner to latest KAON2 release Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/kb/KBFile.java trunk/src/dl-learner/org/dllearner/reasoning/KAON2Reasoner.java Modified: trunk/src/dl-learner/org/dllearner/kb/KBFile.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/KBFile.java 2007-12-02 17:06:39 UTC (rev 306) +++ trunk/src/dl-learner/org/dllearner/kb/KBFile.java 2007-12-02 17:40:55 UTC (rev 307) @@ -120,7 +120,7 @@ public void export(File file, org.dllearner.core.OntologyFormat format){ Reasoner kaon2Reasoner = KAON2Reasoner.getKAON2Reasoner(kb); - String kaon2Format = ""; + OntologyFileFormat kaon2Format = null; if(format.equals(org.dllearner.core.OntologyFormat.RDF_XML)) kaon2Format = OntologyFileFormat.OWL_RDF; else { Modified: trunk/src/dl-learner/org/dllearner/reasoning/KAON2Reasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/KAON2Reasoner.java 2007-12-02 17:06:39 UTC (rev 306) +++ trunk/src/dl-learner/org/dllearner/reasoning/KAON2Reasoner.java 2007-12-02 17:40:55 UTC (rev 307) @@ -96,12 +96,7 @@ if(imports.size()>1) System.out.println("Warning: KAON2-Reasoner currently supports only one import file. Ignoring all other imports."); - try { - kaon2Connection = KAON2Manager.newConnection(); - } catch (KAON2Exception e2) { - // TODO Auto-generated catch block - e2.printStackTrace(); - } + kaon2Connection = KAON2Manager.newConnection(); DefaultOntologyResolver resolver = new DefaultOntologyResolver(); @@ -475,7 +470,7 @@ public void saveOntology(File file, org.dllearner.core.OntologyFormat format) { // File exportFile = new File(baseDir, fileName); // String format = OntologyFileFormat.OWL_RDF; - String kaon2Format = ""; + OntologyFileFormat kaon2Format = null; if(format.equals(org.dllearner.core.OntologyFormat.RDF_XML)) kaon2Format = OntologyFileFormat.OWL_RDF; else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2007-12-03 15:57:46
|
Revision: 313 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=313&view=rev Author: jenslehmann Date: 2007-12-03 07:57:42 -0800 (Mon, 03 Dec 2007) Log Message: ----------- fixed KAON2 errors Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/kb/KBFile.java trunk/src/dl-learner/org/dllearner/reasoning/KAON2Reasoner.java Modified: trunk/src/dl-learner/org/dllearner/kb/KBFile.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/KBFile.java 2007-12-03 15:04:54 UTC (rev 312) +++ trunk/src/dl-learner/org/dllearner/kb/KBFile.java 2007-12-03 15:57:42 UTC (rev 313) @@ -120,7 +120,7 @@ public void export(File file, org.dllearner.core.OntologyFormat format){ Reasoner kaon2Reasoner = KAON2Reasoner.getKAON2Reasoner(kb); - OntologyFileFormat kaon2Format = null; + String kaon2Format = null; if(format.equals(org.dllearner.core.OntologyFormat.RDF_XML)) kaon2Format = OntologyFileFormat.OWL_RDF; else { Modified: trunk/src/dl-learner/org/dllearner/reasoning/KAON2Reasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/KAON2Reasoner.java 2007-12-03 15:04:54 UTC (rev 312) +++ trunk/src/dl-learner/org/dllearner/reasoning/KAON2Reasoner.java 2007-12-03 15:57:42 UTC (rev 313) @@ -96,7 +96,11 @@ if(imports.size()>1) System.out.println("Warning: KAON2-Reasoner currently supports only one import file. Ignoring all other imports."); - kaon2Connection = KAON2Manager.newConnection(); + try { + kaon2Connection = KAON2Manager.newConnection(); + } catch (KAON2Exception e2) { + e2.printStackTrace(); + } DefaultOntologyResolver resolver = new DefaultOntologyResolver(); @@ -470,7 +474,7 @@ public void saveOntology(File file, org.dllearner.core.OntologyFormat format) { // File exportFile = new File(baseDir, fileName); // String format = OntologyFileFormat.OWL_RDF; - OntologyFileFormat kaon2Format = null; + String kaon2Format = null; if(format.equals(org.dllearner.core.OntologyFormat.RDF_XML)) kaon2Format = OntologyFileFormat.OWL_RDF; else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |