From: <ku...@us...> - 2008-09-02 21:09:13
|
Revision: 1168 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1168&view=rev Author: kurzum Date: 2008-09-02 21:08:59 +0000 (Tue, 02 Sep 2008) Log Message: ----------- latest changes Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/scripts/RDF2NT.java trunk/src/dl-learner/org/dllearner/utilities/examples/ExampleContainer.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-09-01 10:50:00 UTC (rev 1167) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-09-02 21:08:59 UTC (rev 1168) @@ -399,9 +399,7 @@ // we record when a more accurate node is found and log it if (bestNodeStable.getCovPosMinusCovNeg() < candidatesStable.last() .getCovPosMinusCovNeg()) { - String acc = (candidatesStable.last().getAccuracy(nrOfPositiveExamples, nrOfNegativeExamples))+""; - try { acc = acc.substring(2,6); - acc= acc.substring(0,2)+"."+acc.substring(3)+"%";}catch (Exception e) { } + String acc = new DecimalFormat( ".00%" ).format((candidatesStable.last().getAccuracy(nrOfPositiveExamples, nrOfNegativeExamples))); // no handling needed, it will just look ugly in the output logger.info("more accurate ("+acc+") node found: " + candidatesStable.last()); bestNodeStable = candidatesStable.last(); Added: trunk/src/dl-learner/org/dllearner/scripts/RDF2NT.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/RDF2NT.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/scripts/RDF2NT.java 2008-09-02 21:08:59 UTC (rev 1168) @@ -0,0 +1,84 @@ +/** + * 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.io.PrintStream; +public class RDF2NT { + + + public static void main(String[] args) { + + //String ontopath=args[0]; + String ontopath = "examples/semantic_bible/NTNcombined.owl"; + convertRDF2NT(ontopath); + + + } + + + /** + * converts .nt file to rdf, same file name, different ending + * @param ontopath path to nt file + */ + public static void convertRDF2NT(String inputOntopath){ + + try { + //URI inputURI = new File(inputOntopath).toURI(); + String outputOntopath=""; +// outputURI + String ending = inputOntopath.substring(inputOntopath.lastIndexOf(".") + 1); + outputOntopath = inputOntopath.replace("." + ending, ".nt" ); + //URI outputURI = new File(ontopath).toURI(); + /* + java jena.rdfcat (options|input)* + where options are: + -out N3 (aliases n, n3, ttl) + -out N-TRIPLE (aliases t, ntriple) + -out RDF/XML (aliases x, rdf, xml, rdfxml) + -out RDF/XML-ABBREV (default) + -in N3 (aliases n, n3, ttl) + -in N-TRIPLE (aliases t, ntriple) + -in RDF/XML (aliases x, rdf, xml, rdfxml) + -include + -noinclude (default) + + input is one of: + -n <filename> for n3 input (aliases -n3, -N3, -ttl) + -x <filename> for rdf/xml input (aliases -rdf, -xml, -rdfxml) + -t <filename> for n-triple input (aliases -ntriple) + or just a URL, a filename, or - for the standard input. + + */ + PrintStream p = new PrintStream(new File(outputOntopath)); + System.setOut(p); + jena.rdfcat.main(new String[]{"-x", inputOntopath,"-out", "ntriple"}); + p.flush(); + p.close(); + + + } + catch (Exception e) { + System.out.println("The ontology could not be created: " + e.getMessage()); + e.printStackTrace(); + } + + } + + } + + Modified: trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java 2008-09-01 10:50:00 UTC (rev 1167) +++ trunk/src/dl-learner/org/dllearner/scripts/SemanticBible2.java 2008-09-02 21:08:59 UTC (rev 1168) @@ -46,6 +46,7 @@ import org.dllearner.utilities.Files; import org.dllearner.utilities.JamonMonitorLogger; import org.dllearner.utilities.datastructures.SetManipulation; +import org.dllearner.utilities.examples.ExampleContainer; import org.dllearner.utilities.learn.ConfWriter; import org.dllearner.utilities.owl.ReasoningServiceFactory; import org.dllearner.utilities.owl.ReasoningServiceFactory.AvailableReasoners; @@ -124,6 +125,7 @@ ComponentManager cm =ComponentManager.getInstance(); try{ + for (File f : confs) { Cache.getDefaultCache().clearCache(); String fileContent = Files.readFile(f); @@ -143,6 +145,7 @@ LearningAlgorithm la = cm.getLiveLearningAlgorithms().remove(0); EvaluatedDescription onFragment =(la.getCurrentlyBestEvaluatedDescription()); + accFragment.addNumber(onFragment.getAccuracy()); dDepthFragment.addNumber((double)onFragment.getDescriptionDepth()); dLengthFragment.addNumber((double)onFragment.getDescriptionLength()); Added: trunk/src/dl-learner/org/dllearner/utilities/examples/ExampleContainer.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/examples/ExampleContainer.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/utilities/examples/ExampleContainer.java 2008-09-02 21:08:59 UTC (rev 1168) @@ -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.utilities.examples; + +import java.util.SortedSet; +import java.util.TreeSet; + +import org.dllearner.core.owl.Individual; + +public class ExampleContainer implements Comparable<ExampleContainer>{ + + + private static SortedSet<ExampleContainer> exampleSets = new TreeSet<ExampleContainer>(); + + private SortedSet<Individual> positiveExamples = new TreeSet<Individual>(); + private SortedSet<Individual> negativeExamples = new TreeSet<Individual>(); + + + public ExampleContainer(SortedSet<Individual> positiveExamples, SortedSet<Individual> negativeExamples) { + super(); + this.positiveExamples = positiveExamples; + this.negativeExamples = negativeExamples; + } + + + public static boolean add(ExampleContainer e){ + return exampleSets.add(e); + } + + public int compareTo(ExampleContainer e){ + + if(getNegativeExamples().equals(e.getNegativeExamples()) + && + getPositiveExamples().equals(e.getPositiveExamples())){ + return 0; + } + + boolean equalPosSize = false; + boolean equalNegSize = false; + + if(getPositiveExamples().size() == e.getPositiveExamples().size()){ + equalPosSize = true; + } + if(getNegativeExamples().size() == e.getNegativeExamples().size()){ + equalNegSize = true; + } + + + if(equalPosSize && !equalNegSize)return 1; + if(equalNegSize && !equalPosSize)return -1; + if(!equalPosSize && !equalPosSize)return 1; + + + return 1; + + } + + public SortedSet<Individual> getNegativeExamples() { + return negativeExamples; + } + public SortedSet<Individual> getPositiveExamples() { + return positiveExamples; + } + + + + +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |