From: <ku...@us...> - 2008-08-30 14:31:29
|
Revision: 1153 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1153&view=rev Author: kurzum Date: 2008-08-30 14:31:26 +0000 (Sat, 30 Aug 2008) Log Message: ----------- Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java trunk/src/dl-learner/org/dllearner/scripts/DumbLPFinder.java trunk/src/dl-learner/org/dllearner/scripts/WikipediaCategoryCleaner.java trunk/src/dl-learner/org/dllearner/utilities/learn/LearnSPARQLConfiguration.java trunk/src/dl-learner/org/dllearner/utilities/learn/LearnSparql.java Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java 2008-08-30 13:52:08 UTC (rev 1152) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java 2008-08-30 14:31:26 UTC (rev 1153) @@ -80,7 +80,7 @@ static int recursionDepthDefault = 1; //RBC - static final boolean debug = true; + static final boolean debug = false; static final boolean debugUseImprovedTupleAquisitor = debug && false; //switches tupleaquisitor static final boolean debugExitAfterExtraction = debug && false; //switches sysex und rdf generation static final boolean debugAdditionallyGenerateRDF = debug && true; Modified: trunk/src/dl-learner/org/dllearner/scripts/DumbLPFinder.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/DumbLPFinder.java 2008-08-30 13:52:08 UTC (rev 1152) +++ trunk/src/dl-learner/org/dllearner/scripts/DumbLPFinder.java 2008-08-30 14:31:26 UTC (rev 1153) @@ -23,6 +23,7 @@ import java.util.SortedSet; import java.util.TreeSet; +import org.apache.log4j.ConsoleAppender; import org.apache.log4j.FileAppender; import org.apache.log4j.Level; import org.apache.log4j.Logger; @@ -33,11 +34,14 @@ import org.dllearner.core.ReasoningService; import org.dllearner.core.owl.Individual; import org.dllearner.reasoning.FastInstanceChecker; +import org.dllearner.reasoning.OWLAPIReasoner; import org.dllearner.utilities.Files; import org.dllearner.utilities.datastructures.SetManipulation; import org.dllearner.utilities.learn.ConfWriter; import org.dllearner.utilities.learn.LearnOWLFile; import org.dllearner.utilities.learn.LearnOWLFileConfiguration; +import org.dllearner.utilities.learn.LearnSPARQLConfiguration; +import org.dllearner.utilities.learn.LearnSparql; import org.dllearner.utilities.owl.ReasoningServiceFactory; import org.dllearner.utilities.owl.ReasoningServiceFactory.AvailableReasoners; @@ -49,10 +53,14 @@ public static String ontologyPath = "examples/semantic_bible/NTNcombined.owl"; - private static Class usedReasoner = FastInstanceChecker.class; - //private static Class usedReasoner = OWLAPIReasoner.class; + //private static Class usedReasoner = FastInstanceChecker.class; + private static Class usedReasoner = OWLAPIReasoner.class; private static boolean allOrExists = false; private static boolean tenORthirty = false; + + private static boolean sparql = true; + + private static boolean DEBUG = false; //private static boolean allOrExists = true; /** @@ -60,6 +68,7 @@ */ public static void main(String[] args) { initLogger(); + logger.info("started"); //String fileURL = new File(ontologyFile).toURI().toString(); reasoningService = ReasoningServiceFactory.getReasoningService( @@ -124,8 +133,12 @@ } - - EvaluatedDescription d = learnOriginal( positiveEx, negativeEx); + EvaluatedDescription d; + if(sparql){ + d = learnSPARQL( positiveEx, negativeEx); + }else { + d = learnOriginal( positiveEx, negativeEx); + } @@ -133,12 +146,12 @@ filename+=(d.getDescriptionLength()<10)?"0"+d.getDescriptionLength():d.getDescriptionLength()+""; if(d.getAccuracy()>=0.99){ filename +="_99+"; - }else if(d.getAccuracy()>=0.75){ - filename +="_75+"; - }else if(d.getAccuracy()>=0.50){ - filename +="_50+"; + }else if(d.getAccuracy()>=0.80){ + filename +="_80+"; + }else if(d.getAccuracy()>=0.60){ + filename +="_60+"; }else { - filename +="_50-"; + filename +="_60-"; } filename += "_"+div+".conf"; @@ -220,6 +233,28 @@ } + + private static EvaluatedDescription learnSPARQL( SortedSet<Individual> posExamples, SortedSet<Individual> negExamples) { + + LearnSparql learner = new LearnSparql(getConfForSparql()); + LearningAlgorithm la = null; + try{ + la = learner.learn( + SetManipulation.indToString(posExamples), + SetManipulation.indToString(negExamples), + usedReasoner); + la.start(); + }catch (Exception e) { + System.out.println("ignoring the error "+e.toString()); + + } + + EvaluatedDescription d = la.getCurrentlyBestEvaluatedDescription(); + + return d; + + + } @@ -254,7 +289,41 @@ } + private static LearnSPARQLConfiguration getConfForSparql() { + LearnSPARQLConfiguration lc = new LearnSPARQLConfiguration(); + // lsc.sparqlEndpoint = sparqlTasks.getSparqlEndpoint(); + + + lc.recursiondepth = 2; + lc.closeAfterRecursion = true; + lc.useLits = true; + lc.predefinedEndpoint = "LOCALJOSEKIBIBLE"; + + lc.noisePercentage = 0; + lc.guaranteeXgoodDescriptions = 1; + lc.maxExecutionTimeInSeconds = 30; + + + + if(allOrExists){ + lc.useAllConstructor = true; + lc.useCardinalityRestrictions = true; + lc.useExistsConstructor =true; + lc.useNegation = true; + }else { + lc.useAllConstructor = false; + lc.useCardinalityRestrictions = false; + lc.useExistsConstructor =true; + lc.useNegation = false; + } + + // lsc.searchTreeFile = "log/WikipediaCleaner.txt"; + + return lc; + + } + private static void initLogger() { SimpleLayout layout = new SimpleLayout(); @@ -270,11 +339,16 @@ logger.removeAllAppenders(); - //ConsoleAppender consoleAppender = new ConsoleAppender(layout); - //logger.addAppender(consoleAppender); + if(DEBUG){ + logger.setLevel(Level.DEBUG); + ConsoleAppender consoleAppender = new ConsoleAppender(layout); + logger.addAppender(consoleAppender); + }else{ + logger.setLevel(Level.INFO); + } logger.addAppender(fileAppender); - logger.setLevel(Level.INFO); + } Modified: trunk/src/dl-learner/org/dllearner/scripts/WikipediaCategoryCleaner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/WikipediaCategoryCleaner.java 2008-08-30 13:52:08 UTC (rev 1152) +++ trunk/src/dl-learner/org/dllearner/scripts/WikipediaCategoryCleaner.java 2008-08-30 14:31:26 UTC (rev 1153) @@ -43,6 +43,7 @@ import org.dllearner.kb.sparql.SparqlEndpoint; import org.dllearner.kb.sparql.SparqlKnowledgeSource; import org.dllearner.kb.sparql.SparqlQuery; +import org.dllearner.reasoning.FastInstanceChecker; import org.dllearner.scripts.improveWikipedia.ConceptSPARQLReEvaluator; import org.dllearner.scripts.improveWikipedia.ConceptSelector; import org.dllearner.scripts.improveWikipedia.WikipediaCategoryTasks; @@ -208,7 +209,7 @@ LearnSparql learner = new LearnSparql(getConfToRelearn()); LearningAlgorithm la = null; try { - la = learner.learn(posExamples, negExamples); + la = learner.learn(posExamples, negExamples, FastInstanceChecker.class); } catch (Exception e) { e.printStackTrace(); } @@ -221,6 +222,7 @@ private static LearnSPARQLConfiguration getConfToFindWrongIndividuals() { LearnSPARQLConfiguration lsc = new LearnSPARQLConfiguration(); lsc.sparqlEndpoint = sparqlTasks.getSparqlEndpoint(); + lsc.predefinedEndpoint = "DBPEDIA"; lsc.recursiondepth = 1; lsc.noisePercentage = 20; Modified: trunk/src/dl-learner/org/dllearner/utilities/learn/LearnSPARQLConfiguration.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/learn/LearnSPARQLConfiguration.java 2008-08-30 13:52:08 UTC (rev 1152) +++ trunk/src/dl-learner/org/dllearner/utilities/learn/LearnSPARQLConfiguration.java 2008-08-30 14:31:26 UTC (rev 1153) @@ -14,10 +14,12 @@ // SparqlKnowledgeSource public SparqlEndpoint sparqlEndpoint = SparqlEndpoint.getEndpointDBpedia(); + public String predefinedEndpoint = null; public int recursiondepth = 1; public boolean closeAfterRecursion = true; + public boolean useLits = false; public boolean randomizeCache = false; - public String predefinedFilter = "YAGO"; + public String predefinedFilter = null; @Override @@ -25,11 +27,21 @@ try { super.applyConfigEntries(cm, ks, lp, rs, la); // KNOWLEDGESOURCE - cm.applyConfigEntry(ks, "url", sparqlEndpoint.getURL().toString()); - cm.applyConfigEntry(ks, "predefinedEndpoint", "DBPEDIA"); + if(predefinedEndpoint ==null){ + cm.applyConfigEntry(ks, "url", sparqlEndpoint.getURL().toString()); + }else { + cm.applyConfigEntry(ks, "predefinedEndpoint", predefinedEndpoint); + } + if(predefinedFilter==null){ + //todo manual + }else{ + cm.applyConfigEntry(ks, "predefinedFilter", predefinedFilter); + } + + cm.applyConfigEntry(ks, "useLits", useLits); cm.applyConfigEntry(ks, "recursionDepth", recursiondepth); cm.applyConfigEntry(ks, "closeAfterRecursion", closeAfterRecursion); - cm.applyConfigEntry(ks, "predefinedFilter", predefinedFilter); + if (randomizeCache) cm.applyConfigEntry(ks, "cacheDir", "cache/" + System.currentTimeMillis() + ""); Modified: trunk/src/dl-learner/org/dllearner/utilities/learn/LearnSparql.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/learn/LearnSparql.java 2008-08-30 13:52:08 UTC (rev 1152) +++ trunk/src/dl-learner/org/dllearner/utilities/learn/LearnSparql.java 2008-08-30 14:31:26 UTC (rev 1153) @@ -53,7 +53,7 @@ //return will be replaced by List Description public LearningAlgorithm learn( SortedSet<String> posExamples, - SortedSet<String> negExamples) throws ComponentInitException, + SortedSet<String> negExamples, Class<? extends ReasonerComponent> Reasoner) throws ComponentInitException, LearningProblemUnsupportedException { logger.info("Start Learning with"); @@ -72,7 +72,7 @@ cm.applyConfigEntry(ks, "instances", instances); // reasoner - ReasonerComponent r = cm.reasoner(FastInstanceChecker.class, ks); + ReasonerComponent r = cm.reasoner(Reasoner, ks); ReasoningService rs = cm.reasoningService(r); // learning problem This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |