From: <ku...@us...> - 2008-08-30 13:52:13
|
Revision: 1152 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1152&view=rev Author: kurzum Date: 2008-08-30 13:52:08 +0000 (Sat, 30 Aug 2008) Log Message: ----------- Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/scripts/DumbLPFinder.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java Modified: trunk/src/dl-learner/org/dllearner/scripts/DumbLPFinder.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/DumbLPFinder.java 2008-08-30 01:29:38 UTC (rev 1151) +++ trunk/src/dl-learner/org/dllearner/scripts/DumbLPFinder.java 2008-08-30 13:52:08 UTC (rev 1152) @@ -51,8 +51,8 @@ private static Class usedReasoner = FastInstanceChecker.class; //private static Class usedReasoner = OWLAPIReasoner.class; - private static boolean allOrExists = true; - private static boolean tenORthirty = true; + private static boolean allOrExists = false; + private static boolean tenORthirty = false; //private static boolean allOrExists = true; /** Added: trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java 2008-08-30 13:52:08 UTC (rev 1152) @@ -0,0 +1,181 @@ +/** + * Copyright (C) 2007-2008, 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.scripts; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +import org.apache.log4j.ConsoleAppender; +import org.apache.log4j.FileAppender; +import org.apache.log4j.Level; +import org.apache.log4j.Logger; +import org.apache.log4j.SimpleLayout; +import org.dllearner.algorithms.refexamples.ExampleBasedROLComponent; +import org.dllearner.cli.Start; +import org.dllearner.core.KnowledgeSource; +import org.dllearner.core.ReasoningService; +import org.dllearner.kb.extraction.ExtractionAlgorithm; +import org.dllearner.kb.extraction.Manager; +import org.dllearner.kb.sparql.Cache; +import org.dllearner.kb.sparql.SparqlKnowledgeSource; +import org.dllearner.kb.sparql.SparqlQuery; +import org.dllearner.reasoning.FastInstanceChecker; +import org.dllearner.utilities.Files; +import org.dllearner.utilities.examples.AutomaticNegativeExampleFinderSPARQL; +import org.dllearner.utilities.examples.AutomaticPositiveExampleFinderOWL; +import org.dllearner.utilities.examples.AutomaticPositiveExampleFinderSPARQL; +import org.dllearner.utilities.owl.ReasoningServiceFactory; +import org.dllearner.utilities.owl.ReasoningServiceFactory.AvailableReasoners; +import org.dllearner.utilities.statistics.SimpleClock; + +public class SemanticBible2 { + + private static ReasoningService reasoningService; + + private static Logger logger = Logger.getRootLogger(); + + + public static String ontologyPath = "examples/semantic_bible/NTNcombined.owl"; + public static String dir = "sembib/"; + public static String sparqldir = dir+"sparql/"; + public static String normaldir = dir+"normal/"; + + public static String tmpFilename = dir + "tmp.conf"; + + private static Class usedReasoner = FastInstanceChecker.class; + + private static boolean useSPARQL = false; + + /** + * @param args + */ + public static void main(String[] args) { + SimpleClock sc = new SimpleClock(); + initLogger(); + logger.info("Start"); + File tmpFile = new File(tmpFilename); + + List<File> confs = getFilesContaining(useSPARQL,"thirty","exists", "75+"); + + //reasoningService = ReasoningServiceFactory.getReasoningService(ontologyPath, AvailableReasoners.OWLAPIREASONERPELLET); + try{ + for (File file : confs) { + System.out.println(file.getAbsolutePath()); + StringBuffer sbuf = new StringBuffer(Files.readFile( file)); + sbuf.insert(0, (useSPARQL)?sparqlOptions():normalOptions()); + Files.createFile(tmpFile, sbuf.toString()); + //System.out.println(tmpFile.getCanonicalPath()); + + Start.main(new String[] { tmpFilename }); + Cache.getDefaultCache().clearCache(); + System.exit(0); + } + }catch (Exception e) { + e.printStackTrace(); + } + logger.info("finished"); + } + + public static List<File> getFilesContaining(boolean sparql, String numExamples, String allOrEx, String acc) { + List<File> ret = new ArrayList<File>(); + try{ + String actualDir = (sparql)?sparqldir:normaldir; + File f = new File(actualDir); + String[] files = f.list(); + for (int i = 0; i < files.length; i++) { + if( + files[i].contains(numExamples) + && files[i].contains(allOrEx) + && files[i].contains(acc) + ){ + ret.add(new File(actualDir+files[i])); + } + + } + }catch (Exception e) { + logger.warn("deleting cache failed"); + e.printStackTrace(); + } + return ret; + } + + + public static String sparqlOptions (){ + String s="// SPARQL options\n"+ + "sparql.recursionDepth = 3;\n"+ + "sparql.useLits = true;\n"+ + "sparql.predefinedEndpoint = \"LOCALJOSEKIBIBLE\";\n"+ + "import(\"lalala\",\"SPARQL\");\n"+ + + "algorithm = refexamples;\n"+ + "refexamples.useAllConstructor = true;\n"+ + "refexamples.useNegation = true;\n"+ + "refexamples.useCardinalityRestrictions = true;\n"+ + "refexamples.guaranteeXgoodDescriptions = 1;\n"+ + "\n"+ + //"reasoner = owlAPI;\n"+ + "reasoner = fastInstanceChecker;\n"+ + //"owlAPIReasoner.reasonerType = pellet;\n\n"; + ""; + return s; + } + + public static String normalOptions (){ + String s="\n"+ + "import(\"NTNcombined.owl\");\n"+ + "algorithm = refexamples;\n"+ + "refexamples.useAllConstructor = true;\n"+ + "refexamples.useNegation = true;\n"+ + "refexamples.useCardinalityRestrictions = true;\n"+ + "refexamples.guaranteeXgoodDescriptions = 1;\n"+ + "\n"+ + "reasoner = owlAPI;\n"+ + //"reasoner = fastInstanceChecker;\n"+ + //"owlAPIReasoner.reasonerType = pellet;\n\n"; + ""; + return s; + } + + + private static void initLogger() { + + SimpleLayout layout = new SimpleLayout(); + // create logger (a simple logger which outputs + // its messages to the console) + FileAppender fileAppender = null; + try { + fileAppender = new FileAppender(layout, "log/semBibleLog.txt", + false); + } catch (Exception e) { + e.printStackTrace(); + } + + ConsoleAppender consoleAppender = new ConsoleAppender(layout); + logger.removeAllAppenders(); + logger.addAppender(consoleAppender); + logger.addAppender(fileAppender); + logger.setLevel(Level.DEBUG); + + + } + + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |